summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-11-22 11:28:55 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-11-25 11:32:19 +0100
commita0304e8d62325b4f3c07c0c520220c7929eea1c0 (patch)
tree4273b4210bc366f6d37042c9a7ed59169e98415e
parentbsp/mpc55xxevb: Remove obsolete linker cmd file (diff)
downloadrtems-a0304e8d62325b4f3c07c0c520220c7929eea1c0.tar.bz2
libtest: Output basename of source files
Output only the basename of source files to be independent of the build system source paths. In the future it may be better to use the GCC -fmacro-prefix-map option. This option is available in GCC 8 and later. It is not yet available in clang. Update #3818.
-rw-r--r--cpukit/libtest/t-test.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index 6338750c8c..5e9be54ed2 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -480,6 +480,20 @@ T_case_name(void)
}
}
+static const char *
+T_file(const T_check_context *t)
+{
+ const char *file;
+
+ file = strrchr(t->file, '/');
+
+ if (file == NULL) {
+ return t->file;
+ }
+
+ return file + 1;
+}
+
void
T_check_true(bool ok, const T_check_context *t, const char *fmt, ...)
{
@@ -502,7 +516,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->line,
+ T_cpu(), T_scope(scope), T_file(t), t->line,
T_CHECK_STEP_FROM_FLAGS(t->flags));
} else if (!ok) {
T_add_failure(ctx);
@@ -511,10 +525,10 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...)
if ((t->flags & T_CHECK_QUIET) == 0) {
T_printf("F:%u:%i:%s:%s:%i:",
step, T_cpu(), T_scope(scope),
- t->file, t->line);
+ T_file(t), t->line);
} else {
T_printf("F:*:%i:%s:%s:%i:", T_cpu(),
- T_scope(scope), t->file, t->line);
+ T_scope(scope), T_file(t), t->line);
}
va_start(ap, fmt);
@@ -530,7 +544,7 @@ 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->line);
+ T_scope(scope), T_file(t), t->line);
}
} else if (!ok) {
T_add_failure(ctx);