summaryrefslogtreecommitdiff
path: root/rt
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-08-07 19:28:26 +0000
committerJakub Jelinek <jakub@redhat.com>2006-08-07 19:28:26 +0000
commit503d6a958581777473c31f73113d0fa6cff19b30 (patch)
treec8526f0403ac272cba94213a3c5b10a369876d78 /rt
parent98d2266156a49df5f93726c8f0b148bbdee41c9d (diff)
Updated to fedora-glibc-20060807T1859cvs/fedora-glibc-2_4_90-18
Diffstat (limited to 'rt')
-rw-r--r--rt/Makefile3
-rw-r--r--rt/tst-clock2.c43
2 files changed, 45 insertions, 1 deletions
diff --git a/rt/Makefile b/rt/Makefile
index f8487975dd..148ded996e 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -48,7 +48,8 @@ tests := tst-shm tst-clock tst-clock_nanosleep tst-timer tst-timer2 \
tst-mqueue5 tst-mqueue6 tst-mqueue7 tst-mqueue8 tst-mqueue9 \
tst-timer3 tst-timer4 tst-timer5 \
tst-cpuclock1 tst-cpuclock2 \
- tst-cputimer1 tst-cputimer2 tst-cputimer3
+ tst-cputimer1 tst-cputimer2 tst-cputimer3 \
+ tst-clock2
extra-libs := librt
extra-libs-others := $(extra-libs)
diff --git a/rt/tst-clock2.c b/rt/tst-clock2.c
new file mode 100644
index 0000000000..4c8fb9f247
--- /dev/null
+++ b/rt/tst-clock2.c
@@ -0,0 +1,43 @@
+/* Test setting the monotonic clock. */
+
+#include <time.h>
+#include <unistd.h>
+
+#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
+
+# include <errno.h>
+# include <stdio.h>
+
+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"