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
This commit is contained in:
Ben Gras 2013-01-25 01:00:10 +00:00
parent 8ebdbed79c
commit 042ecb4231
4 changed files with 6 additions and 8 deletions

View file

@ -12,9 +12,11 @@
int common_test_nr = -1, errct = 0, subtest; int common_test_nr = -1, errct = 0, subtest;
#define e(errn) e_f(__FILE__, __LINE__, (errn))
void cleanup(void); void cleanup(void);
int does_fs_truncate(void); int does_fs_truncate(void);
void e(int n); void e_f(char *file, int lineno, int n);
int name_max(char *path); int name_max(char *path);
void quit(void); void quit(void);
void rm_rf_dir(int test_nr); 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); if (system(buf) != 0) printf("Warning: system(\"%s\") failed\n", buf);
} }
void e(n) void e_f(char *file, int line, int n)
int n;
{ {
int err_number; int err_number;
err_number = errno; /* Store before printf can clobber it */ err_number = errno; /* Store before printf can clobber it */
if (errct == 0) printf("\n"); /* finish header */ if (errct == 0) printf("\n"); /* finish header */
printf("Subtest %d, error %d, errno %d: %s\n", printf("%s:%d: Subtest %d, error %d, errno %d: %s\n",
subtest, n, errno, strerror(errno)); file, line, subtest, n, errno, strerror(errno));
if (++errct > MAX_ERROR) { if (++errct > MAX_ERROR) {
printf("Too many errors; test aborted\n"); printf("Too many errors; test aborted\n");
cleanup(); cleanup();

View file

@ -16,7 +16,6 @@ int subtest = 1;
#include "common.c" #include "common.c"
int main(void); int main(void);
void e(int n);
void quit(void); void quit(void);
int main() int main()

View file

@ -21,7 +21,6 @@
void test22a(void); void test22a(void);
int mode(char *filename); int mode(char *filename);
int umode(char *filename); int umode(char *filename);
void e(int number);
void quit(void); void quit(void);
int main(int argc, char *argv[]) int main(int argc, char *argv[])

View file

@ -25,7 +25,6 @@ void test3a(void);
void test3c(void); void test3c(void);
void test3d(void); void test3d(void);
void test3e(void); void test3e(void);
void e(int n);
int main(argc, argv) int main(argc, argv)
int argc; int argc;