summaryrefslogtreecommitdiffstats
path: root/cpukit/libtest
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-06-08 10:04:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-07-23 09:27:47 +0200
commit6b27e3251eb6b3374751cdcec4015b4ee1026e0e (patch)
tree79bcdce7c596569ae3dd5c1b77ec343ece5b37b6 /cpukit/libtest
parentlibtest: Add T_make_runner() (diff)
downloadrtems-6b27e3251eb6b3374751cdcec4015b4ee1026e0e.tar.bz2
libtest: Support custom scope messages via fixture
Update #3199.
Diffstat (limited to 'cpukit/libtest')
-rw-r--r--cpukit/libtest/t-test.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index a0336fa461..aa04f09139 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -49,7 +49,7 @@
#define T_LINE_SIZE 128
-#define T_SCOPE_SIZE 5
+#define T_SCOPE_SIZE 64
typedef struct {
pthread_spinlock_t lock;
@@ -285,9 +285,10 @@ T_thread_name(const Thread_Control *th, char *buf)
#endif
static const char *
-T_scope(char *buf)
+T_scope(T_context *ctx, char *buf)
{
const char *r;
+ const T_case_context *tc;
#if defined(__rtems__)
ISR_Level level;
@@ -326,6 +327,20 @@ T_scope(char *buf)
r = buf;
#endif
+ tc = ctx->current_case;
+ if (tc != NULL) {
+ const T_fixture *fixture;
+
+ fixture = tc->fixture;
+ if (fixture != NULL && fixture->scope != NULL) {
+ size_t n;
+
+ n = strlen(r);
+ (*fixture->scope)(ctx->fixture_context, buf + n,
+ T_SCOPE_SIZE - n);
+ }
+ }
+
return r;
}
@@ -522,7 +537,7 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...)
step != T_CHECK_STEP_FROM_FLAGS(t->flags)) {
T_add_failure(ctx);
T_printf("F:%u:%i:%s:%s:%i:planned step (%u)\n", step,
- T_cpu(), T_scope(scope), T_file(t), t->line,
+ T_cpu(), T_scope(ctx, scope), T_file(t), t->line,
T_CHECK_STEP_FROM_FLAGS(t->flags));
} else if (!ok) {
T_add_failure(ctx);
@@ -530,11 +545,12 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...)
if (ctx->verbosity >= T_NORMAL) {
if ((t->flags & T_CHECK_QUIET) == 0) {
T_printf("F:%u:%i:%s:%s:%i:",
- step, T_cpu(), T_scope(scope),
+ step, T_cpu(), T_scope(ctx, scope),
T_file(t), t->line);
} else {
T_printf("F:*:%i:%s:%s:%i:", T_cpu(),
- T_scope(scope), T_file(t), t->line);
+ T_scope(ctx, scope), T_file(t),
+ t->line);
}
va_start(ap, fmt);
@@ -550,12 +566,12 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...)
} else if ((t->flags & T_CHECK_QUIET) == 0 &&
ctx->verbosity >= T_VERBOSE) {
T_printf("P:%u:%i:%s:%s:%i\n", step, T_cpu(),
- T_scope(scope), T_file(t), t->line);
+ T_scope(ctx, scope), T_file(t), t->line);
}
} else if (!ok) {
T_add_failure(ctx);
- T_printf("F:*:%i:%s:*:*:", T_cpu(), T_scope(scope));
+ T_printf("F:*:%i:%s:*:*:", T_cpu(), T_scope(ctx, scope));
va_start(ap, fmt);
T_vprintf(fmt, ap);
@@ -802,7 +818,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc)
T_printf("F:*:%i:%s:*:*:actual steps (%u), "
"planned steps (%u)\n", T_cpu(),
- T_scope(scope), steps, planned_steps);
+ T_scope(ctx, scope), steps, planned_steps);
}
}