1 /* 2 * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz> 3 * 4 * This file is licensed under the GPL license. For the full content of this 5 * license, see the COPYING file at the top level of this source tree. 6 * 7 * After sigprocmask() is called on an invalid how it should return -1 and set 8 * errno to EINVAL. 9 */ 10 11 12 #include <stdio.h> 13 #include <signal.h> 14 #include <errno.h> 15 #include <stdint.h> 16 #include <stdlib.h> 17 #include "posixtest.h" 18 main(void)19int main(void) 20 { 21 sigset_t set; 22 int r, i, fails = 0; 23 24 sigemptyset(&set); 25 sigaddset(&set, SIGABRT); 26 27 for (i = 0; i < 100000; i++) { 28 r = rand() % (i + 1); 29 30 switch (r) { 31 case SIG_BLOCK: 32 case SIG_UNBLOCK: 33 case SIG_SETMASK: 34 continue; 35 default: 36 break; 37 } 38 39 if (sigprocmask(r, &set, NULL) != -1 || errno != EINVAL) { 40 printf("sigprocmask(%i, ...) failed to fail\n", r); 41 fails++; 42 } 43 } 44 45 if (fails) { 46 printf("Test FAILED\n"); 47 return PTS_FAIL; 48 } 49 50 printf("Test PASSED\n"); 51 return PTS_PASS; 52 } 53