X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Futils%2Ftap%2Ftap.c;h=8e9f9a645fc38c2ec09a972b1b8d45fbcccb891c;hb=994cd345db7a82957ce647c2dac28cae11382dcc;hp=08dfa658ca76e4e3cdca4ab1fca7f1c694b4d791;hpb=3842465694945829d76452ff83924aa0103c6293;p=babeltrace.git diff --git a/tests/utils/tap/tap.c b/tests/utils/tap/tap.c index 08dfa658..8e9f9a64 100644 --- a/tests/utils/tap/tap.c +++ b/tests/utils/tap/tap.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2004 Nik Clayton + * 2017 Jérémie Galarneau * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,6 +29,9 @@ #include #include #include +#include +#include +#include #include "tap.h" @@ -38,7 +42,7 @@ static unsigned int test_count = 0; /* Number of tests that have been run */ static unsigned int e_tests = 0; /* Expected number of tests to run */ static unsigned int failures = 0; /* Number of tests that failed */ static char *todo_msg = NULL; -static char *todo_msg_fixed = "libtap malloc issue"; +static const char *todo_msg_fixed = "libtap malloc issue"; static int todo = 0; static int test_died = 0; @@ -58,6 +62,18 @@ static void _expected_tests(unsigned int); static void _tap_init(void); static void _cleanup(void); +#ifdef __MINGW32__ +static inline +void flockfile (FILE * filehandle) { + return; +} + +static inline +void funlockfile(FILE * filehandle) { + return; +} +#endif + /* * Generate a test result. * @@ -66,8 +82,8 @@ static void _cleanup(void); * test_comment -- a comment to print afterwards, may be NULL */ unsigned int -_gen_result(int ok, const char *func, char *file, unsigned int line, - char *test_name, ...) +_gen_result(int ok, const char *func, const char *file, unsigned int line, + const char *test_name, ...) { va_list ap; char *local_test_name = NULL; @@ -93,7 +109,7 @@ _gen_result(int ok, const char *func, char *file, unsigned int line, if(local_test_name) { name_is_digits = 1; for(c = local_test_name; *c != '\0'; c++) { - if(!isdigit(*c) && !isspace(*c)) { + if(!isdigit((unsigned char) *c) && !isspace((unsigned char) *c)) { name_is_digits = 0; break; } @@ -212,7 +228,7 @@ plan_no_plan(void) * Note that the plan is to skip all tests */ int -plan_skip_all(char *reason) +plan_skip_all(const char *reason) { LOCK; @@ -268,7 +284,7 @@ plan_tests(unsigned int tests) } unsigned int -diag(char *fmt, ...) +diag(const char *fmt, ...) { va_list ap; @@ -283,6 +299,28 @@ diag(char *fmt, ...) return 0; } +void +diag_multiline(const char *val) +{ + size_t len, i, line_start_idx = 0; + + assert(val); + len = strlen(val); + + for (i = 0; i < len; i++) { + int line_length; + + if (val[i] != '\n') { + continue; + } + + assert((i - line_start_idx + 1) <= INT_MAX); + line_length = i - line_start_idx + 1; + fprintf(stderr, "# %.*s", line_length, &val[line_start_idx]); + line_start_idx = i + 1; + } +} + void _expected_tests(unsigned int tests) { @@ -292,7 +330,7 @@ _expected_tests(unsigned int tests) } int -skip(unsigned int n, char *fmt, ...) +skip(unsigned int n, const char *fmt, ...) { va_list ap; char *skip_msg = NULL; @@ -320,7 +358,7 @@ skip(unsigned int n, char *fmt, ...) } void -todo_start(char *fmt, ...) +todo_start(const char *fmt, ...) { va_list ap;