summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-11-11 17:09:58 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-11-19 08:39:02 +0100
commit78baeb757957fa0807c30e6c4d21ae99c9639e6a (patch)
tree75a2bad02a15e15c99b31abd132b22fc2665af54
parentlibtest: Rename ValidCache in FullCache (diff)
downloadrtems-78baeb757957fa0807c30e6c4d21ae99c9639e6a.tar.bz2
libtest: Allow assert checks during test begin
Allow assert checks in test begin actions and setup fixture methods.
-rw-r--r--cpukit/include/rtems/test.h2
-rw-r--r--cpukit/libtest/t-test.c29
2 files changed, 18 insertions, 13 deletions
diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h
index 509c7d0213..573f7b93c9 100644
--- a/cpukit/include/rtems/test.h
+++ b/cpukit/include/rtems/test.h
@@ -2306,7 +2306,7 @@ void T_run_all(void);
void T_run_by_name(const char *);
-void T_case_begin(const char *, const T_fixture *);
+bool T_case_begin(const char *, const T_fixture *);
void T_case_end(void);
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index 2e27e3c9e6..ca91d1592f 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -948,7 +948,7 @@ T_do_run_initialize(const T_config *config)
return ctx;
}
-static void
+static bool
T_do_case_begin(T_context *ctx, const T_case_context *tc)
{
const T_config *config;
@@ -969,16 +969,23 @@ T_do_case_begin(T_context *ctx, const T_case_context *tc)
T_actions_forward(config, T_EVENT_CASE_EARLY, tc->name);
T_do_log(ctx, T_NORMAL, "B:%s\n", tc->name);
ctx->case_begin_time = (*config->now)();
- T_actions_forward(config, T_EVENT_CASE_BEGIN, tc->name);
- if (fixture != NULL) {
- ctx->case_fixture.fixture = fixture;
- ctx->case_fixture.context = fixture->initial_context;
+ if (setjmp(ctx->case_begin_context) == 0) {
+ T_actions_forward(config, T_EVENT_CASE_BEGIN, tc->name);
+
+ if (fixture != NULL) {
+ ctx->case_fixture.fixture = fixture;
+ ctx->case_fixture.context = fixture->initial_context;
- if (fixture->setup != NULL) {
- (*fixture->setup)(ctx->case_fixture.context);
+ if (fixture->setup != NULL) {
+ (*fixture->setup)(ctx->case_fixture.context);
+ }
}
+
+ return true;
}
+
+ return false;
}
static void
@@ -1034,9 +1041,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc)
static void
T_run_case(T_context *ctx, const T_case_context *tc)
{
- T_do_case_begin(ctx, tc);
-
- if (setjmp(ctx->case_begin_context) == 0) {
+ if (T_do_case_begin(ctx, tc)) {
(*tc->body)();
}
@@ -1140,7 +1145,7 @@ T_run_by_name(const char *name)
static T_case_context default_case;
-void
+bool
T_case_begin(const char *name, const T_fixture *fixture)
{
T_case_context *tc;
@@ -1148,7 +1153,7 @@ T_case_begin(const char *name, const T_fixture *fixture)
tc = &default_case;
tc->name = name;
tc->fixture = fixture;
- T_do_case_begin(&T_instance, tc);
+ return T_do_case_begin(&T_instance, tc);
}
void