From patchwork Tue Mar 23 13:44:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 42752 X-Patchwork-Delegate: siddhesh@gotplt.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AD7B3385040B; Tue, 23 Mar 2021 13:45:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD7B3385040B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616507116; bh=ErkowY/a5TuQSIk48GrYP10Y5oNRE1MLqeKSAAefhgU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=IAgDBM7AWfUCABGQc8YoA9Qt+44NjM5QwOt9BjG2CMtfE9/CbmtZ53f3RNta5+PyO BXRFUfz0x/6v5fcQv+Iic3EJHIu+SjFX5jZ0ows2cZkFUmDZsMZDbd1ftjGROcvkTR OMmxa4k9Au9zl7cTvUnSGbFYhHJTMTfCC740DOkY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by sourceware.org (Postfix) with ESMTPS id 605E6385040A for ; Tue, 23 Mar 2021 13:45:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 605E6385040A Received: by mail-qv1-xf2d.google.com with SMTP id cx5so10436095qvb.10 for ; Tue, 23 Mar 2021 06:45:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ErkowY/a5TuQSIk48GrYP10Y5oNRE1MLqeKSAAefhgU=; b=bxl3T+s19onBa6kOYaKtffi2Gm4ozlGTGQiT7T5HixLlCS6sduMwRNp7AoZGKKA8CP TuF4NFyABbEBre3mOWiEi8nMiZGcOsuHBEal2+Ges2NyAgnznPTiZMlT0n7egZMG5EhQ cR5SFCcUnH74x35i94ENmcgSTfvrg0pakpD7huwUQNFBbB1+jMwp3EXovxKfQ7HsQrkk gDYLLp7hhnWgs9dOgRJFYkvKKM4QjJvqU6YXLDRbr1+D739jC2v7AQEHNprxDHaqp9uP elNXtIUd6L5evh7mCgoiw7PRxyfJGye0og4bCEBg5sMJhir4XSj6/QCKe5yGKW2L0NaS 4rKA== X-Gm-Message-State: AOAM533dZp+UwpOYfv2gzO8IhQTp1GmoYG+P034ku/B27sQTY7VYGAOF gAaRdd/lFzgVzkIoPH9/hskqIvShyP7rGA== X-Google-Smtp-Source: ABdhPJy27zdlm9w4g8Oay6dfzKoZm2fs2PQoUZx4X4FCd+OlDFSxZSPdVjxxjE/NGdVIpS0hdxpbsA== X-Received: by 2002:a0c:b59d:: with SMTP id g29mr4758893qve.39.1616507112785; Tue, 23 Mar 2021 06:45:12 -0700 (PDT) Received: from localhost.localdomain ([177.194.41.149]) by smtp.googlemail.com with ESMTPSA id z24sm12783384qkz.65.2021.03.23.06.45.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 06:45:12 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 09/15] time: Add basic timespec_get tests Date: Tue, 23 Mar 2021 10:44:52 -0300 Message-Id: <20210323134458.2563022-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210323134458.2563022-1-adhemerval.zanella@linaro.org> References: <20210323134458.2563022-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Checkec on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Siddhesh Poyarekar --- time/Makefile | 3 ++- time/tst-timespec_get.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 time/tst-timespec_get.c diff --git a/time/Makefile b/time/Makefile index 5fcd40ccbb..e1faeb3921 100644 --- a/time/Makefile +++ b/time/Makefile @@ -49,7 +49,8 @@ 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-settimeofday tst-itimer tst-gmtime tst-timegm + tst-settimeofday 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