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