From 042ecb4231882ed0fbc7fe30133a6e294683ea60 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 25 Jan 2013 01:00:10 +0000 Subject: [PATCH] tests: print error locations verbosely So we don't have to figure out which line generated this error by searching for the subtest/error code combination. Change-Id: Icca0a776fd19f0f3d250ddb76916f5f932dd9b5e --- test/common.c | 11 ++++++----- test/test14.c | 1 - test/test22.c | 1 - test/test3.c | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/common.c b/test/common.c index 7807d79da..40b2fccc6 100644 --- a/test/common.c +++ b/test/common.c @@ -12,9 +12,11 @@ int common_test_nr = -1, errct = 0, subtest; +#define e(errn) e_f(__FILE__, __LINE__, (errn)) + void cleanup(void); int does_fs_truncate(void); -void e(int n); +void e_f(char *file, int lineno, int n); int name_max(char *path); void quit(void); void rm_rf_dir(int test_nr); @@ -98,14 +100,13 @@ int test_nr; if (system(buf) != 0) printf("Warning: system(\"%s\") failed\n", buf); } -void e(n) -int n; +void e_f(char *file, int line, int n) { int err_number; err_number = errno; /* Store before printf can clobber it */ if (errct == 0) printf("\n"); /* finish header */ - printf("Subtest %d, error %d, errno %d: %s\n", - subtest, n, errno, strerror(errno)); + printf("%s:%d: Subtest %d, error %d, errno %d: %s\n", + file, line, subtest, n, errno, strerror(errno)); if (++errct > MAX_ERROR) { printf("Too many errors; test aborted\n"); cleanup(); diff --git a/test/test14.c b/test/test14.c index 1765239af..479fdb250 100644 --- a/test/test14.c +++ b/test/test14.c @@ -16,7 +16,6 @@ int subtest = 1; #include "common.c" int main(void); -void e(int n); void quit(void); int main() diff --git a/test/test22.c b/test/test22.c index 3bdc0c8c2..bdefc73a4 100644 --- a/test/test22.c +++ b/test/test22.c @@ -21,7 +21,6 @@ void test22a(void); int mode(char *filename); int umode(char *filename); -void e(int number); void quit(void); int main(int argc, char *argv[]) diff --git a/test/test3.c b/test/test3.c index 84c83ec44..5490b3b9e 100644 --- a/test/test3.c +++ b/test/test3.c @@ -25,7 +25,6 @@ void test3a(void); void test3c(void); void test3d(void); void test3e(void); -void e(int n); int main(argc, argv) int argc;