Skip to content

Commit 87062af

Browse files
committed
tests: posix: headers: add checks for posix signals option group
Add tests for the presence of items in the POSIX SIGNALS Option Group. Signed-off-by: Chris Friedt <[email protected]>
1 parent 1593954 commit 87062af

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

tests/posix/headers/src/signal_h.c

+38-27
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "_common.h"
88

9+
#include <stdlib.h>
10+
911
#ifdef CONFIG_POSIX_API
1012
#include <signal.h>
1113
#else
@@ -19,13 +21,17 @@
1921
*/
2022
ZTEST(posix_headers, test_signal_h)
2123
{
22-
/* zassert_not_equal(-1, SIG_DFL); */ /* not implemented */
23-
/* zassert_not_equal(-1, SIG_ERR); */ /* not implemented */
24+
typedef void *(*my_sig_handler_t)(int signo);
25+
26+
my_sig_handler_t handler;
27+
28+
handler = SIG_DFL;
29+
handler = SIG_ERR;
30+
handler = SIG_IGN;
2431
/* zassert_not_equal(-1, SIG_HOLD); */ /* not implemented */
25-
/* zassert_not_equal(-1, SIG_IGN); */ /* not implemented */
2632

2733
zassert_not_equal((sig_atomic_t)-1, (sig_atomic_t)0);
28-
/* zassert_not_equal((pid_t)-1, (pid_t)0); */ /* not implemented */
34+
zassert_not_equal((pid_t)-1, (pid_t)0);
2935

3036
zassert_not_equal(-1, offsetof(struct sigevent, sigev_notify));
3137
zassert_not_equal(-1, offsetof(struct sigevent, sigev_signo));
@@ -47,6 +53,15 @@ ZTEST(posix_headers, test_signal_h)
4753
zassert_not_equal(-1, SIG_UNBLOCK);
4854
zassert_not_equal(-1, SIG_SETMASK);
4955

56+
zassert_not_equal(-1, offsetof(struct sigaction, sa_handler));
57+
zassert_not_equal(-1, offsetof(struct sigaction, sa_mask));
58+
zassert_not_equal(-1, offsetof(struct sigaction, sa_flags));
59+
zassert_not_equal(-1, offsetof(struct sigaction, sa_sigaction));
60+
61+
zassert_not_equal(-1, offsetof(siginfo_t, si_signo));
62+
zassert_not_equal(-1, offsetof(siginfo_t, si_code));
63+
zassert_not_equal(-1, offsetof(siginfo_t, si_value));
64+
5065
/* zassert_not_equal(-1, SA_NOCLDSTOP); */ /* not implemented */
5166
/* zassert_not_equal(-1, SA_ONSTACK); */ /* not implemented */
5267
/* zassert_not_equal(-1, SA_RESETHAND); */ /* not implemented */
@@ -117,18 +132,11 @@ ZTEST(posix_headers, test_signal_h)
117132
/* zassert_not_equal(-1, CLD_STOPPED); */ /* not implemented */
118133
/* zassert_not_equal(-1, CLD_CONTINUED); */ /* not implemented */
119134

120-
/* zassert_not_equal(-1, POLL_IN); */ /* not implemented */
121-
/* zassert_not_equal(-1, POLL_OUT); */ /* not implemented */
122-
/* zassert_not_equal(-1, POLL_MSG); */ /* not implemented */
123-
/* zassert_not_equal(-1, POLL_ERR); */ /* not implemented */
124-
/* zassert_not_equal(-1, POLL_PRI); */ /* not implemented */
125-
/* zassert_not_equal(-1, POLL_HUP); */ /* not implemented */
126-
127-
/* zassert_not_equal(-1, SI_USER); */ /* not implemented */
128-
/* zassert_not_equal(-1, SI_QUEUE); */ /* not implemented */
129-
/* zassert_not_equal(-1, SI_TIMER); */ /* not implemented */
130-
/* zassert_not_equal(-1, SI_ASYNCIO); */ /* not implemented */
131-
/* zassert_not_equal(-1, SI_MESGQ); */ /* not implemented */
135+
zassert_not_equal(-1, SI_USER);
136+
zassert_not_equal(-1, SI_QUEUE);
137+
zassert_not_equal(-1, SI_TIMER);
138+
zassert_not_equal(-1, SI_ASYNCIO);
139+
zassert_not_equal(-1, SI_MESGQ);
132140

133141
#ifdef CONFIG_POSIX_SIGNALS
134142
zassert_true(SIGRTMIN >= 0);
@@ -158,37 +166,40 @@ ZTEST(posix_headers, test_signal_h)
158166
zassert_not_equal(-1, SIGXCPU);
159167
zassert_not_equal(-1, SIGXFSZ);
160168
zassert_not_equal(((sigset_t){.sig[0] = 0}).sig[0], ((sigset_t){.sig[0] = -1}).sig[0]);
161-
zassert_not_null(sigemptyset);
162-
zassert_not_null(sigfillset);
169+
zassert_not_null(abort);
170+
zassert_not_null(alarm);
171+
zassert_not_null(kill);
172+
zassert_not_null(pause);
173+
zassert_not_null(pthread_sigmask);
174+
zassert_not_null(raise);
175+
zassert_not_null(sigaction);
163176
zassert_not_null(sigaddset);
164177
zassert_not_null(sigdelset);
178+
zassert_not_null(sigemptyset);
179+
zassert_not_null(sigfillset);
165180
zassert_not_null(sigismember);
166-
zassert_not_null(strsignal);
181+
zassert_not_null(signal);
182+
zassert_not_null(sigpending);
167183
zassert_not_null(sigprocmask);
168-
zassert_not_null(pthread_sigmask);
184+
zassert_not_null(sigsuspend);
185+
zassert_not_null(sigwait);
186+
zassert_not_null(strsignal);
169187
#endif /* CONFIG_POSIX_SIGNALS */
170188

171189
if (IS_ENABLED(CONFIG_POSIX_API)) {
172-
/* zassert_not_null(kill); */ /* not implemented */
173190
/* zassert_not_null(killpg); */ /* not implemented */
174191
/* zassert_not_null(psiginfo); */ /* not implemented */
175192
/* zassert_not_null(psignal); */ /* not implemented */
176193
/* zassert_not_null(pthread_kill); */ /* not implemented */
177-
/* zassert_not_null(raise); */ /* not implemented */
178-
/* zassert_not_null(sigaction); */ /* not implemented */
179194
/* zassert_not_null(sigaltstack); */ /* not implemented */
180195
/* zassert_not_null(sighold); */ /* not implemented */
181196
/* zassert_not_null(sigignore); */ /* not implemented */
182197
/* zassert_not_null(siginterrupt); */ /* not implemented */
183-
/* zassert_not_null(signal); */ /* not implemented */
184198
/* zassert_not_null(sigpause); */ /* not implemented */
185-
/* zassert_not_null(sigpending); */ /* not implemented */
186199
/* zassert_not_null(sigqueue); */ /* not implemented */
187200
/* zassert_not_null(sigrelse); */ /* not implemented */
188201
/* zassert_not_null(sigset); */ /* not implemented */
189-
/* zassert_not_null(sigsuspend); */ /* not implemented */
190202
/* zassert_not_null(sigtimedwait); */ /* not implemented */
191-
/* zassert_not_null(sigwait); */ /* not implemented */
192203
/* zassert_not_null(sigwaitinfo); */ /* not implemented */
193204
}
194205
}

0 commit comments

Comments
 (0)