• 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 
27 #define	NUMSIGNALS	(sizeof(sigs) / sizeof(sigs[0]))
28 
main(void)29 int main(void)
30 {
31 	sigset_t signalset;
32 	int i, ret, err = 0;
33 
34 	if (sigfillset(&signalset) == -1) {
35 		perror("sigemptyset failed -- test aborted");
36 		return PTS_UNRESOLVED;
37 	}
38 
39 	for (i = 0; i < (int)NUMSIGNALS; i++) {
40 		ret = sigdelset(&signalset, sigs[i]);
41 		if (ret != -1 || errno != EINVAL) {
42 			err++;
43 			printf("Failed sigdelset(..., %i) ret=%i errno=%i\n",
44 			       sigs[i], ret, errno);
45 		}
46 	}
47 
48 	if (err) {
49 		printf("Test FAILED\n");
50 		return PTS_FAIL;
51 	} else {
52 		printf("Test PASSED\n");
53 		return PTS_PASS;
54 	}
55 }
56