1 /* Tests for POSIX timer implementation using process CPU clock. */
5 #if _POSIX_THREADS && defined _POSIX_CPUTIME
14 #define TEST_CLOCK CLOCK_PROCESS_CPUTIME_ID
15 #define TEST_CLOCK_MISSING(clock) \
16 (setup_test () ? "process CPU clock timer support" : NULL)
18 /* This function is intended to rack up both user and system time. */
24 static volatile char buf
[4096];
25 for (int i
= 0; i
< 100; ++i
)
26 for (size_t j
= 0; j
< sizeof buf
; ++j
)
28 int nullfd
= open ("/dev/null", O_WRONLY
);
29 for (int i
= 0; i
< 100; ++i
)
30 for (size_t j
= 0; j
< sizeof buf
; ++j
)
32 write (nullfd
, (char *) buf
, sizeof buf
);
42 /* Test timers on our own process CPU clock by having a worker thread
43 eating CPU. First make sure we can make such timers at all. */
46 if (timer_create (TEST_CLOCK
, NULL
, &t
) != 0)
48 printf ("timer_create: %m\n");
54 int e
= pthread_create (&th
, NULL
, chew_cpu
, NULL
);
57 printf ("pthread_create: %s\n", strerror (e
));
65 # define TEST_CLOCK_MISSING(clock) "process clocks"
68 #include "tst-timer4.c"