| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_sigaction.c,v 1.1 2011/10/15 07:00:48 jruoho Exp $ */ | | 1 | /* $NetBSD: t_sigaction.c,v 1.2 2012/11/07 16:51:16 pgoyette Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -19,27 +19,27 @@ | | | @@ -19,27 +19,27 @@ |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __COPYRIGHT("@(#) Copyright (c) 2010\ | | 30 | __COPYRIGHT("@(#) Copyright (c) 2010\ |
31 | The NetBSD Foundation, inc. All rights reserved."); | | 31 | The NetBSD Foundation, inc. All rights reserved."); |
32 | __RCSID("$NetBSD: t_sigaction.c,v 1.1 2011/10/15 07:00:48 jruoho Exp $"); | | 32 | __RCSID("$NetBSD: t_sigaction.c,v 1.2 2012/11/07 16:51:16 pgoyette Exp $"); |
33 | | | 33 | |
34 | #include <sys/wait.h> | | 34 | #include <sys/wait.h> |
35 | | | 35 | |
36 | #include <signal.h> | | 36 | #include <signal.h> |
37 | #include <stdbool.h> | | 37 | #include <stdbool.h> |
38 | #include <stdlib.h> | | 38 | #include <stdlib.h> |
39 | #include <string.h> | | 39 | #include <string.h> |
40 | #include <unistd.h> | | 40 | #include <unistd.h> |
41 | | | 41 | |
42 | #include <atf-c.h> | | 42 | #include <atf-c.h> |
43 | #include <atf-c/config.h> | | 43 | #include <atf-c/config.h> |
44 | | | 44 | |
45 | #include "../../../h_macros.h" | | 45 | #include "../../../h_macros.h" |
| @@ -69,26 +69,51 @@ sa_resethand_child(const int flags) | | | @@ -69,26 +69,51 @@ sa_resethand_child(const int flags) |
69 | static void | | 69 | static void |
70 | wait_and_check_child(const pid_t pid, const char *fail_message) | | 70 | wait_and_check_child(const pid_t pid, const char *fail_message) |
71 | { | | 71 | { |
72 | int status; | | 72 | int status; |
73 | | | 73 | |
74 | (void)waitpid(pid, &status, 0); | | 74 | (void)waitpid(pid, &status, 0); |
75 | | | 75 | |
76 | if (WIFEXITED(status)) | | 76 | if (WIFEXITED(status)) |
77 | ATF_CHECK_EQ(EXIT_SUCCESS, WEXITSTATUS(status)); | | 77 | ATF_CHECK_EQ(EXIT_SUCCESS, WEXITSTATUS(status)); |
78 | else | | 78 | else |
79 | atf_tc_fail("%s; raw exit status was %d", fail_message, status); | | 79 | atf_tc_fail("%s; raw exit status was %d", fail_message, status); |
80 | } | | 80 | } |
81 | | | 81 | |
| | | 82 | static void |
| | | 83 | catch(int sig) |
| | | 84 | { |
| | | 85 | return; |
| | | 86 | } |
| | | 87 | |
| | | 88 | ATF_TC(sigaction_basic); |
| | | 89 | ATF_TC_HEAD(sigaction_basic, tc) |
| | | 90 | { |
| | | 91 | |
| | | 92 | atf_tc_set_md_var(tc, "descr", "Checks for correct I&D cache" |
| | | 93 | "synchronization after copying out the trampoline code."); |
| | | 94 | } |
| | | 95 | |
| | | 96 | ATF_TC_BODY(sigaction_basic, tc) |
| | | 97 | { |
| | | 98 | static struct sigaction sa; |
| | | 99 | |
| | | 100 | sa.sa_handler = catch; |
| | | 101 | |
| | | 102 | sigaction(SIGUSR1, &sa, 0); |
| | | 103 | kill(getpid(), SIGUSR1); |
| | | 104 | atf_tc_pass(); |
| | | 105 | } |
| | | 106 | |
82 | ATF_TC(sigaction_noflags); | | 107 | ATF_TC(sigaction_noflags); |
83 | ATF_TC_HEAD(sigaction_noflags, tc) | | 108 | ATF_TC_HEAD(sigaction_noflags, tc) |
84 | { | | 109 | { |
85 | atf_tc_set_md_var(tc, "descr", "Checks programming a signal with " | | 110 | atf_tc_set_md_var(tc, "descr", "Checks programming a signal with " |
86 | "sigaction(2) but without any flags"); | | 111 | "sigaction(2) but without any flags"); |
87 | } | | 112 | } |
88 | | | 113 | |
89 | ATF_TC_BODY(sigaction_noflags, tc) | | 114 | ATF_TC_BODY(sigaction_noflags, tc) |
90 | { | | 115 | { |
91 | const pid_t pid = fork(); | | 116 | const pid_t pid = fork(); |
92 | if (pid == -1) | | 117 | if (pid == -1) |
93 | atf_tc_fail_errno("fork(2) failed"); | | 118 | atf_tc_fail_errno("fork(2) failed"); |
94 | else if (pid == 0) | | 119 | else if (pid == 0) |
| @@ -111,18 +136,19 @@ ATF_TC_BODY(sigaction_resethand, tc) | | | @@ -111,18 +136,19 @@ ATF_TC_BODY(sigaction_resethand, tc) |
111 | atf_tc_fail_errno("fork(2) failed"); | | 136 | atf_tc_fail_errno("fork(2) failed"); |
112 | else if (pid == 0) | | 137 | else if (pid == 0) |
113 | sa_resethand_child(SA_RESETHAND); | | 138 | sa_resethand_child(SA_RESETHAND); |
114 | else { | | 139 | else { |
115 | wait_and_check_child(pid, "Child process did not exit cleanly;" | | 140 | wait_and_check_child(pid, "Child process did not exit cleanly;" |
116 | " it either failed to process the signal or SA_RESETHAND" | | 141 | " it either failed to process the signal or SA_RESETHAND" |
117 | " is broken"); | | 142 | " is broken"); |
118 | } | | 143 | } |
119 | } | | 144 | } |
120 | | | 145 | |
121 | ATF_TP_ADD_TCS(tp) | | 146 | ATF_TP_ADD_TCS(tp) |
122 | { | | 147 | { |
123 | | | 148 | |
| | | 149 | ATF_TP_ADD_TC(tp, sigaction_basic); |
124 | ATF_TP_ADD_TC(tp, sigaction_noflags); | | 150 | ATF_TP_ADD_TC(tp, sigaction_noflags); |
125 | ATF_TP_ADD_TC(tp, sigaction_resethand); | | 151 | ATF_TP_ADD_TC(tp, sigaction_resethand); |
126 | | | 152 | |
127 | return atf_no_error(); | | 153 | return atf_no_error(); |
128 | } | | 154 | } |