From 115d20fe89f755c0204d8dd566dfed8686290c88 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Fri, 12 May 2017 17:55:08 +0200 Subject: nptl: add new testcase for pthread_getcpuclockid() --- test/nptl/Makefile.in | 6 +++--- test/nptl/tst-clockid.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 test/nptl/tst-clockid.c diff --git a/test/nptl/Makefile.in b/test/nptl/Makefile.in index be55165..0f43c77 100644 --- a/test/nptl/Makefile.in +++ b/test/nptl/Makefile.in @@ -48,8 +48,8 @@ TESTS := tst-align tst-align2 tst-atfork1 tst-attr1 tst-attr2 tst-attr3 \ tst-signal5 tst-signal6 tst-spin1 tst-spin2 tst-spin3 \ tst-stack1 tst-stack2 tst-stdio1 tst-stdio2 tst-sysconf \ tst-tls1 tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tsd1 tst-tsd2 \ - tst-tsd3 tst-tsd4 tst-tsd5 tst-umask1 tst-cond-deadlock \ - tst-align3 tst-cancel4 tst-cancel5 tst-cancel18 tst-cancel23 \ + tst-tsd3 tst-tsd4 tst-tsd5 tst-umask1 tst-cond-deadlock \ + tst-align3 tst-cancel4 tst-cancel5 tst-cancel18 tst-cancel23 \ tst-cancel25 tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx6 \ tst-cancelx7 tst-cancelx8 tst-cancelx9 tst-cancelx10 tst-cancelx11 \ tst-cancelx12 tst-cancelx13 tst-cancelx14 tst-cancelx15 tst-cancelx16 \ @@ -60,7 +60,7 @@ TESTS := tst-align tst-align2 tst-atfork1 tst-attr1 tst-attr2 tst-attr3 \ tst-basic7 tst-signal7 tst-vfork1x tst-vfork2x tst-sem10 tst-sem11 \ tst-sem12 tst-initializers1-c89 tst-initializers1-c99 \ tst-initializers1-gnu89 tst-initializers1-gnu99 \ - tst-atfork2 + tst-atfork2 tst-clockid # # These are for the RT library and POSIX timers. 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 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include +#include +#include +#include +#include + +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" -- cgit v1.2.3