1 /* vi: set sw=4 ts=4: */
3 * signal testing function for uClibc
5 * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
6 * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
7 * Written by Erik Andersen <andersen@uclibc.org>
9 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
24 /* -------------------------------------------------*/
25 /* This stuff is common to all the testing routines */
26 /* -------------------------------------------------*/
27 const char *it = "<UNSET>"; /* Routine name for message routines. */
30 void check(int thing, int number)
33 printf("%s: flunked test %d\n", it, number);
38 void equal(const char *a, const char *b, int number)
40 check(a != NULL && b != NULL && (strcmp(a, b) == 0), number);
44 /* -------------------------------------------------*/
45 /* Let the tests begin.... */
46 /* -------------------------------------------------*/
50 void set_global_int_to_one(int signum)
52 printf ("Received signal %d (%s).\n", signum, strsignal(signum));
57 void signal_test_1(void)
61 it = "global variable set from signal handler";
62 if (signal(SIGUSR1, set_global_int_to_one) == SIG_ERR) {
63 perror("signal(SIGUSR1) failed");
68 /* This should already have jumped to the signal handler */
69 check((global_int == 1), 1);
72 if (signal(SIGUSR1, SIG_IGN) == SIG_ERR) {
73 perror("signal(SIGUSR1) failed");
77 /* This should not go to the signal handler this time since we */
78 check((global_int == 0), 1);
89 status = EXIT_SUCCESS;
90 printf("No errors.\n");
92 status = EXIT_FAILURE;
93 printf("%lu errors.\n", (unsigned long)errors);