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 #define _XOPEN_SOURCE 600
18 
19 #include <stdio.h>
20 #include <signal.h>
21 #include <errno.h>
22 #include <stdint.h>
23 #include <setjmp.h>
24 #include "posixtest.h"
25 
26 static const int sigs[] = {-1, -10000, INT32_MIN, INT32_MIN + 1};
27 
main(void)28 int main(void)
29 {
30 	int i, ret, err = 0;
31 
32 	for (i = 0; i < sizeof(sigs) / sizeof(int); i++) {
33 		ret = sigrelse(sigs[i]);
34 
35 		if (ret != -1 || errno != EINVAL) {
36 			err++;
37 			printf("Failed sigrelse(%i) ret=%i errno=%i\n",
38 			       sigs[i], ret, errno);
39 		}
40 	}
41 
42 	if (err) {
43 		printf("Test FAILED\n");
44 		return PTS_FAIL;
45 	} else {
46 		printf("Test PASSED\n");
47 		return PTS_PASS;
48 	}
49 }
50