• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
3  * Copyright (c) 2013, Cyril Hrubis <chrubis@suse.cz>
4  *
5  * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com
6  * This file is licensed under the GPL license.  For the full content
7  * of this license, see the COPYING file at the top level of this
8  * source tree.
9  *
10  * Testing sending invalid signals to sigdelset().
11  * After invalid signal sent, sigdelset() should return -1 and set
12  * errno to indicate the error.
13  * Test steps:
14  * 1)  Initialize a full signal set.
15  * 2)  Remove the invalid signal from the full signal set.
16  * 3)  Verify that -1 is returned, the invalid signal is not a member of
17  *     the signal set, and errno is set to indicate the error.
18  */
19 #include <stdio.h>
20 #include <signal.h>
21 #include <errno.h>
22 #include <stdint.h>
23 #include "posixtest.h"
24 
25 static const int sigs[] = {-1, -10000, INT32_MIN, INT32_MIN + 1};
26 
main(void)27 int main(void)
28 {
29 	sigset_t signalset;
30 	int i, ret, err = 0;
31 
32 	if (sigfillset(&signalset) == -1) {
33 		perror("sigemptyset failed -- test aborted");
34 		return PTS_UNRESOLVED;
35 	}
36 
37 	for (i = 0; i < sizeof(sigs) / sizeof(int); i++) {
38 		ret = sigdelset(&signalset, sigs[i]);
39 
40 		if (ret != -1 || errno != EINVAL) {
41 			err++;
42 			printf("Failed sigdelset(..., %i) ret=%i errno=%i\n",
43 			       sigs[i], ret, errno);
44 		}
45 	}
46 
47 	if (err) {
48 		printf("Test FAILED\n");
49 		return PTS_FAIL;
50 	} else {
51 		printf("Test PASSED\n");
52 		return PTS_PASS;
53 	}
54 }
55