• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>
3  *
4  * This file is licensed under the GPL license. For the full content of this
5  * license, see the COPYING file at the top level of this source tree.
6  *
7  * After sigprocmask() is called on an invalid how it should return -1 and set
8  * errno to EINVAL.
9  */
10 
11 #define _XOPEN_SOURCE 600
12 
13 #include <stdio.h>
14 #include <signal.h>
15 #include <errno.h>
16 #include <stdint.h>
17 #include <stdlib.h>
18 #include "posixtest.h"
19 
main(void)20 int main(void)
21 {
22 	sigset_t set;
23 	int r, i, fails = 0;
24 
25 	sigemptyset(&set);
26 	sigaddset(&set, SIGABRT);
27 
28 	for (i = 0; i < 100000; i++) {
29 		r = rand() % (i + 1);
30 
31 		switch (r) {
32 		case SIG_BLOCK:
33 		case SIG_UNBLOCK:
34 		case SIG_SETMASK:
35 			continue;
36 		default:
37 		break;
38 		}
39 
40 		if (sigprocmask(r, &set, NULL) != -1 || errno != EINVAL) {
41 			printf("sigprocmask(%i, ...) failed to fail\n", r);
42 			fails++;
43 		}
44 	}
45 
46 	if (fails) {
47 		printf("Test FAILED\n");
48 		return PTS_FAIL;
49 	}
50 
51 	printf("Test PASSED\n");
52 	return PTS_PASS;
53 }
54