diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2019-05-13 19:53:15 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2019-05-13 19:53:15 +0200 |
commit | 7500a8166f9d5f2df595e4bef2240d0a93526507 (patch) | |
tree | 169192ad502aa21758d402d9cb9b427dd643fab9 | |
parent | c5ab62a6d0940e89ae11b4611edbaea445dfe464 (diff) | |
download | mtest-7500a8166f9d5f2df595e4bef2240d0a93526507.tar.gz mtest-7500a8166f9d5f2df595e4bef2240d0a93526507.tar.bz2 mtest-7500a8166f9d5f2df595e4bef2240d0a93526507.zip |
mtest.h: add more verbose assert messages
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r-- | mtest.h | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -185,12 +185,22 @@ /* ========================================================================== - shortcut macro to test if function exits with success (with return value - set to 0) + Checks if function exits with success (return value == 0). ========================================================================== */ -#define mt_fok(e) mt_fail(e == 0) +#define mt_fok(e) do { \ + ++mt_total_checks; \ + int ret; \ + 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) /* ========================================================================== @@ -203,7 +213,12 @@ errno = 0; \ mt_fail(e == -1); \ mt_fail(errno == errn); \ - } while (0) + if (errno != errn) \ + { \ + fprintf(stderr, "# assert [%s:%d] %s, got errno: %d\n", \ + __FILE__, __LINE__, curr_test, errno); \ + } } while (0) + /* ========================================================================== prints test plan, in format 1..<number_of_test_run>. If all tests have |