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 /nptl/tst-cancel7.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 'nptl/tst-cancel7.c')
-rw-r--r-- | nptl/tst-cancel7.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/nptl/tst-cancel7.c b/nptl/tst-cancel7.c index 7f20862952..8eff3a8dac 100644 --- a/nptl/tst-cancel7.c +++ b/nptl/tst-cancel7.c @@ -24,6 +24,9 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <getopt.h> + +#include <support/xthread.h> const char *command; const char *pidfile; @@ -105,18 +108,8 @@ do_test (void) sleep (1); while (access (pidfilename, R_OK) != 0); - if (pthread_cancel (th) != 0) - { - puts ("pthread_cancel failed"); - return 1; - } - - void *r; - if (pthread_join (th, &r) != 0) - { - puts ("pthread_join failed"); - return 1; - } + xpthread_cancel (th); + void *r = xpthread_join (th); sleep (1); @@ -196,15 +189,20 @@ do_cleanup (void) #define CMDLINE_OPTIONS \ { "command", required_argument, NULL, OPT_COMMAND }, \ { "pidfile", required_argument, NULL, OPT_PIDFILE }, -#define CMDLINE_PROCESS \ - case OPT_COMMAND: \ - command = optarg; \ - break; \ - case OPT_PIDFILE: \ - pidfile = optarg; \ - break; -#define CLEANUP_HANDLER do_cleanup () -#define PREPARE(argc, argv) do_prepare (argc, argv) -#define TEST_FUNCTION do_test () +static void +cmdline_process (int c) +{ + switch (c) + { + command = optarg; + break; + case OPT_PIDFILE: + pidfile = optarg; + break; + } +} +#define CMDLINE_PROCESS cmdline_process +#define CLEANUP_HANDLER do_cleanup +#define PREPARE do_prepare #define TIMEOUT 5 -#include "../test-skeleton.c" +#include <support/test-driver.c> |