diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2020-10-22 21:20:25 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2020-10-22 21:20:25 +0200 |
commit | 51e341a39dc371585ecdff3b86116e0b7929a1e7 (patch) | |
tree | b6e63a5267c2efb40e033249b5abacf27e2af6b4 | |
parent | 97483e904d46d6d54cb832696f5ad0a81aa3b7b0 (diff) | |
download | embedlog-51e341a39dc371585ecdff3b86116e0b7929a1e7.tar.gz embedlog-51e341a39dc371585ecdff3b86116e0b7929a1e7.tar.bz2 embedlog-51e341a39dc371585ecdff3b86116e0b7929a1e7.zip |
tst/mtest.h: update mtest to v1.3.1
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r-- | tst/mtest.h | 232 |
1 files changed, 109 insertions, 123 deletions
diff --git a/tst/mtest.h b/tst/mtest.h index db8c4de..a5b0f38 100644 --- a/tst/mtest.h +++ b/tst/mtest.h @@ -2,24 +2,22 @@ Licensed under BSD 2clause license. See LICENSE file for more information Author: Michał Łyszczek <michal.lyszczek@bofc.pl> ========================================================================== - __________________________________________________________ - / mtest version v1.1.4 \ - | | - | Simple test framework that uses TAP output format | - \ http://testanything.org / - ---------------------------------------------------------- - \ ,-^-. - \ !oYo! - \ /./=\.\______ - ## )\/\ - ||-----w|| - || || - - Cowth Vader - ========================================================================== */ - - -/* ========================================================================== + __________________________________________________________ + / mtest v1.3.1 \ + | https://mtest.bofc.pl | + | | + | Simple test framework that uses TAP output format | + \ http://testanything.org / + ---------------------------------------------------------- + \ ,-^-. + \ !oYo! + \ /./=\.\______ + ## )\/\ + ||-----w|| + || || + + Cowth Vader + ========================================================================== _ __ __ ____ _ __ (_)____ _____ / /__ __ ____/ /___ / __/(_)/ /___ _____ / // __ \ / ___// // / / // __ // _ \ / /_ / // // _ \ / ___/ @@ -33,18 +31,10 @@ /* ========================================================================== - __ __ _ - ____ __ __ / /_ / /(_)_____ - / __ \ / / / // __ \ / // // ___/ - / /_/ // /_/ // /_/ // // // /__ - / .___/ \__,_//_.___//_//_/ \___/ - /_/ - ____ ___ ____ _ _____ _____ ____ _____ / __ `__ \ / __ `// ___// ___// __ \ / ___/ / / / / / // /_/ // /__ / / / /_/ /(__ ) /_/ /_/ /_/ \__,_/ \___//_/ \____//____/ - ========================================================================== */ @@ -54,15 +44,15 @@ ========================================================================== */ -#define mt_defs() \ - const char *curr_test; \ - int mt_test_status; \ - int mt_total_tests = 0; \ - int mt_total_failed = 0; \ - int mt_total_checks = 0; \ - int mt_checks_failed = 0; \ - static void (*mt_prepare_test)(void); \ - static void (*mt_cleanup_test)(void) +#define mt_defs() \ + const char *curr_test; \ + int mt_test_status; \ + int mt_total_tests = 0; \ + int mt_total_failed = 0; \ + int mt_total_checks = 0; \ + int mt_checks_failed = 0; \ + static void (*mt_prepare_test)(void); \ + static void (*mt_cleanup_test)(void) /* ========================================================================== @@ -72,15 +62,15 @@ ========================================================================== */ -#define mt_defs_ext() \ - extern const char *curr_test; \ - extern int mt_test_status; \ - extern int mt_total_tests; \ - extern int mt_total_failed; \ - extern int mt_total_checks; \ - extern int mt_checks_failed; \ - static void (*mt_prepare_test)(void); \ - static void (*mt_cleanup_test)(void) +#define mt_defs_ext()\ + extern const char *curr_test; \ + extern int mt_test_status; \ + extern int mt_total_tests; \ + extern int mt_total_failed; \ + extern int mt_total_checks; \ + extern int mt_checks_failed; \ + static void (*mt_prepare_test)(void); \ + static void (*mt_cleanup_test)(void) /* ========================================================================== @@ -107,21 +97,19 @@ ========================================================================== */ -#define mt_run_named(f, n) do { \ - curr_test = n; \ - mt_test_status = 0; \ - ++mt_total_tests; \ - if (mt_prepare_test) mt_prepare_test(); \ - f(); \ - if (mt_cleanup_test) mt_cleanup_test(); \ - if (mt_test_status != 0) \ - { \ - fprintf(stdout, "not ok %d - %s\n", mt_total_tests, curr_test); \ - ++mt_total_failed; \ - } \ - else \ - fprintf(stdout, "ok %d - %s\n", mt_total_tests, curr_test); \ - } while(0) +#define mt_run_named(f, n) do { \ + curr_test = n; \ + mt_test_status = 0; \ + ++mt_total_tests; \ + if (mt_prepare_test) mt_prepare_test(); \ + f(); \ + if (mt_cleanup_test) mt_cleanup_test(); \ + if (mt_test_status != 0) { \ + fprintf(stdout, "not ok %d - %s\n", mt_total_tests, curr_test); \ + ++mt_total_failed; \ + } else \ + fprintf(stdout, "ok %d - %s\n", mt_total_tests, curr_test); \ +} while(0) /* ========================================================================== @@ -132,21 +120,19 @@ ========================================================================== */ -#define mt_run_param_named(f, p, n) do { \ - curr_test = n; \ - mt_test_status = 0; \ - ++mt_total_tests; \ - if (mt_prepare_test) mt_prepare_test(); \ - f(p); \ - if (mt_cleanup_test) mt_cleanup_test(); \ - if (mt_test_status != 0) \ - { \ - fprintf(stdout, "not ok %d - %s\n", mt_total_tests, curr_test); \ - ++mt_total_failed; \ - } \ - else \ - fprintf(stdout, "ok %d - %s\n", mt_total_tests, curr_test); \ - } while(0) +#define mt_run_param_named(f, p, n) do { \ + curr_test = n; \ + mt_test_status = 0; \ + ++mt_total_tests; \ + if (mt_prepare_test) mt_prepare_test(); \ + f(p); \ + if (mt_cleanup_test) mt_cleanup_test(); \ + if (mt_test_status != 0) { \ + fprintf(stdout, "not ok %d - %s\n", mt_total_tests, curr_test); \ + ++mt_total_failed; \ + } else \ + fprintf(stdout, "ok %d - %s\n", mt_total_tests, curr_test); \ +} while(0) /* ========================================================================== @@ -155,16 +141,16 @@ ========================================================================== */ -#define mt_assert(e) do { \ - ++mt_total_checks; \ - if (!(e)) \ - { \ - fprintf(stderr, "# assert [%s:%d] %s, %s\n", \ - __FILE__, __LINE__, curr_test, #e); \ - mt_test_status = -1; \ - ++mt_checks_failed; \ - return; \ - } } while (0) +#define mt_assert(e) do { \ + ++mt_total_checks; \ + if (!(e)) { \ + fprintf(stderr, "# assert [%s:%d] %s, %s\n", \ + __FILE__, __LINE__, curr_test, #e); \ + mt_test_status = -1; \ + ++mt_checks_failed; \ + return; \ + } \ +} while (0) /* ========================================================================== @@ -173,15 +159,15 @@ ========================================================================== */ -#define mt_fail(e) do { \ - ++mt_total_checks; \ - if (!(e)) \ - { \ - fprintf(stderr, "# assert [%s:%d] %s, %s\n", \ - __FILE__, __LINE__, curr_test, #e); \ - mt_test_status = -1; \ - ++mt_checks_failed; \ - } } while (0) +#define mt_fail(e) do { \ + ++mt_total_checks; \ + if (!(e)) { \ + fprintf(stderr, "# assert [%s:%d] %s, %s\n", \ + __FILE__, __LINE__, curr_test, #e); \ + mt_test_status = -1; \ + ++mt_checks_failed; \ + } \ +} while (0) /* ========================================================================== @@ -189,18 +175,18 @@ ========================================================================== */ -#define mt_fok(e) do { \ - int ret; \ - ++mt_total_checks; \ - if ((ret = e) != 0) \ - { \ - fprintf(stderr, "# assert [%s:%d] %s, %s != ok\n", \ - __FILE__, __LINE__, curr_test, #e); \ - fprintf(stderr, "# assert [%s:%d] %s, return: %d, errno: %d\n", \ - __FILE__, __LINE__, curr_test, ret, errno); \ - mt_test_status = -1; \ - ++mt_checks_failed; \ - } } while (0) +#define mt_fok(e) do { \ + int ret; \ + ++mt_total_checks; \ + if ((ret = e) != 0) { \ + fprintf(stderr, "# assert [%s:%d] %s, %s != ok\n", \ + __FILE__, __LINE__, curr_test, #e); \ + fprintf(stderr, "# assert [%s:%d] %s, return: %d, errno: %d\n", \ + __FILE__, __LINE__, curr_test, ret, errno); \ + mt_test_status = -1; \ + ++mt_checks_failed; \ + } \ +} while (0) /* ========================================================================== @@ -209,15 +195,14 @@ ========================================================================== */ -#define mt_ferr(e, errn) do { \ - errno = 0; \ - mt_fail(e == -1); \ - mt_fail(errno == errn); \ - if (errno != errn) \ - { \ - fprintf(stderr, "# assert [%s:%d] %s, got errno: %d\n", \ - __FILE__, __LINE__, curr_test, errno); \ - } } while (0) +#define mt_ferr(e, errn) do { \ + errno = 0; \ + mt_fail(e == -1); \ + mt_fail(errno == errn); \ + if (errno != errn) \ + fprintf(stderr, "# assert [%s:%d] %s, got errno: %d\n", \ + __FILE__, __LINE__, curr_test, errno); \ +} while (0) /* ========================================================================== @@ -228,12 +213,13 @@ ========================================================================== */ -#define mt_return() do { \ - fprintf(stdout, "1..%d\n", mt_total_tests); \ - fprintf(stderr, "# total tests.......:%4d\n", mt_total_tests); \ - fprintf(stderr, "# passed tests......:%4d\n", mt_total_tests - mt_total_failed); \ - fprintf(stderr, "# failed tests......:%4d\n", mt_total_failed); \ - fprintf(stderr, "# total checks......:%4d\n", mt_total_checks); \ - fprintf(stderr, "# passed checks.....:%4d\n", mt_total_checks - mt_checks_failed); \ - fprintf(stderr, "# failed checks.....:%4d\n", mt_checks_failed); \ - return mt_total_failed > 254 ? 254 : mt_total_failed; } while(0) +#define mt_return() do { \ + fprintf(stdout, "1..%d\n", mt_total_tests); \ + fprintf(stderr, "# total tests.......:%4d\n", mt_total_tests); \ + fprintf(stderr, "# passed tests......:%4d\n", mt_total_tests - mt_total_failed); \ + fprintf(stderr, "# failed tests......:%4d\n", mt_total_failed); \ + fprintf(stderr, "# total checks......:%4d\n", mt_total_checks); \ + fprintf(stderr, "# passed checks.....:%4d\n", mt_total_checks - mt_checks_failed); \ + fprintf(stderr, "# failed checks.....:%4d\n", mt_checks_failed); \ + return mt_total_failed > 254 ? 254 : mt_total_failed; \ +} while(0) |