|
Packit Service |
82fcde |
/* Timer test using the monotonic clock. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <time.h>
|
|
Packit Service |
82fcde |
#include <unistd.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define TEST_CLOCK CLOCK_MONOTONIC
|
|
Packit Service |
82fcde |
# define TEST_CLOCK_MISSING(clock) \
|
|
Packit Service |
82fcde |
(setup_test () ? "CLOCK_MONOTONIC" : NULL)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# include <stdio.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static int
|
|
Packit Service |
82fcde |
setup_test (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
if (sysconf (_SC_MONOTONIC_CLOCK) <= 0)
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* The user-level timers implementation doesn't support CLOCK_MONOTONIC,
|
|
Packit Service |
82fcde |
even though sysconf claims it will. */
|
|
Packit Service |
82fcde |
timer_t t;
|
|
Packit Service |
82fcde |
if (timer_create (TEST_CLOCK, NULL, &t) != 0)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("timer_create: %m\n");
|
|
Packit Service |
82fcde |
return 1;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
timer_delete (t);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return 0;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# include "tst-timer4.c"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
# define TEST_FUNCTION 0
|
|
Packit Service |
82fcde |
# include "../test-skeleton.c"
|
|
Packit Service |
82fcde |
#endif
|