1 /* vi: set sw=4 ts=4: */
3 * signal testing function for uClibc
5 * Copyright (C) 2000 by Lineo, inc. Written by Erik Andersen
6 * <andersen@lineo.com>, <andersee@debian.org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Library General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
18 * You should have received a copy of the GNU Library General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 /* -------------------------------------------------*/
35 /* This stuff is common to all the testing routines */
36 /* -------------------------------------------------*/
37 const char *it = "<UNSET>"; /* Routine name for message routines. */
40 void check(int thing, int number)
43 printf("%s: flunked test %d\n", it, number);
48 void equal(const char *a, const char *b, int number)
50 check(a != NULL && b != NULL && (strcmp(a, b) == 0), number);
54 /* -------------------------------------------------*/
55 /* Let the tests begin.... */
56 /* -------------------------------------------------*/
60 void set_global_int_to_one(int signum)
62 printf ("Received signal %d (%s).\n", signum, strsignal(signum));
67 void signal_test_1(void)
71 it = "global variable set from signal handler";
72 signal(SIGUSR1, set_global_int_to_one);
75 /* This should already have jumped to the signal handler */
76 check((global_int == 1), 1);
79 signal(SIGUSR1, SIG_IGN);
81 /* This should not go to the signal handler this time since we */
82 check((global_int == 0), 1);
93 status = EXIT_SUCCESS;
94 printf("No errors.\n");
96 status = EXIT_FAILURE;
97 printf("%d errors.\n", errors);