From patchwork Tue Mar 9 11:47:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 42393 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com 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 894D4382E80A; Tue, 9 Mar 2021 11:47:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id AB7043836C11 for ; Tue, 9 Mar 2021 11:47:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AB7043836C11 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dvtjj6f3pz1rxY9; Tue, 9 Mar 2021 12:47:21 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dvtjj5TQyz1r1MS; Tue, 9 Mar 2021 12:47:21 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id BmwZlOXGonNg; Tue, 9 Mar 2021 12:47:19 +0100 (CET) X-Auth-Info: FjEq0GC9dI5tWk9s1oskdEQsO7OAMWT/w/Wv0a4ACbw= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 9 Mar 2021 12:47:19 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Adhemerval Zanella , Florian Weimer , DJ Delorie Subject: [PATCH 1/2] tst: Add test for ntp_gettime Date: Tue, 9 Mar 2021 12:47:08 +0100 Message-Id: <20210309114709.23403-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Cc: GNU C Library , Florian Weimer , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This code provides test to check if time on target machine is properly read via ntp_gettime syscall. --- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/tst-ntp_gettime.c | 49 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_gettime.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index b8c1caa505..8a07870cb4 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -113,7 +113,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \ tst-timerfd tst-ppoll tst-futimens tst-utime tst-utimes \ tst-clock_adjtime tst-adjtimex tst-ntp_adjtime tst-futimes \ - tst-lutimes + tst-lutimes tst-ntp_gettime tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc tests-time64 += \ tst-futimes-time64\ diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettime.c b/sysdeps/unix/sysv/linux/tst-ntp_gettime.c new file mode 100644 index 0000000000..5a1261fd35 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-ntp_gettime.c @@ -0,0 +1,49 @@ +/* Test for ntp_gettime + 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 +#include +#include +#include + +#ifndef NTP_GETTIME_SYSCALL +# define NTP_GETTIME_SYSCALL ntp_gettime +#endif + +# define STR(__s) #__s + +static int +do_test (void) +{ + struct timespec tv_now; + struct ntptimeval ntv; + + int ret = NTP_GETTIME_SYSCALL (&ntv); + if (ret == -1) + FAIL_EXIT1 (STR(NTP_GETTIME_SYSCALL)" failed: %m\n"); + + tv_now = xclock_now (CLOCK_REALTIME); + + if (tv_now.tv_sec != ntv.time.tv_sec) + FAIL_EXIT1 ("ntp_gettime provided wrong time!\n"); + + return 0; +} + +#include From patchwork Tue Mar 9 11:47:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 42394 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com 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 E21863836C11; Tue, 9 Mar 2021 11:47:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id BA521386F02C for ; Tue, 9 Mar 2021 11:47:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BA521386F02C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dvtjm28lNz1qs3t; Tue, 9 Mar 2021 12:47:24 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dvtjm0hy9z1r1MS; Tue, 9 Mar 2021 12:47:24 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 6wlzxZi90gb3; Tue, 9 Mar 2021 12:47:22 +0100 (CET) X-Auth-Info: Fw7FsO2LVaG+4gBTVSYHPxorzVenRHu8wt/UfVvUHvg= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 9 Mar 2021 12:47:21 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Adhemerval Zanella , Florian Weimer , DJ Delorie Subject: [PATCH 2/2] tst: Add test for ntp_gettimex Date: Tue, 9 Mar 2021 12:47:09 +0100 Message-Id: <20210309114709.23403-2-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210309114709.23403-1-lukma@denx.de> References: <20210309114709.23403-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Cc: GNU C Library , Florian Weimer , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This test is a wrapper on tst-ntp_gettime test. --- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/tst-ntp_gettimex.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_gettimex.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 8a07870cb4..e7f733eacf 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -113,7 +113,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \ tst-timerfd tst-ppoll tst-futimens tst-utime tst-utimes \ tst-clock_adjtime tst-adjtimex tst-ntp_adjtime tst-futimes \ - tst-lutimes tst-ntp_gettime + tst-lutimes tst-ntp_gettime tst-ntp_gettimex tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc tests-time64 += \ tst-futimes-time64\ diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettimex.c b/sysdeps/unix/sysv/linux/tst-ntp_gettimex.c new file mode 100644 index 0000000000..3865dd3083 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-ntp_gettimex.c @@ -0,0 +1,21 @@ +/* Test for ntp_gettimex + 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 + . */ + +#define NTP_GETTIME_SYSCALL ntp_gettimex + +#include