| 1 |
/* COVERAGE: alarm nanosleep pause */ |
| 2 |
#include <sys/types.h> |
| 3 |
#include <unistd.h> |
| 4 |
#include <time.h> |
| 5 |
#include <string.h> |
| 6 |
#include <signal.h> |
| 7 |
|
| 8 |
static void |
| 9 |
sigrt_act_handler(int signo, siginfo_t *info, void *context) |
| 10 |
{ |
| 11 |
} |
| 12 |
|
| 13 |
int main() |
| 14 |
{ |
| 15 |
struct timespec rem, t = {0,789}; |
| 16 |
struct sigaction sigrt_act; |
| 17 |
memset(&sigrt_act, 0, sizeof(sigrt_act)); |
| 18 |
sigrt_act.sa_handler = (void *)sigrt_act_handler; |
| 19 |
sigaction(SIGALRM, &sigrt_act, NULL); |
| 20 |
|
| 21 |
alarm(1); |
| 22 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 23 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,1.000000\], XXXX) = 0 |
| 24 |
#else |
| 25 |
//staptest// alarm (1) = 0 |
| 26 |
#endif |
| 27 |
|
| 28 |
pause(); |
| 29 |
#if defined(__ia64__) || defined(__aarch64__) |
| 30 |
//staptest// rt_sigsuspend (\[EMPTY\], 8) = NNNN |
| 31 |
#else |
| 32 |
//staptest// pause () = NNNN |
| 33 |
#endif |
| 34 |
|
| 35 |
alarm(0); |
| 36 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 37 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,0.000000\], XXXX) = 0 |
| 38 |
#else |
| 39 |
//staptest// alarm (0) = 0 |
| 40 |
#endif |
| 41 |
|
| 42 |
alarm(-1); |
| 43 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 44 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,-1.000000\], XXXX) = NNNN |
| 45 |
#else |
| 46 |
#if __WORDSIZE == 64 |
| 47 |
// Sigh. On s390x and ppc64, the kernel gets a 32-bit value. |
| 48 |
//staptest// alarm ([[[[18446744073709551615!!!!4294967295]]]]) = 0 |
| 49 |
#else |
| 50 |
//staptest// alarm (4294967295) = 0 |
| 51 |
#endif |
| 52 |
#endif |
| 53 |
|
| 54 |
alarm(0); |
| 55 |
#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) |
| 56 |
//staptest// setitimer (ITIMER_REAL, \[0.000000,0.000000\], XXXX) = NNNN |
| 57 |
#else |
| 58 |
//staptest// alarm (0) = NNNN |
| 59 |
#endif |
| 60 |
|
| 61 |
sleep(1); |
| 62 |
//staptest// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]\[1.000000000\], XXXX) = 0 |
| 63 |
|
| 64 |
usleep(1234); |
| 65 |
//XXX// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]\[0.001234000\], 0x[0]+) = 0 |
| 66 |
|
| 67 |
nanosleep(&t, &rem); |
| 68 |
//XXX// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]\[0.000000789\], XXXX) = 0 |
| 69 |
|
| 70 |
nanosleep(&t, NULL); |
| 71 |
//XXX// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]\[0.000000789\], 0x[0]+) = 0 |
| 72 |
|
| 73 |
// The following SEGVs in __nanosleep() |
| 74 |
#if 0 |
| 75 |
nanosleep((struct timespec *)-1, NULL); |
| 76 |
#ifdef __s390__ |
| 77 |
//XXX// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]0x[7]?[f]+, 0x[0]+) = -NNNN |
| 78 |
#else |
| 79 |
//XXX// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]0x[f]+, 0x[0]+) = -NNNN |
| 80 |
#endif |
| 81 |
#endif |
| 82 |
|
| 83 |
nanosleep(&t, (struct timespec *)-1); |
| 84 |
#ifdef __s390__ |
| 85 |
//XXX// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]\[0.000000789\], 0x[7]?[f]+) = NNNN |
| 86 |
#else |
| 87 |
//XXX// [[[[nanosleep (!!!!clock_nanosleep (CLOCK_REALTIME, 0x0, ]]]]\[0.000000789\], 0x[f]+) = NNNN |
| 88 |
#endif |
| 89 |
|
| 90 |
return 0; |
| 91 |
} |
| 92 |
|