diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/diagnostic.c | 54 | ||||
-rw-r--r-- | test/meson.build | 4 |
2 files changed, 19 insertions, 39 deletions
diff --git a/test/diagnostic.c b/test/diagnostic.c index 35866df..363743b 100644 --- a/test/diagnostic.c +++ b/test/diagnostic.c @@ -36,13 +36,11 @@ static int err_test(void); static int warn_test(void); static int fixme_test(void); static int info_test(void); -static int prefix_test(void); -static int thread_test(void); -static int clean_test(void); +static int format_test(void); static struct stdiocap capture_stdio_start(FILE *stream); static void capture_stdio_stop(struct stdiocap *cap); static char *visible_newlines(const char * const in); -static int test_default_channels(const char * const in, const char * const expected, size_t i, int usearg, void (*func)(const char *, const char *, ...)); +static int test_default_channels(const char * const in, const char * const expected, size_t i, int usearg, const char *func_name, void (*func)(const char *, const char *, ...)); int diagnostic_test(char *testname) { @@ -51,9 +49,7 @@ int diagnostic_test(char *testname) {"warn", warn_test}, {"fixme", fixme_test}, {"info", info_test}, - {"prefix", prefix_test}, - {"thread", thread_test}, - {"clean", clean_test} }; + {"format", format_test}}; size_t i; for (i = 0; i < arrlen(tests); ++i) { @@ -72,11 +68,11 @@ static int err_test(void) int ret; static const char *in[] = {"", "test", "test number is %zu", "%zu tests ran"}; - static const char *expected[] = {"error:\n", "error:test\n", "error:test number is 3\n", "error:4 tests ran\n"}; + static const char *expected[] = {"error:err_test:\n", "error:err_test:test\n", "error:err_test:test number is 3\n", "error:err_test:4 tests ran\n"}; for (i = 0; i < arrlen(in); ++i) { usearg = i < (arrlen(in) / 2) ? 0 : 1; - ret = test_default_channels(in[i], expected[i], i, usearg, __rin_err); + ret = test_default_channels(in[i], expected[i], i, usearg, __func__, __rin_err); } return ret; @@ -89,11 +85,11 @@ static int warn_test(void) int ret; static const char *in[] = {"", "test", "test number is %zu", "%zu tests ran"}; - static const char *expected[] = {"warning:\n", "warning:test\n", "warning:test number is 3\n", "warning:4 tests ran\n"}; + static const char *expected[] = {"warning:warn_test:\n", "warning:warn_test:test\n", "warning:warn_test:test number is 3\n", "warning:warn_test:4 tests ran\n"}; for (i = 0; i < arrlen(in); ++i) { usearg = i < (arrlen(in) / 2) ? 0 : 1; - ret = test_default_channels(in[i], expected[i], i, usearg, __rin_warn); + ret = test_default_channels(in[i], expected[i], i, usearg, __func__, __rin_warn); } return ret; @@ -106,11 +102,11 @@ static int fixme_test(void) int ret; static const char *in[] = {"", "test", "test number is %zu", "%zu tests ran"}; - static const char *expected[] = {"fixme:\n", "fixme:test\n", "fixme:test number is 3\n", "fixme:4 tests ran\n"}; + static const char *expected[] = {"fixme:fixme_test:\n", "fixme:fixme_test:test\n", "fixme:fixme_test:test number is 3\n", "fixme:fixme_test:4 tests ran\n"}; for (i = 0; i < arrlen(in); ++i) { usearg = i < (arrlen(in) / 2) ? 0 : 1; - ret = test_default_channels(in[i], expected[i], i, usearg, __rin_fixme); + ret = test_default_channels(in[i], expected[i], i, usearg, __func__, __rin_fixme); } return ret; @@ -123,14 +119,14 @@ static int info_test(void) int ret; static const char *in[] = {"", "test", "test number is %zu", "%zu tests ran"}; - static const char *expected[] = {"info:\n", "info:test\n", "info:test number is 3\n", "info:4 tests ran\n"}; + static const char *expected[] = {"info:info_test:\n", "info:info_test:test\n", "info:info_test:test number is 3\n", "info:info_test:4 tests ran\n"}; /* `ninja test` seems to be intercepting stdout, so we cannot test the default outstream */ rin_diag_set_outstream(rin_diag_info, stderr); for (i = 0; i < arrlen(in); ++i) { usearg = i < (arrlen(in) / 2) ? 0 : 1; - ret = test_default_channels(in[i], expected[i], i, usearg, __rin_info); + ret = test_default_channels(in[i], expected[i], i, usearg, __func__, __rin_info); } /* restore the default, kind of */ @@ -139,17 +135,7 @@ static int info_test(void) return ret; } -static int prefix_test(void) -{ - return 77; -} - -static int thread_test(void) -{ - return 77; -} - -static int clean_test(void) +static int format_test(void) { return 77; } @@ -221,16 +207,12 @@ static char *visible_newlines(const char * const in) return ret; } -static int test_default_channels(const char * const in, const char * const expected, size_t i, int usearg, void (*func)(const char *, const char *, ...)) +static int test_default_channels(const char * const in, const char * const expected, size_t i, int usearg, const char *func_name, void (*func)(const char *, const char *, ...)) { - char buf[32] = {0}; + char buf[64] = {0}; struct stdiocap cap; - size_t len; int ret = 0; - len = strlen(expected); - ++len; - cap = capture_stdio_start(stderr); if (!cap.pipe) { @@ -239,12 +221,12 @@ static int test_default_channels(const char * const in, const char * const expec } if (usearg) { - func(NULL, in, i + 1); + func(func_name, in, i + 1); } else { - func(NULL, in); + func(func_name, in); } - if (!(fgets(buf, sizeof(buf) < len ? sizeof(buf) : len, cap.pipe))) { + if (!(fgets(buf, sizeof(buf), cap.pipe))) { ret = 1; goto fail; } @@ -257,7 +239,7 @@ fail: } else { char *tmp[2]; - ret = strncmp(buf, expected, sizeof(buf) < len ? sizeof(buf) : len); + ret = strncmp(buf, expected, sizeof(buf)); tmp[0] = visible_newlines(buf); tmp[1] = visible_newlines(expected); diff --git a/test/meson.build b/test/meson.build index 7864166..3ca8a08 100644 --- a/test/meson.build +++ b/test/meson.build @@ -20,9 +20,7 @@ test('diagnostic err', test_e, args : ['diagnostic', 'err']) test('diagnostic warn', test_e, args : ['diagnostic', 'warn']) test('diagnostic fixme', test_e, args : ['diagnostic', 'fixme']) test('diagnostic info', test_e, args : ['diagnostic', 'info']) -test('diagnostic prefix', test_e, args : ['diagnostic', 'prefix']) -test('diagnostic thread', test_e, args : ['diagnostic', 'thread']) -test('diagnostic clean', test_e, args : ['diagnostic', 'clean']) +test('diagnostic format', test_e, args : ['diagnostic', 'format']) test('timespec add', test_e, args : ['time', 'timespec add']) test('timespec subtract', test_e, args : ['time', 'timespec sub']) test('timespec normalize', test_e, args : ['time', 'timespec normalize']) |