aboutsummaryrefslogtreecommitdiff
path: root/tests/testutils.c
diff options
context:
space:
mode:
authorDavid Gibson <dgibson@sneetch.ozlabs.ibm.com>2006-03-02 16:38:43 +1100
committerDavid Gibson <dgibson@sneetch.ozlabs.ibm.com>2006-03-02 16:38:43 +1100
commita510a867d7bfaf39a368d25d05a1ec52b27e8921 (patch)
tree969364d892c9f10aba1a6b1e7d5a3b68972889c2 /tests/testutils.c
parent86076c41364d7da6726ef8eaac22d9a9272a312d (diff)
downloadlibhugetlbfs-a510a867d7bfaf39a368d25d05a1ec52b27e8921.tar.gz
cleanup() after Ctrl-C
Add a default SIGINT handler in all the testcases which will call the cleanup() function. In particular this means the shm tests won't leave around a shm segment if Ctrl-Ced. Also remove error checking from the cleanup() functions - it could just lead to dangerous recursion (TEST_BUG() tries to call cleanup()).
Diffstat (limited to 'tests/testutils.c')
-rw-r--r--tests/testutils.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/testutils.c b/tests/testutils.c
index 2312b97..1af1726 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -18,12 +18,14 @@
*/
#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#include <signal.h>
#include <sys/vfs.h>
#include <sys/ipc.h>
@@ -47,21 +49,25 @@ static void segv_handler(int signum, siginfo_t *si, void *uc)
}
#endif
+static void sigint_handler(int signum, siginfo_t *si, void *uc)
+{
+ cleanup();
+ fprintf(stderr, "%s (pid=%d)\n", strsignal(signum), getpid());
+ exit(RC_BUG);
+}
+
void test_init(int argc, char *argv[])
{
-#if 0
int err;
- struct sigaction sa = {
- .sa_sigaction = segv_handler,
- .sa_flags = SA_SIGINFO,
+ struct sigaction sa_int = {
+ .sa_sigaction = sigint_handler,
};
test_name = argv[0];
- err = sigaction(SIGSEGV, &sa, NULL);
+ err = sigaction(SIGINT, &sa_int, NULL);
if (err)
- FAIL("Can't install SEGV handler");
-#endif
+ FAIL("Can't install SIGINT handler");
if (getenv("QUIET_TEST"))
verbose_test = 0;