From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 3761A3AA903D; Thu, 4 Mar 2021 17:38:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3761A3AA903D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/y2038] time: Add basic timespec_get tests X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/y2038 X-Git-Oldrev: 52d7778262fe7bde7c1d9ee5b457fccdde9d9016 X-Git-Newrev: 074af1dc74d5f9c9d0e26ada4602454f1ba08c64 Message-Id: <20210304173810.3761A3AA903D@sourceware.org> Date: Thu, 4 Mar 2021 17:38:10 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Mar 2021 17:38:10 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=074af1dc74d5f9c9d0e26ada4602454f1ba08c64 commit 074af1dc74d5f9c9d0e26ada4602454f1ba08c64 Author: Adhemerval Zanella Date: Mon Mar 1 13:14:03 2021 -0300 time: Add basic timespec_get tests Checkec on x86_64-linux-gnu and i686-linux-gnu. Diff: --- time/Makefile | 2 +- time/tst-timespec_get.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/time/Makefile b/time/Makefile index 5d865a4054..29208f35c0 100644 --- a/time/Makefile +++ b/time/Makefile @@ -49,7 +49,7 @@ tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \ tst-tzname tst-y2039 bug-mktime4 tst-strftime2 tst-strftime3 \ tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1 \ tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime \ - tst-itimer tst-gmtime tst-timegm + tst-itimer tst-gmtime tst-timegm tst-timespec_get include ../Rules diff --git a/time/tst-timespec_get.c b/time/tst-timespec_get.c new file mode 100644 index 0000000000..7389927db4 --- /dev/null +++ b/time/tst-timespec_get.c @@ -0,0 +1,40 @@ +/* Basic tests for timespec_get. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +static int +do_test (void) +{ + { + struct timespec ts; + TEST_COMPARE (timespec_get (&ts, 0), 0); + } + + { + struct timespec ts; + TEST_COMPARE (timespec_get (&ts, TIME_UTC), TIME_UTC); + TEST_VERIFY (ts.tv_nsec >= 0); + TEST_VERIFY (ts.tv_nsec < 1000000000); + } + + return 0; +} + +#include