1 /* vi: set sw=4 ts=4: */
3 * signal testing function for uClibc
4 * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
21 /* -------------------------------------------------*/
22 /* This stuff is common to all the testing routines */
23 /* -------------------------------------------------*/
24 const char *it = "<UNSET>"; /* Routine name for message routines. */
27 static void check(int thing, int number)
30 printf("%s: flunked test %d\n", it, number);
36 static void equal(const char *a, const char *b, int number)
38 check(a != NULL && b != NULL && (strcmp(a, b) == 0), number);
43 /* -------------------------------------------------*/
44 /* Let the tests begin.... */
45 /* -------------------------------------------------*/
49 static void set_global_int_to_one(int signum)
51 printf ("Received signal %d (%s).\n", signum, strsignal(signum));
56 static void signal_test_1(void)
60 it = "global variable set from signal handler";
61 if (signal(SIGUSR1, set_global_int_to_one) == SIG_ERR) {
62 perror("signal(SIGUSR1) failed");
67 /* This should already have jumped to the signal handler */
68 check((global_int == 1), 1);
71 if (signal(SIGUSR1, SIG_IGN) == SIG_ERR) {
72 perror("signal(SIGUSR1) failed");
76 /* This should not go to the signal handler this time since we */
77 check((global_int == 0), 1);
88 status = EXIT_SUCCESS;
89 printf("No errors.\n");
91 status = EXIT_FAILURE;
92 printf("%lu errors.\n", (unsigned long)errors);