mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 17:20:48 +08:00
libtest: Add T_CHECK_FMT
Rename internal function T_check_true() to T_check() and use the new flag T_CHECK_FMT to indicate if a format string is present. This is a preparation step to make the format string optional. Make the check context the first parameter. The API remains the same. Update #3199.
This commit is contained in:
+172
-166
File diff suppressed because it is too large
Load Diff
@@ -134,12 +134,12 @@ const char *T_strerror(int eno)
|
||||
}
|
||||
}
|
||||
|
||||
void T_check_eno(int a, const T_check_context *t, int e)
|
||||
void T_check_eno(const T_check_context *t, int a, int e)
|
||||
{
|
||||
T_check_true(a == e, t, "%s == %s", T_strerror(a), T_strerror(e));
|
||||
T_check(t, a == e, "%s == %s", T_strerror(a), T_strerror(e));
|
||||
}
|
||||
|
||||
void T_check_eno_success(int a, const T_check_context *t)
|
||||
void T_check_eno_success(const T_check_context *t, int a)
|
||||
{
|
||||
T_check_eno(a, t, 0);
|
||||
T_check_eno(t, a, 0);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
void T_check_psx_error(int a, const T_check_context *t, int eeno)
|
||||
void T_check_psx_error(const T_check_context *t, int a, int eeno)
|
||||
{
|
||||
int aeno;
|
||||
|
||||
aeno = errno;
|
||||
T_check_true(a == -1 && aeno == eeno, t, "%i == -1, %s == %s", a,
|
||||
T_check(t, a == -1 && aeno == eeno, "%i == -1, %s == %s", a,
|
||||
T_strerror(aeno), T_strerror(eeno));
|
||||
}
|
||||
|
||||
void T_check_psx_success(int a, const T_check_context *t)
|
||||
void T_check_psx_success(const T_check_context *t, int a)
|
||||
{
|
||||
T_check_true(a == 0, t, "%i == 0, %s", a, T_strerror(errno));
|
||||
T_check(t, a == 0, "%i == 0, %s", a, T_strerror(errno));
|
||||
}
|
||||
|
||||
@@ -30,299 +30,299 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
void
|
||||
T_check_eq_ptr(const void *a, const T_check_context_msg *t, const void *e)
|
||||
T_check_eq_ptr(const T_check_context_msg *t, const void *a, const void *e)
|
||||
{
|
||||
T_check_true(a == e, &t->base, "%s", t->msg);
|
||||
T_check(&t->base, a == e, "%s", t->msg);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_ptr(const void *a, const T_check_context_msg *t, const void *e)
|
||||
T_check_ne_ptr(const T_check_context_msg *t, const void *a, const void *e)
|
||||
{
|
||||
T_check_true(a != e, &t->base, "%s", t->msg);
|
||||
T_check(&t->base, a != e, "%s", t->msg);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_null(const void *a, const T_check_context_msg *t)
|
||||
T_check_null(const T_check_context_msg *t, const void *a)
|
||||
{
|
||||
T_check_true(a == NULL, &t->base, "%s == NULL", t->msg);
|
||||
T_check(&t->base, a == NULL, "%s == NULL", t->msg);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_not_null(const void *a, const T_check_context_msg *t)
|
||||
T_check_not_null(const T_check_context_msg *t, const void *a)
|
||||
{
|
||||
T_check_true(a != NULL, &t->base, "%s != NULL", t->msg);
|
||||
T_check(&t->base, a != NULL, "%s != NULL", t->msg);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_mem(const void *a, const T_check_context_msg *t, const void *e,
|
||||
T_check_eq_mem(const T_check_context_msg *t, const void *a, const void *e,
|
||||
size_t n)
|
||||
{
|
||||
T_check_true(memcmp(a, e, n) == 0, &t->base, "%s", t->msg);
|
||||
T_check(&t->base, memcmp(a, e, n) == 0, "%s", t->msg);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_mem(const void *a, const T_check_context_msg *t, const void *e,
|
||||
T_check_ne_mem(const T_check_context_msg *t, const void *a, const void *e,
|
||||
size_t n)
|
||||
{
|
||||
T_check_true(memcmp(a, e, n) != 0, &t->base, "%s", t->msg);
|
||||
T_check(&t->base, memcmp(a, e, n) != 0, "%s", t->msg);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_str(const char *a, const T_check_context *t, const char *e)
|
||||
T_check_eq_str(const T_check_context *t, const char *a, const char *e)
|
||||
{
|
||||
T_check_true(strcmp(a, e) == 0, t, "\"%s\" == \"%s\"", a, e);
|
||||
T_check(t, strcmp(a, e) == 0, "\"%s\" == \"%s\"", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_str(const char *a, const T_check_context *t, const char *e)
|
||||
T_check_ne_str(const T_check_context *t, const char *a, const char *e)
|
||||
{
|
||||
T_check_true(strcmp(a, e) != 0, t, "\"%s\" != \"%s\"", a, e);
|
||||
T_check(t, strcmp(a, e) != 0, "\"%s\" != \"%s\"", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_nstr(const char *a, const T_check_context *t, const char *e, size_t n)
|
||||
T_check_eq_nstr(const T_check_context *t, const char *a, const char *e, size_t n)
|
||||
{
|
||||
T_check_true(strncmp(a, e, n) == 0, t, "\"%.*s\" == \"%.*s\"", (int)n, a,
|
||||
T_check(t, strncmp(a, e, n) == 0, "\"%.*s\" == \"%.*s\"", (int)n, a,
|
||||
(int)n, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_nstr(const char *a, const T_check_context *t, const char *e, size_t n)
|
||||
T_check_ne_nstr(const T_check_context *t, const char *a, const char *e, size_t n)
|
||||
{
|
||||
T_check_true(strncmp(a, e, n) != 0, t, "\"%.*s\" != \"%.*s\"", (int)n, a,
|
||||
T_check(t, strncmp(a, e, n) != 0, "\"%.*s\" != \"%.*s\"", (int)n, a,
|
||||
(int)n, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_char(char a, const T_check_context *t, char e)
|
||||
T_check_eq_char(const T_check_context *t, char a, char e)
|
||||
{
|
||||
T_check_true(a == e, t, "'%c' == '%c'", a, e);
|
||||
T_check(t, a == e, "'%c' == '%c'", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_char(char a, const T_check_context *t, char e)
|
||||
T_check_ne_char(const T_check_context *t, char a, char e)
|
||||
{
|
||||
T_check_true(a != e, t, "'%c' != '%c'", a, e);
|
||||
T_check(t, a != e, "'%c' != '%c'", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_int(int a, const T_check_context *t, int e)
|
||||
T_check_eq_int(const T_check_context *t, int a, int e)
|
||||
{
|
||||
T_check_true(a == e, t, "%i == %i", a, e);
|
||||
T_check(t, a == e, "%i == %i", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_int(int a, const T_check_context *t, int e)
|
||||
T_check_ne_int(const T_check_context *t, int a, int e)
|
||||
{
|
||||
T_check_true(a != e, t, "%i != %i", a, e);
|
||||
T_check(t, a != e, "%i != %i", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ge_int(int a, const T_check_context *t, int e)
|
||||
T_check_ge_int(const T_check_context *t, int a, int e)
|
||||
{
|
||||
T_check_true(a >= e, t, "%i >= %i", a, e);
|
||||
T_check(t, a >= e, "%i >= %i", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_gt_int(int a, const T_check_context *t, int e)
|
||||
T_check_gt_int(const T_check_context *t, int a, int e)
|
||||
{
|
||||
T_check_true(a > e, t, "%i > %i", a, e);
|
||||
T_check(t, a > e, "%i > %i", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_le_int(int a, const T_check_context *t, int e)
|
||||
T_check_le_int(const T_check_context *t, int a, int e)
|
||||
{
|
||||
T_check_true(a <= e, t, "%i <= %i", a, e);
|
||||
T_check(t, a <= e, "%i <= %i", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_lt_int(int a, const T_check_context *t, int e)
|
||||
T_check_lt_int(const T_check_context *t, int a, int e)
|
||||
{
|
||||
T_check_true(a < e, t, "%i < %i", a, e);
|
||||
T_check(t, a < e, "%i < %i", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_uint(unsigned int a, const T_check_context *t, unsigned int e)
|
||||
T_check_eq_uint(const T_check_context *t, unsigned int a, unsigned int e)
|
||||
{
|
||||
T_check_true(a == e, t, "%u == %u", a, e);
|
||||
T_check(t, a == e, "%u == %u", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_uint(unsigned int a, const T_check_context *t, unsigned int e)
|
||||
T_check_ne_uint(const T_check_context *t, unsigned int a, unsigned int e)
|
||||
{
|
||||
T_check_true(a != e, t, "%u != %u", a, e);
|
||||
T_check(t, a != e, "%u != %u", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ge_uint(unsigned int a, const T_check_context *t, unsigned int e)
|
||||
T_check_ge_uint(const T_check_context *t, unsigned int a, unsigned int e)
|
||||
{
|
||||
T_check_true(a >= e, t, "%u >= %u", a, e);
|
||||
T_check(t, a >= e, "%u >= %u", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_gt_uint(unsigned int a, const T_check_context *t, unsigned int e)
|
||||
T_check_gt_uint(const T_check_context *t, unsigned int a, unsigned int e)
|
||||
{
|
||||
T_check_true(a > e, t, "%u > %u", a, e);
|
||||
T_check(t, a > e, "%u > %u", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_le_uint(unsigned int a, const T_check_context *t, unsigned int e)
|
||||
T_check_le_uint(const T_check_context *t, unsigned int a, unsigned int e)
|
||||
{
|
||||
T_check_true(a <= e, t, "%u <= %u", a, e);
|
||||
T_check(t, a <= e, "%u <= %u", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_lt_uint(unsigned int a, const T_check_context *t, unsigned int e)
|
||||
T_check_lt_uint(const T_check_context *t, unsigned int a, unsigned int e)
|
||||
{
|
||||
T_check_true(a < e, t, "%u < %u", a, e);
|
||||
T_check(t, a < e, "%u < %u", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_long(long a, const T_check_context *t, long e)
|
||||
T_check_eq_long(const T_check_context *t, long a, long e)
|
||||
{
|
||||
T_check_true(a == e, t, "%li == %li", a, e);
|
||||
T_check(t, a == e, "%li == %li", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_long(long a, const T_check_context *t, long e)
|
||||
T_check_ne_long(const T_check_context *t, long a, long e)
|
||||
{
|
||||
T_check_true(a != e, t, "%li != %li", a, e);
|
||||
T_check(t, a != e, "%li != %li", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ge_long(long a, const T_check_context *t, long e)
|
||||
T_check_ge_long(const T_check_context *t, long a, long e)
|
||||
{
|
||||
T_check_true(a >= e, t, "%li >= %li", a, e);
|
||||
T_check(t, a >= e, "%li >= %li", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_gt_long(long a, const T_check_context *t, long e)
|
||||
T_check_gt_long(const T_check_context *t, long a, long e)
|
||||
{
|
||||
T_check_true(a > e, t, "%li > %li", a, e);
|
||||
T_check(t, a > e, "%li > %li", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_le_long(long a, const T_check_context *t, long e)
|
||||
T_check_le_long(const T_check_context *t, long a, long e)
|
||||
{
|
||||
T_check_true(a <= e, t, "%li <= %li", a, e);
|
||||
T_check(t, a <= e, "%li <= %li", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_lt_long(long a, const T_check_context *t, long e)
|
||||
T_check_lt_long(const T_check_context *t, long a, long e)
|
||||
{
|
||||
T_check_true(a < e, t, "%li < %li", a, e);
|
||||
T_check(t, a < e, "%li < %li", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_ulong(unsigned long a, const T_check_context *t, unsigned long e)
|
||||
T_check_eq_ulong(const T_check_context *t, unsigned long a, unsigned long e)
|
||||
{
|
||||
T_check_true(a == e, t, "%lu == %lu", a, e);
|
||||
T_check(t, a == e, "%lu == %lu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_ulong(unsigned long a, const T_check_context *t, unsigned long e)
|
||||
T_check_ne_ulong(const T_check_context *t, unsigned long a, unsigned long e)
|
||||
{
|
||||
T_check_true(a != e, t, "%lu != %lu", a, e);
|
||||
T_check(t, a != e, "%lu != %lu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ge_ulong(unsigned long a, const T_check_context *t, unsigned long e)
|
||||
T_check_ge_ulong(const T_check_context *t, unsigned long a, unsigned long e)
|
||||
{
|
||||
T_check_true(a >= e, t, "%lu >= %lu", a, e);
|
||||
T_check(t, a >= e, "%lu >= %lu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_gt_ulong(unsigned long a, const T_check_context *t, unsigned long e)
|
||||
T_check_gt_ulong(const T_check_context *t, unsigned long a, unsigned long e)
|
||||
{
|
||||
T_check_true(a > e, t, "%lu > %lu", a, e);
|
||||
T_check(t, a > e, "%lu > %lu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_le_ulong(unsigned long a, const T_check_context *t, unsigned long e)
|
||||
T_check_le_ulong(const T_check_context *t, unsigned long a, unsigned long e)
|
||||
{
|
||||
T_check_true(a <= e, t, "%lu <= %lu", a, e);
|
||||
T_check(t, a <= e, "%lu <= %lu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_lt_ulong(unsigned long a, const T_check_context *t, unsigned long e)
|
||||
T_check_lt_ulong(const T_check_context *t, unsigned long a, unsigned long e)
|
||||
{
|
||||
T_check_true(a < e, t, "%lu < %lu", a, e);
|
||||
T_check(t, a < e, "%lu < %lu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_ll(long long a, const T_check_context *t, long long e)
|
||||
T_check_eq_ll(const T_check_context *t, long long a, long long e)
|
||||
{
|
||||
T_check_true(a == e, t, "%lli == %lli", a, e);
|
||||
T_check(t, a == e, "%lli == %lli", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_ll(long long a, const T_check_context *t, long long e)
|
||||
T_check_ne_ll(const T_check_context *t, long long a, long long e)
|
||||
{
|
||||
T_check_true(a != e, t, "%lli != %lli", a, e);
|
||||
T_check(t, a != e, "%lli != %lli", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ge_ll(long long a, const T_check_context *t, long long e)
|
||||
T_check_ge_ll(const T_check_context *t, long long a, long long e)
|
||||
{
|
||||
T_check_true(a >= e, t, "%lli >= %lli", a, e);
|
||||
T_check(t, a >= e, "%lli >= %lli", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_gt_ll(long long a, const T_check_context *t, long long e)
|
||||
T_check_gt_ll(const T_check_context *t, long long a, long long e)
|
||||
{
|
||||
T_check_true(a > e, t, "%lli > %lli", a, e);
|
||||
T_check(t, a > e, "%lli > %lli", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_le_ll(long long a, const T_check_context *t, long long e)
|
||||
T_check_le_ll(const T_check_context *t, long long a, long long e)
|
||||
{
|
||||
T_check_true(a <= e, t, "%lli <= %lli", a, e);
|
||||
T_check(t, a <= e, "%lli <= %lli", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_lt_ll(long long a, const T_check_context *t, long long e)
|
||||
T_check_lt_ll(const T_check_context *t, long long a, long long e)
|
||||
{
|
||||
T_check_true(a < e, t, "%lli < %lli", a, e);
|
||||
T_check(t, a < e, "%lli < %lli", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_eq_ull(unsigned long long a, const T_check_context *t,
|
||||
T_check_eq_ull(const T_check_context *t, unsigned long long a,
|
||||
unsigned long long e)
|
||||
{
|
||||
T_check_true(a == e, t, "%llu == %llu", a, e);
|
||||
T_check(t, a == e, "%llu == %llu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ne_ull(unsigned long long a, const T_check_context *t,
|
||||
T_check_ne_ull(const T_check_context *t, unsigned long long a,
|
||||
unsigned long long e)
|
||||
{
|
||||
T_check_true(a != e, t, "%llu != %llu", a, e);
|
||||
T_check(t, a != e, "%llu != %llu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_ge_ull(unsigned long long a, const T_check_context *t,
|
||||
T_check_ge_ull(const T_check_context *t, unsigned long long a,
|
||||
unsigned long long e)
|
||||
{
|
||||
T_check_true(a >= e, t, "%llu >= %llu", a, e);
|
||||
T_check(t, a >= e, "%llu >= %llu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_gt_ull(unsigned long long a, const T_check_context *t,
|
||||
T_check_gt_ull(const T_check_context *t, unsigned long long a,
|
||||
unsigned long long e)
|
||||
{
|
||||
T_check_true(a > e, t, "%llu > %llu", a, e);
|
||||
T_check(t, a > e, "%llu > %llu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_le_ull(unsigned long long a, const T_check_context *t,
|
||||
T_check_le_ull(const T_check_context *t, unsigned long long a,
|
||||
unsigned long long e)
|
||||
{
|
||||
T_check_true(a <= e, t, "%llu <= %llu", a, e);
|
||||
T_check(t, a <= e, "%llu <= %llu", a, e);
|
||||
}
|
||||
|
||||
void
|
||||
T_check_lt_ull(unsigned long long a, const T_check_context *t,
|
||||
T_check_lt_ull(const T_check_context *t, unsigned long long a,
|
||||
unsigned long long e)
|
||||
{
|
||||
T_check_true(a < e, t, "%llu < %llu", a, e);
|
||||
T_check(t, a < e, "%llu < %llu", a, e);
|
||||
}
|
||||
|
||||
@@ -41,15 +41,15 @@ T_do_check_task_context(void)
|
||||
uint32_t v;
|
||||
|
||||
v = _Per_CPU_Get_snapshot()->thread_dispatch_disable_level;
|
||||
T_check_true(v == 0, NULL,
|
||||
T_check(&T_special, v == 0,
|
||||
"Wrong thread dispatch disabled level (%" PRIu32 ")", v);
|
||||
|
||||
v = _Per_CPU_Get_snapshot()->isr_nest_level;
|
||||
T_check_true(v == 0, NULL,
|
||||
T_check(&T_special, v == 0,
|
||||
"Wrong ISR nest level (%" PRIu32 ")", v);
|
||||
|
||||
v = _ISR_Get_level();
|
||||
T_check_true(v == 0, NULL,
|
||||
T_check(&T_special, v == 0,
|
||||
"Wrong ISR level (%" PRIu32 ")", v);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ T_check_open_fds(void)
|
||||
|
||||
if (delta != 0) {
|
||||
T_open_fds = open_fds;
|
||||
T_check_true(false, NULL, "file descriptor leak (%+i)", delta);
|
||||
T_check(&T_special, false, "file descriptor leak (%+i)",
|
||||
delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ T_heap_case_end(void)
|
||||
where = "workspace";
|
||||
}
|
||||
|
||||
T_check_true(ok, NULL, "memory leak in %s", where);
|
||||
T_check(&T_special, ok, "memory leak in %s", where);
|
||||
memcpy(&ctx->workspace_info, &info, sizeof(info));
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ T_heap_case_end(void)
|
||||
ok = memcmp(&info, &ctx->heap_info, sizeof(info)) == 0;
|
||||
|
||||
if (!ok) {
|
||||
T_check_true(ok, NULL, "memory leak in heap");
|
||||
T_check(&T_special, ok, "memory leak in heap");
|
||||
memcpy(&ctx->heap_info, &info, sizeof(info));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ T_objects_check(Objects_APIs api, uint16_t cls,
|
||||
|
||||
if (delta != 0) {
|
||||
*expected = count;
|
||||
T_check_true(false, NULL, "%s leak (%" PRIi32 ")", name, delta);
|
||||
T_check(&T_special, false, "%s leak (%" PRIi32 ")", name,
|
||||
delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,8 @@ T_posix_keys_case_end(void)
|
||||
|
||||
if (delta != 0) {
|
||||
T_posix_key_value_count = count;
|
||||
T_check_true(false, NULL, "POSIX key value pair leak (%zi)", delta);
|
||||
T_check(&T_special, false, "POSIX key value pair leak (%zi)",
|
||||
delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,14 +38,14 @@ T_putchar_default(int c, void *arg)
|
||||
}
|
||||
|
||||
void
|
||||
T_check_rsc(uint32_t a, const T_check_context *t, uint32_t e)
|
||||
T_check_rsc(const T_check_context *t, uint32_t a, uint32_t e)
|
||||
{
|
||||
T_check_true(a == e, t, "%s == %s", rtems_status_text(a),
|
||||
T_check(t, a == e, "%s == %s", rtems_status_text(a),
|
||||
rtems_status_text(e));
|
||||
}
|
||||
|
||||
void
|
||||
T_check_rsc_success(uint32_t a, const T_check_context *t)
|
||||
T_check_rsc_success(const T_check_context *t, uint32_t a)
|
||||
{
|
||||
T_check_rsc(a, t, RTEMS_SUCCESSFUL);
|
||||
T_check_rsc(t, a, RTEMS_SUCCESSFUL);
|
||||
}
|
||||
|
||||
+54
-50
@@ -86,6 +86,12 @@ typedef struct {
|
||||
|
||||
static T_context T_instance;
|
||||
|
||||
const T_check_context T_special = {
|
||||
.file = "*",
|
||||
.line = -1,
|
||||
.flags = T_CHECK_FMT | T_CHECK_QUIET
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *s;
|
||||
size_t n;
|
||||
@@ -462,7 +468,8 @@ void T_plan(unsigned int planned_steps)
|
||||
success = atomic_compare_exchange_strong_explicit(&ctx->planned_steps,
|
||||
&expected, planned_steps, memory_order_relaxed,
|
||||
memory_order_relaxed);
|
||||
T_check_true(success, NULL, "planned steps (%u) already set", expected);
|
||||
T_check(&T_special, success, "planned steps (%u) already set",
|
||||
expected);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -529,68 +536,65 @@ T_file(const T_check_context *t)
|
||||
}
|
||||
|
||||
void
|
||||
T_check_true(bool ok, const T_check_context *t, const char *fmt, ...)
|
||||
T_check(const T_check_context *t, bool ok, ...)
|
||||
{
|
||||
T_context *ctx;
|
||||
va_list ap;
|
||||
char scope[T_SCOPE_SIZE];
|
||||
unsigned int step;
|
||||
|
||||
ctx = &T_instance;
|
||||
|
||||
if (t != NULL) {
|
||||
unsigned int step;
|
||||
if ((t->flags & T_CHECK_QUIET) == 0) {
|
||||
step = T_fetch_add_step(ctx);
|
||||
} else {
|
||||
step = UINT_MAX;
|
||||
}
|
||||
|
||||
if ((t->flags & T_CHECK_QUIET) == 0) {
|
||||
step = T_fetch_add_step(ctx);
|
||||
} else {
|
||||
step = UINT_MAX;
|
||||
}
|
||||
|
||||
if ((t->flags & T_CHECK_STEP_FLAG) != 0 &&
|
||||
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(ctx, scope), T_file(t), t->line,
|
||||
T_CHECK_STEP_FROM_FLAGS(t->flags));
|
||||
} else if (!ok) {
|
||||
T_add_failure(ctx);
|
||||
|
||||
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(ctx, scope),
|
||||
T_file(t), t->line);
|
||||
} else {
|
||||
T_printf("F:*:%i:%s:%s:%i:", T_cpu(),
|
||||
T_scope(ctx, scope), T_file(t),
|
||||
t->line);
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
T_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
T_printf("\n");
|
||||
}
|
||||
|
||||
if ((t->flags & T_CHECK_STOP) != 0) {
|
||||
T_do_stop(ctx);
|
||||
}
|
||||
} 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(ctx, scope), T_file(t), t->line);
|
||||
}
|
||||
if ((t->flags & T_CHECK_STEP_FLAG) != 0 &&
|
||||
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(ctx, scope), T_file(t), t->line,
|
||||
T_CHECK_STEP_FROM_FLAGS(t->flags));
|
||||
} else if (!ok) {
|
||||
T_add_failure(ctx);
|
||||
|
||||
T_printf("F:*:%i:%s:*:*:", T_cpu(), T_scope(ctx, scope));
|
||||
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(ctx, scope),
|
||||
T_file(t), t->line);
|
||||
} else if (t->line >= 0) {
|
||||
T_printf("F:*:%i:%s:%s:%i", T_cpu(),
|
||||
T_scope(ctx, scope), T_file(t),
|
||||
t->line);
|
||||
} else {
|
||||
T_printf("F:*:%i:%s:%s:*", T_cpu(),
|
||||
T_scope(ctx, scope), T_file(t));
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
T_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
if ((t->flags & T_CHECK_FMT) != 0) {
|
||||
const char *fmt;
|
||||
|
||||
T_printf("\n");
|
||||
T_printf(":");
|
||||
|
||||
va_start(ap, ok);
|
||||
fmt = va_arg(ap, const char *);
|
||||
T_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
T_printf("\n");
|
||||
}
|
||||
|
||||
if ((t->flags & T_CHECK_STOP) != 0) {
|
||||
T_do_stop(ctx);
|
||||
}
|
||||
} 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(ctx, scope), T_file(t), t->line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user