• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***
2   This file is part of PulseAudio.
3 
4   PulseAudio is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as published
6   by the Free Software Foundation; either version 2.1 of the License,
7   or (at your option) any later version.
8 
9   PulseAudio is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   General Public License for more details.
13 
14   You should have received a copy of the GNU Lesser General Public License
15   along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
16 ***/
17 
18 #ifdef HAVE_CONFIG_H
19 #include <config.h>
20 #endif
21 
22 #include <check.h>
23 
24 #include <signal.h>
25 #include <stdio.h>
26 
27 #include <pulsecore/macro.h>
28 #include <pulsecore/core-util.h>
29 
30 static const char *names[] = {
31     "SIG-1",
32     "SIG0",
33     "SIGHUP",
34     "SIGINT",
35     "SIGQUIT",
36     "SIGULL",
37     "SIGTRAP",
38     "SIGABRT",
39     "SIGBUS",
40     "SIGFPE",
41     "SIGKILL",
42     "SIGUSR1",
43     "SIGSEGV",
44     "SIGUSR2",
45     "SIGPIPE",
46     "SIGALRM",
47     "SIGTERM",
48     "SIGSTKFLT",
49     "SIGCHLD",
50     "SIGCONT",
51     "SIGSTOP",
52     "SIGTSTP",
53     "SIGTTIN",
54     "SIGTTOU",
55     "SIGURG",
56     "SIGXCPU",
57     "SIGXFSZ",
58     "SIGVTALRM",
59     "SIGPROF",
60     "SIGWINCH",
61     "SIGIO",
62     "SIGPWR",
63     "SIGSYS",
64     "SIG32",
65     "SIG33",
66     "SIGRTMIN+0",
67     "SIGRTMIN+1",
68     "SIGRTMIN+2",
69     "SIGRTMIN+3",
70     "SIGRTMIN+4",
71     "SIGRTMIN+5",
72     "SIGRTMIN+6",
73     "SIGRTMIN+7",
74     "SIGRTMIN+8",
75     "SIGRTMIN+9",
76     "SIGRTMIN+10",
77     "SIGRTMIN+11",
78     "SIGRTMIN+12",
79     "SIGRTMIN+13",
80     "SIGRTMIN+14",
81     "SIGRTMIN+15",
82     "SIGRTMIN+16",
83     "SIGRTMIN+17",
84     "SIGRTMIN+18",
85     "SIGRTMIN+19",
86     "SIGRTMIN+20",
87     "SIGRTMIN+21",
88     "SIGRTMIN+22",
89     "SIGRTMIN+23",
90     "SIGRTMIN+24",
91     "SIGRTMIN+25",
92     "SIGRTMIN+26",
93     "SIGRTMIN+27",
94     "SIGRTMIN+28",
95     "SIGRTMIN+29",
96     "SIGRTMIN+30",
97     "SIG65"
98 };
99 
START_TEST(sig2str_test)100 START_TEST (sig2str_test) {
101     int sig;
102 
103     for (sig = -1; sig <= NSIG; sig++) {
104         printf("%i = %s\n", sig, pa_sig2str(sig));
105         fail_unless(pa_streq(pa_sig2str(sig), names[sig+1]));
106     }
107 }
108 END_TEST
109 
main(int argc,char * argv[])110 int main(int argc, char *argv[]) {
111     int failed = 0;
112     Suite *s;
113     TCase *tc;
114     SRunner *sr;
115 
116     s = suite_create("Signal String");
117     tc = tcase_create("sig2str");
118     tcase_add_test(tc, sig2str_test);
119     suite_add_tcase(s, tc);
120 
121     sr = srunner_create(s);
122     srunner_run_all(sr, CK_NORMAL);
123     failed = srunner_ntests_failed(sr);
124     srunner_free(sr);
125 
126     return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
127 }
128