• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2003, Intel Corporation. All rights reserved.
3  * Copyright (c) 2013, Cyril Hrubis <chrubis@suse.cz>
4  *
5  * Created by:  salwan.searty 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 passing an invalid signals to sigrelse().
11  * After sighold is called on an invalid signal, sigrelse() should
12  * return -1 and set errno to EINVAL
13  *
14  * The invalid signal passed to sigrelse() depends on the argument
15  * passed to this program.
16  */
17 
18 #include <stdio.h>
19 #include <signal.h>
20 #include <errno.h>
21 #include <stdint.h>
22 #include <setjmp.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 	int i, ret, err = 0;
32 
33 	for (i = 0; i < (int)NUMSIGNALS; i++) {
34 		ret = sigrelse(sigs[i]);
35 
36 		if (ret != -1 || errno != EINVAL) {
37 			err++;
38 			printf("Failed sigrelse(%i) ret=%i errno=%i\n",
39 			       sigs[i], ret, errno);
40 		}
41 	}
42 
43 	if (err) {
44 		printf("Test FAILED\n");
45 		return PTS_FAIL;
46 	} else {
47 		printf("Test PASSED\n");
48 		return PTS_PASS;
49 	}
50 }
51