Home | History | Annotate | Download | only in sigismember
      1 /*
      2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
      3  * Copyright (c) 2013, Cyril Hrubis <chrubis (at) 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 invalid signals with sigismember().
     11  * After invalid signal set sigismember() should return -1 and set
     12  * errno to indicate the error.
     13  * Test steps:
     14  * 1)  Initialize a full signal set.
     15  * 2)  Check for invalid signal from the full signal set.
     16  * 3)  Verify that -1 is returned and errno is set to indicate the error.
     17  */
     18 #include <stdio.h>
     19 #include <signal.h>
     20 #include <errno.h>
     21 #include <stdint.h>
     22 #include "posixtest.h"
     23 
     24 static const int sigs[] = {-1, -10000, INT32_MIN, INT32_MIN + 1};
     25 
     26 int main(void)
     27 {
     28 	sigset_t signalset;
     29 	int i, ret, err = 0;
     30 
     31 	if (sigfillset(&signalset) == -1) {
     32 		perror("sigemptyset failed -- test aborted");
     33 		return PTS_UNRESOLVED;
     34 	}
     35 
     36 	for (i = 0; i < sizeof(sigs) / sizeof(int); i++) {
     37 		ret = sigismember(&signalset, sigs[i]);
     38 
     39 		if (ret != -1 || errno != EINVAL) {
     40 			err++;
     41 			printf("Failed sigaddset(..., %i) ret=%i errno=%i\n",
     42 			       sigs[i], ret, errno);
     43 		}
     44 	}
     45 
     46 	if (err) {
     47 		printf("Test FAILED\n");
     48 		return PTS_FAIL;
     49 	} else {
     50 		printf("Test PASSED\n");
     51 		return PTS_PASS;
     52 	}
     53 }
     54