summaryrefslogtreecommitdiff
path: root/test/nptl/tst-clockid.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/nptl/tst-clockid.c')
-rw-r--r--test/nptl/tst-clockid.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/nptl/tst-clockid.c b/test/nptl/tst-clockid.c
new file mode 100644
index 0000000..7ced2fb
--- /dev/null
+++ b/test/nptl/tst-clockid.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 Sergey Korolev <s.korolev@ndmsystems.com>
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <time.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+int do_test (void)
+{
+ clockid_t clk;
+ struct timespec ts;
+ const int err = pthread_getcpuclockid(pthread_self(), &clk);
+
+ if (err != 0) {
+ errno = err;
+ perror("pthread_getcpuclockid");
+ return EXIT_FAILURE;
+ }
+
+ if (clock_gettime(clk, &ts) == -1) {
+ perror("clock_gettime");
+ return EXIT_FAILURE;
+ }
+
+ printf("Thread time is %lu.%06lu.\n",
+ ts.tv_sec,
+ ts.tv_nsec / 1000);
+
+ return EXIT_SUCCESS;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"