diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-13 11:33:47 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-18 07:08:51 +0200 |
commit | 72960bc7d4c8f7eb7687827d1c1545b1eb5fdb71 (patch) | |
tree | 1bf7537d745a7a46dc42aaebe26077296ad667ea /cpukit | |
parent | libtest: Add fixture steps (diff) | |
download | rtems-72960bc7d4c8f7eb7687827d1c1545b1eb5fdb71.tar.bz2 |
libtest: Change T_step() and T_assert_step()
Normally, the expected test step must be a compile time constant. Allow
variable expected test steps for the T_step() and T_assert_step(). This
can be used for parameterized test loops with individual fixtures.
Remove the ability to use custom failure messages due to some
implementation constraints.
Update #3199.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/include/rtems/test.h | 17 | ||||
-rw-r--r-- | cpukit/libtest/t-test.c | 11 |
2 files changed, 22 insertions, 6 deletions
diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 95e078ceff..ccab6c4a95 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -2168,12 +2168,17 @@ void T_check_rsc_success(const T_check_context *, uint32_t); void T_plan(unsigned int); -#define T_step(...) \ - T_flags_true(T_CHECK_STEP(T_VA_ARGS_FIRST(__VA_ARGS__)), \ - true T_VA_ARGS_MORE(__VA_ARGS__)) -#define T_step_assert(...) \ - T_flags_true(T_CHECK_STEP(T_VA_ARGS_FIRST(__VA_ARGS__)) | T_CHECK_STOP, \ - true T_VA_ARGS_MORE(__VA_ARGS__)) +void T_check_step(const T_check_context *, unsigned int); + +#define T_flags_step(a, flags) \ +{ \ + static const T_check_context T_check_instance = { \ + T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }; \ + T_check_step(&T_check_instance, a); \ +} + +#define T_step(e) T_flags_step(e, 0) +#define T_step_assert(e) T_flags_step(e, T_CHECK_STOP) /** * @defgroup RTEMSTestFrameworkTime Time Services diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index 4d68a83fff..3f9046a891 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -551,6 +551,17 @@ void T_plan(unsigned int planned_steps) } void +T_check_step(const T_check_context *t, unsigned int expected) +{ + T_check_context tt; + + tt = *t; + tt.flags |= T_CHECK_STEP(expected); + T_check(&tt, true, "actual step is not equal to expected step (%u)", + expected); +} + +void T_case_register(T_case_context *tc) { T_context *ctx; |