summaryrefslogtreecommitdiffstats
path: root/cpukit/libtest
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-22 14:57:32 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-28 14:30:46 +0100
commitd586b3c01484640b7b0243b172672f47fd8c0c74 (patch)
tree32e47c68d994151844e7cf7089d4c2fe5a610f8a /cpukit/libtest
parentbsps/imxrt1166: Disable video_mux (diff)
downloadrtems-d586b3c01484640b7b0243b172672f47fd8c0c74.tar.bz2
libtest: Add T_add_remark()
This can be used to report that nested test cases did run in a test case. Update #4971.
Diffstat (limited to 'cpukit/libtest')
-rw-r--r--cpukit/libtest/t-test.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index 1a9d85af55..1230505edf 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (C) 2018, 2020 embedded brains GmbH & Co. KG
+ * Copyright (C) 2018, 2023 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -72,6 +72,7 @@ typedef struct {
T_fixture_node *fixtures;
T_fixture_node case_fixture;
LIST_HEAD(, T_destructor) destructors;
+ T_remark remarks;
T_time case_begin_time;
atomic_uint planned_steps;
atomic_uint steps;
@@ -931,6 +932,23 @@ T_call_destructors(const T_context *ctx)
#endif
}
+static void
+T_make_remarks(T_context *ctx)
+{
+ T_remark *remark;
+
+ remark = ctx->remarks.next;
+
+ while (remark != &ctx->remarks) {
+ T_remark *current;
+
+ current = remark;
+ remark = current->next;
+ current->next = NULL;
+ T_do_log(ctx, T_QUIET, "R:%s\n", current->remark);
+ }
+}
+
static T_context *
T_do_run_initialize(const T_config *config)
{
@@ -982,6 +1000,7 @@ T_do_case_begin(T_context *ctx, const T_case_context *tc)
ctx->current_case = tc;
ctx->fixtures = &ctx->case_fixture;
LIST_INIT(&ctx->destructors);
+ ctx->remarks.next = &ctx->remarks;
atomic_store_explicit(&ctx->planned_steps, UINT_MAX,
memory_order_relaxed);
atomic_store_explicit(&ctx->steps, 0, memory_order_relaxed);
@@ -1033,6 +1052,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc)
T_call_destructors(ctx);
config = ctx->config;
T_actions_backward(config, T_EVENT_CASE_END, tc->name);
+ T_make_remarks(ctx);
planned_steps = atomic_fetch_add_explicit(&ctx->planned_steps,
0, memory_order_relaxed);
@@ -1293,6 +1313,18 @@ T_pop_fixture(void)
T_do_pop_fixture(&T_instance);
}
+void
+T_add_remark(T_remark *remark)
+{
+ if (remark->next == NULL) {
+ T_context *ctx;
+
+ ctx = &T_instance;
+ remark->next = ctx->remarks.next;
+ ctx->remarks.next = remark;
+ }
+}
+
size_t
T_get_scope(const char * const * const *desc, char *buf, size_t n,
const size_t *second_indices)