diff options
author | Florian Weimer <fweimer@redhat.com> | 2016-12-31 12:20:49 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2016-12-31 18:51:15 +0100 |
commit | 039c5a05cc905e3d48392e7ea9f85e339b7c068b (patch) | |
tree | 2d69efafb74a99d94b13b98eaab09d9e1d0e505c /support | |
parent | 5707a64d9462001f9c7c2e02d3f52cf8b0181658 (diff) | |
download | glibc-039c5a05cc905e3d48392e7ea9f85e339b7c068b.tar glibc-039c5a05cc905e3d48392e7ea9f85e339b7c068b.tar.gz glibc-039c5a05cc905e3d48392e7ea9f85e339b7c068b.tar.bz2 glibc-039c5a05cc905e3d48392e7ea9f85e339b7c068b.zip |
support: Use support_record_failure consistently
This causes more test programs to link in the support_record_failure
function, which triggers an early call to mmap from an ELF
constructor, but this should not have side effects intefering
with the functionality actually under test (unlike, say, a call
to malloc).
Diffstat (limited to 'support')
-rw-r--r-- | support/check.c | 4 | ||||
-rw-r--r-- | support/check.h | 10 | ||||
-rw-r--r-- | support/delayed_exit.c | 6 | ||||
-rw-r--r-- | support/support_record_failure.c | 4 | ||||
-rw-r--r-- | support/support_test_verify_impl.c | 2 | ||||
-rw-r--r-- | support/tst-support_record_failure-2.sh | 6 | ||||
-rw-r--r-- | support/xasprintf.c | 6 | ||||
-rw-r--r-- | support/xfork.c | 6 | ||||
-rw-r--r-- | support/xpthread_check_return.c | 4 | ||||
-rw-r--r-- | support/xsocket.c | 6 | ||||
-rw-r--r-- | support/xwaitpid.c | 6 |
11 files changed, 28 insertions, 32 deletions
diff --git a/support/check.c b/support/check.c index 75fdf524b5..04d25037b0 100644 --- a/support/check.c +++ b/support/check.c @@ -21,6 +21,7 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <support/test-driver.h> static void print_failure (const char *file, int line, const char *format, va_list ap) @@ -34,6 +35,7 @@ int support_print_failure_impl (const char *file, int line, const char *format, ...) { + support_record_failure (); va_list ap; va_start (ap, format); print_failure (file, line, format, ap); @@ -45,6 +47,8 @@ void support_exit_failure_impl (int status, const char *file, int line, const char *format, ...) { + if (status != EXIT_SUCCESS && status != EXIT_UNSUPPORTED) + support_record_failure (); va_list ap; va_start (ap, format); print_failure (file, line, format, ap); diff --git a/support/check.h b/support/check.h index 92cb5d9934..129bff2dbe 100644 --- a/support/check.h +++ b/support/check.h @@ -23,15 +23,19 @@ __BEGIN_DECLS -/* Print failure message to standard output and return 1. */ +/* Record a test failure, print the failure message to standard output + and return 1. */ #define FAIL_RET(...) \ return support_print_failure_impl (__FILE__, __LINE__, __VA_ARGS__) -/* Print failure message and terminate the process with STATUS. */ +/* Print the failure message and terminate the process with STATUS. + Record a the process as failed if STATUS is neither EXIT_SUCCESS + nor EXIT_UNSUPPORTED. */ #define FAIL_EXIT(status, ...) \ support_exit_failure_impl (status, __FILE__, __LINE__, __VA_ARGS__) -/* Print failure message and terminate with exit status 1. */ +/* Record a test failure, print the failure message and terminate with + exit status 1. */ #define FAIL_EXIT1(...) \ support_exit_failure_impl (1, __FILE__, __LINE__, __VA_ARGS__) diff --git a/support/delayed_exit.c b/support/delayed_exit.c index d5b2e10927..1384f5cc34 100644 --- a/support/delayed_exit.c +++ b/support/delayed_exit.c @@ -22,6 +22,7 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <support/check.h> #include <time.h> static void * @@ -31,10 +32,7 @@ delayed_exit_thread (void *seconds_as_ptr) struct timespec delay = { seconds, 0 }; struct timespec remaining = { 0 }; if (nanosleep (&delay, &remaining) != 0) - { - printf ("error: nanosleep: %m\n"); - exit (1); - } + FAIL_EXIT1 ("nanosleep: %m"); /* Exit the process sucessfully. */ exit (0); return NULL; diff --git a/support/support_record_failure.c b/support/support_record_failure.c index 24b2d6e426..30de2f6f8d 100644 --- a/support/support_record_failure.c +++ b/support/support_record_failure.c @@ -36,8 +36,8 @@ propagate to the parent process. */ struct test_failures { - unsigned counter; - unsigned failed; + unsigned int counter; + unsigned int failed; }; static struct test_failures *state; diff --git a/support/support_test_verify_impl.c b/support/support_test_verify_impl.c index 28b152407a..3b74e578ba 100644 --- a/support/support_test_verify_impl.c +++ b/support/support_test_verify_impl.c @@ -26,7 +26,7 @@ support_test_verify_impl (int status, const char *file, int line, const char *expr) { support_record_failure (); - printf ("FAIL %s:%d: not true: %s\n", file, line, expr); + printf ("error: %s:%d: not true: %s\n", file, line, expr); if (status >= 0) exit (status); diff --git a/support/tst-support_record_failure-2.sh b/support/tst-support_record_failure-2.sh index 71af382c30..a96a60d310 100644 --- a/support/tst-support_record_failure-2.sh +++ b/support/tst-support_record_failure-2.sh @@ -52,15 +52,15 @@ different_status () { run_test 1 "error: 1 test failures" $direct --status=1 run_test 2 "error: 1 test failures" $direct --status=2 run_test 1 "error: 1 test failures" $direct --status=77 - run_test 2 "FAIL tst-support_record_failure.c:108: not true: false + run_test 2 "error: tst-support_record_failure.c:108: not true: false error: 1 test failures" $direct --test-verify } different_status different_status --direct -run_test 1 "FAIL tst-support_record_failure.c:113: not true: false +run_test 1 "error: tst-support_record_failure.c:113: not true: false error: 1 test failures" --test-verify-exit # --direct does not print the summary error message if exit is called. -run_test 1 "FAIL tst-support_record_failure.c:113: not true: false" \ +run_test 1 "error: tst-support_record_failure.c:113: not true: false" \ --direct --test-verify-exit diff --git a/support/xasprintf.c b/support/xasprintf.c index b9dc91ba4f..6aa1fe629e 100644 --- a/support/xasprintf.c +++ b/support/xasprintf.c @@ -21,6 +21,7 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <support/check.h> char * xasprintf (const char *format, ...) @@ -29,10 +30,7 @@ xasprintf (const char *format, ...) va_start (ap, format); char *result; if (vasprintf (&result, format, ap) < 0) - { - printf ("error: asprintf: %m\n"); - exit (1); - } + FAIL_EXIT1 ("asprintf: %m"); va_end (ap); return result; } diff --git a/support/xfork.c b/support/xfork.c index 4b2ce915e9..6a2d9ccbdc 100644 --- a/support/xfork.c +++ b/support/xfork.c @@ -20,15 +20,13 @@ #include <stdio.h> #include <stdlib.h> +#include <support/check.h> pid_t xfork (void) { pid_t result = fork (); if (result < 0) - { - printf ("error: fork: %m\n"); - exit (1); - } + FAIL_EXIT1 ("fork: %m"); return result; } diff --git a/support/xpthread_check_return.c b/support/xpthread_check_return.c index 8781ee11a1..398f945590 100644 --- a/support/xpthread_check_return.c +++ b/support/xpthread_check_return.c @@ -21,6 +21,7 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <support/check.h> void xpthread_check_return (const char *function, int value) @@ -28,7 +29,6 @@ xpthread_check_return (const char *function, int value) if (value != 0) { errno = value; - printf ("error: %s: %m\n", function); - exit (1); + FAIL_EXIT1 ("%s: %m", function); } } diff --git a/support/xsocket.c b/support/xsocket.c index 9ebe63fc73..268a825c1d 100644 --- a/support/xsocket.c +++ b/support/xsocket.c @@ -27,10 +27,6 @@ xsocket (int domain, int type, int protocol) { int fd = socket (domain, type, protocol); if (fd < 0) - { - support_record_failure (); - printf ("error: socket (%d, %d, %d): %m\n", domain, type, protocol); - exit (1); - } + FAIL_EXIT1 ("socket (%d, %d, %d): %m\n", domain, type, protocol); return fd; } diff --git a/support/xwaitpid.c b/support/xwaitpid.c index 5a6e540810..f577535fbf 100644 --- a/support/xwaitpid.c +++ b/support/xwaitpid.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> +#include <support/check.h> #include <sys/wait.h> int @@ -27,9 +28,6 @@ xwaitpid (int pid, int *status, int flags) { pid_t result = waitpid (pid, status, flags); if (result < 0) - { - printf ("error: waitpid: %m\n"); - exit (1); - } + FAIL_EXIT1 ("waitpid: %m\n"); return result; } |