diff options
author | Florian Weimer <fweimer@redhat.com> | 2016-12-09 08:18:27 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2016-12-09 08:18:27 +0100 |
commit | c23de0aacbeaa7a091609b35764bed931475a16d (patch) | |
tree | be4396f71292ee7a509912d70e74323d1587d227 /malloc/tst-malloc-fork-deadlock.c | |
parent | c03073774f915fe7841c2b551fe304544143470f (diff) | |
download | glibc-c23de0aacbeaa7a091609b35764bed931475a16d.tar.gz glibc-c23de0aacbeaa7a091609b35764bed931475a16d.tar.xz glibc-c23de0aacbeaa7a091609b35764bed931475a16d.zip |
support: Introduce new subdirectory for test infrastructure
The new test driver in <support/test-driver.c> has feature parity with the old one. The main difference is that its hooking mechanism is based on functions and function pointers instead of macros. This commit also implements a new environment variable, TEST_COREDUMPS, which disables the code which disables coredumps (that is, it enables them if the invocation environment has not disabled them). <test-skeleton.c> defines wrapper functions so that it is possible to use existing macros with the new-style hook functionality. This commit changes only a few test cases to the new test driver, to make sure that it works as expected.
Diffstat (limited to 'malloc/tst-malloc-fork-deadlock.c')
-rw-r--r-- | malloc/tst-malloc-fork-deadlock.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/malloc/tst-malloc-fork-deadlock.c b/malloc/tst-malloc-fork-deadlock.c index 94549ca459..cdef2257d2 100644 --- a/malloc/tst-malloc-fork-deadlock.c +++ b/malloc/tst-malloc-fork-deadlock.c @@ -28,9 +28,9 @@ #include <string.h> #include <signal.h> -static int do_test (void); -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include <support/xthread.h> +#include <support/temp_file.h> +#include <support/test-driver.h> enum { /* Number of threads which call fork. */ @@ -117,30 +117,14 @@ static void create_threads (pthread_t *threads, size_t count, void *(*func) (void *)) { for (size_t i = 0; i < count; ++i) - { - int ret = pthread_create (threads + i, NULL, func, NULL); - if (ret != 0) - { - errno = ret; - printf ("error: pthread_create: %m\n"); - abort (); - } - } + threads[i] = xpthread_create (NULL, func, NULL); } static void join_threads (pthread_t *threads, size_t count) { for (size_t i = 0; i < count; ++i) - { - int ret = pthread_join (threads[i], NULL); - if (ret != 0) - { - errno = ret; - printf ("error: pthread_join: %m\n"); - abort (); - } - } + xpthread_join (threads[i]); } /* Create a file which consists of a single long line, and assigns @@ -189,8 +173,8 @@ do_test (void) /* Leave some room for shutting down all threads gracefully. */ int timeout = 3; - if (timeout > TIMEOUT) - timeout = TIMEOUT - 1; + if (timeout > DEFAULT_TIMEOUT) + timeout = DEFAULT_TIMEOUT - 1; create_file_with_large_line (); @@ -218,3 +202,5 @@ do_test (void) return 0; } + +#include <support/test-driver.c> |