From 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2007 18:26:36 +0000 Subject: 2.5-18.1 --- rt/tst-clock2.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 rt/tst-clock2.c (limited to 'rt/tst-clock2.c') diff --git a/rt/tst-clock2.c b/rt/tst-clock2.c new file mode 100644 index 0000000..4c8fb9f --- /dev/null +++ b/rt/tst-clock2.c @@ -0,0 +1,43 @@ +/* Test setting the monotonic clock. */ + +#include +#include + +#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK + +# include +# include + +static int +do_test (void) +{ + if (sysconf (_SC_MONOTONIC_CLOCK) <= 0) + return 0; + + struct timespec ts; + if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0) + { + puts ("clock_gettime(CLOCK_MONOTONIC) failed"); + return 1; + } + + /* Setting the monotonic clock must fail. */ + if (clock_settime (CLOCK_MONOTONIC, &ts) != -1) + { + puts ("clock_settime(CLOCK_MONOTONIC) did not fail"); + return 1; + } + if (errno != EINVAL) + { + printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n", + errno, EINVAL); + return 1; + } + return 0; +} +# define TEST_FUNCTION do_test () + +#else +# define TEST_FUNCTION 0 +#endif +#include "../test-skeleton.c" -- cgit v1.1