| 1 |
/* COVERAGE: select pselect6 pselect7 */ |
| 2 |
#define _GNU_SOURCE |
| 3 |
#include <unistd.h> |
| 4 |
#include <sys/select.h> |
| 5 |
#include <signal.h> |
| 6 |
#include <sys/syscall.h> |
| 7 |
|
| 8 |
int main() |
| 9 |
{ |
| 10 |
int fd; |
| 11 |
struct timespec tim = {0, 200000000}; |
| 12 |
sigset_t sigs; |
| 13 |
fd_set rfds; |
| 14 |
struct timeval tv = {0, 117}; |
| 15 |
|
| 16 |
sigemptyset(&sigs); |
| 17 |
sigaddset(&sigs,SIGUSR2); |
| 18 |
|
| 19 |
select(1, &rfds, NULL, NULL, &tv); |
| 20 |
//staptest// [[[[select (1, XXXX, 0x[0]+, 0x[0]+, \[0.000117\])!!!!pselect6 (1, XXXX, 0x[0]+, 0x[0]+, \[0.000117[0]+\], 0x0)]]]] |
| 21 |
|
| 22 |
tv.tv_sec = 0; |
| 23 |
tv.tv_usec = 113; |
| 24 |
|
| 25 |
select(1, NULL, NULL, NULL, &tv); |
| 26 |
//staptest// [[[[select (1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.000113\])!!!!pselect6 (1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.000113[0]+\], 0x0)]]]] |
| 27 |
|
| 28 |
tv.tv_sec = 0; |
| 29 |
tv.tv_usec = 120; |
| 30 |
select(-1, &rfds, NULL, NULL, &tv); |
| 31 |
//staptest// [[[[select (-1, XXXX, 0x[0]+, 0x[0]+, \[0.000120\]!!!!pselect6 (-1, XXXX, 0x[0]+, 0x[0]+, \[0.000120[0]+\], 0x0]]]]) = -NNNN (EINVAL) |
| 32 |
|
| 33 |
tv.tv_sec = 0; |
| 34 |
tv.tv_usec = 121; |
| 35 |
select(1, (fd_set *)-1, NULL, NULL, &tv); |
| 36 |
#ifdef __s390__ |
| 37 |
//staptest// select (1, 0x[7]?[f]+, 0x[0]+, 0x[0]+, \[0.000121\]) = [[[[0!!!!-NNNN (EFAULT)]]]] |
| 38 |
#else |
| 39 |
//staptest// [[[[select (1, 0x[f]+, 0x[0]+, 0x[0]+, \[0.000121\]!!!!pselect6 (1, 0x[f]+, 0x[0]+, 0x[0]+, \[0.000121[0]+\], 0x0]]]]) = [[[[0!!!!-NNNN (EFAULT)]]]] |
| 40 |
#endif |
| 41 |
|
| 42 |
tv.tv_sec = 0; |
| 43 |
tv.tv_usec = 122; |
| 44 |
select(1, &rfds, (fd_set *)-1, NULL, &tv); |
| 45 |
#ifdef __s390__ |
| 46 |
//staptest// select (1, XXXX, 0x[7]?[f]+, 0x[0]+, \[0.000122\]) = [[[[0!!!!-NNNN (EFAULT)]]]] |
| 47 |
#else |
| 48 |
//staptest// [[[[select (1, XXXX, 0x[f]+, 0x[0]+, \[0.000122\]!!!!pselect6 (1, XXXX, 0x[f]+, 0x[0]+, \[0.000122[0]+\], 0x0]]]]) = [[[[0!!!!-NNNN (EFAULT)]]]] |
| 49 |
#endif |
| 50 |
|
| 51 |
tv.tv_sec = 0; |
| 52 |
tv.tv_usec = 123; |
| 53 |
select(1, &rfds, NULL, (fd_set *)-1, &tv); |
| 54 |
#ifdef __s390__ |
| 55 |
//staptest// select (1, XXXX, 0x[0]+, 0x[7]?[f]+, \[0.000123\]) = [[[[0!!!!-NNNN (EFAULT)]]]] |
| 56 |
#else |
| 57 |
//staptest// [[[[select (1, XXXX, 0x[0]+, 0x[f]+, \[0.000123\]!!!!pselect6 (1, XXXX, 0x[0]+, 0x[f]+, \[0.000123[0]+\], 0x0]]]]) = [[[[0!!!!-NNNN (EFAULT)]]]] |
| 58 |
#endif |
| 59 |
|
| 60 |
// The following subtest SEGVs (the part using the glibc wrapper) with modern glibc having commit |
| 61 |
// "9d7c5cc38e linux: Normalize and return timeout on select (BZ #27651)" Since it's trying to |
| 62 |
// dereference the invalid timeout pointer (-1) like this: |
| 63 |
// __time64_t s = timeout != NULL ? timeout->tv_sec : 0; |
| 64 |
// Disable whole the subtest with modern glibc. |
| 65 |
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ <= 33 |
| 66 |
#if defined(__arm__) || defined(__aarch64__) |
| 67 |
syscall(SYS_pselect6, 1, &rfds, NULL, NULL, (struct timeval *)-1); |
| 68 |
#else |
| 69 |
select(1, &rfds, NULL, NULL, (struct timeval *)-1); |
| 70 |
#endif |
| 71 |
#ifdef __s390__ |
| 72 |
//staptest// select (1, XXXX, 0x[0]+, 0x[0]+, 0x[7]?[f]+) = -NNNN (EFAULT) |
| 73 |
#else |
| 74 |
//staptest// [[[[select (1, XXXX, 0x[0]+, 0x[0]+, 0x[f]+!!!!pselect6 (1, XXXX, 0x[0]+, 0x[0]+, 0x[f]+, 0x0]]]]) = -NNNN (EFAULT) |
| 75 |
#endif |
| 76 |
#endif |
| 77 |
|
| 78 |
#if defined(SYS_pselect6) || defined(SYS_pselect7) |
| 79 |
pselect( 1, &rfds, NULL, NULL, &tim, &sigs); |
| 80 |
//staptest//pselect[67] (1, XXXX, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN |
| 81 |
|
| 82 |
pselect( 0, NULL, NULL, NULL, &tim, &sigs); |
| 83 |
//staptest// pselect[67] (0, 0x[0]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN |
| 84 |
|
| 85 |
pselect(-1, NULL, NULL, NULL, &tim, &sigs); |
| 86 |
//staptest//pselect[67] (-1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = -NNNN |
| 87 |
|
| 88 |
pselect(1, (fd_set *)-1, NULL, NULL, &tim, &sigs); |
| 89 |
#ifdef __s390__ |
| 90 |
//staptest//pselect[67] (1, 0x[7]?[f]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN |
| 91 |
#else |
| 92 |
//staptest//pselect[67] (1, 0x[f]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN |
| 93 |
#endif |
| 94 |
|
| 95 |
pselect(1, &rfds, (fd_set *)-1, NULL, &tim, &sigs); |
| 96 |
#ifdef __s390__ |
| 97 |
//staptest//pselect[67] (1, XXXX, 0x[7]?[f]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN |
| 98 |
#else |
| 99 |
//staptest//pselect[67] (1, XXXX, 0x[f]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN |
| 100 |
#endif |
| 101 |
|
| 102 |
pselect(1, &rfds, NULL, (fd_set *)-1, &tim, &sigs); |
| 103 |
#ifdef __s390__ |
| 104 |
//staptest//pselect[67] (1, XXXX, 0x[0]+, 0x[7]?[f]+, \[0.200000000\], XXXX) = NNNN |
| 105 |
#else |
| 106 |
//staptest//pselect[67] (1, XXXX, 0x[0]+, 0x[f]+, \[0.200000000\], XXXX) = NNNN |
| 107 |
#endif |
| 108 |
|
| 109 |
// This causes the exe to get a SIGSEGV... |
| 110 |
//pselect(1, &rfds, NULL, NULL, (struct timespec *)-1, &sigs); |
| 111 |
|
| 112 |
// glibc is "fixing" this one... |
| 113 |
//pselect(1, &rfds, NULL, NULL, &tim, (sigset_t *)-1); |
| 114 |
#endif |
| 115 |
|
| 116 |
return 0; |
| 117 |
} |