From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by sourceware.org (Postfix) with ESMTPS id EEE373854816 for ; Thu, 25 Feb 2021 12:16:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EEE373854816 Received: by mail-qk1-x734.google.com with SMTP id d20so4349626qkc.2 for ; Thu, 25 Feb 2021 04:16:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BkXWdp+dbIqq4sqAGOft+jGH1UlcqmptFHJm40IXMyQ=; b=pGg+cPYoAZcsJ2BcKUOJX1DApT2XKHaSj4Wnr4nM0+oNX6Q1/IabLZemerp6CJMJcF vt6pR1kYuuZ89IPf3qSM+qLcU97i1RrezRG220LdbfiXmSw/zzembIoJ0inVGXC7WZyI coh4OYBMlGr3UXX6FLLDx0nX4ozJVKGI8nFYI2TRKImLMIbhATJDd9TPpeWO/ssKs5Ep 4Bkaepm8abbgPZYrz0/TK/ga2srVTQK8ekr2P6/ENhWdiY5iy8v4VPNjkMiOZMVgtxPX 43fXWr+7W4XdvwqJcMey42sVIijt0ENQbknFO0pbnWBSXYnlWWCiqsK33/F2U68lOt6R nMKA== X-Gm-Message-State: AOAM531YIdL5ah+pUp78ub9GL6VeGF0iJrm7wktSbkCHJVnR348mk+d9 0tN7nUvAz68sdVVvRZ75codrJBVZVeMAIw== X-Google-Smtp-Source: ABdhPJwTicqr2wSl5tvP0sYPbqNW7Vk1+crrJ6pPSPagTlGAWhE1k6sUc+SwWxxN1u5CXyP/ijXbDQ== X-Received: by 2002:a37:ec2:: with SMTP id 185mr2282600qko.150.1614255372302; Thu, 25 Feb 2021 04:16:12 -0800 (PST) Received: from [192.168.1.4] ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id q186sm3763391qka.56.2021.02.25.04.16.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Feb 2021 04:16:12 -0800 (PST) To: Lukasz Majewski , GNU C Library References: <20210225003509.7151-1-lukma@denx.de> From: Adhemerval Zanella Subject: Re: [PATCH] tst: Add test for utime Message-ID: Date: Thu, 25 Feb 2021 09:16:09 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210225003509.7151-1-lukma@denx.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, 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-List-Received-Date: Thu, 25 Feb 2021 12:16:14 -0000 On 24/02/2021 21:35, Lukasz Majewski wrote: > This patch provides test for utime. It uses xfstat() syscall to read > access and modification times to compare with ones written by utime. Same as for futimens tests, it does not need to specific the internal function used. > > Moreover, access and modification times beyond the Y2038 threshold > date (i.e. 32 bit time_t overflow) are also checked. LGTM with the commit message change the small nit below. I am not sure if it is worth to silent not run the some internal tests for 32 bit time, but we can improve it once we get 64 bit time_t support. Reviewed-by: Adhemerval Zanella > --- > sysdeps/unix/sysv/linux/Makefile | 2 +- > sysdeps/unix/sysv/linux/tst-utime.c | 83 +++++++++++++++++++++++++++++ > 2 files changed, 84 insertions(+), 1 deletion(-) > create mode 100644 sysdeps/unix/sysv/linux/tst-utime.c > > diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile > index 4e043c78ab..e68c259fa0 100644 > --- a/sysdeps/unix/sysv/linux/Makefile > +++ b/sysdeps/unix/sysv/linux/Makefile > @@ -107,7 +107,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ > test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \ > tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \ > tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \ > - tst-timerfd tst-ppoll tst-futimens > + tst-timerfd tst-ppoll tst-futimens tst-utime > tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc > > CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables Ok. > diff --git a/sysdeps/unix/sysv/linux/tst-utime.c b/sysdeps/unix/sysv/linux/tst-utime.c > new file mode 100644 > index 0000000000..fe1869702c > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/tst-utime.c > @@ -0,0 +1,83 @@ > +/* Test for utime Missing period. > + 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 > +#include > +#include > +#include > + > +static int temp_fd = -1; > +char *testfile; > + > +/* struct utimbuf with Y2038 threshold minus 2 and 1 seconds. */ > +const struct utimbuf t1 = { 0x7FFFFFFE, 0x7FFFFFFF }; > + > +/* struct utimbuf with Y2038 threshold plus 1 and 2 seconds. */ > +const struct utimbuf t2 = { 0x80000001ULL, 0x80000002ULL }; > + > +/* struct utimbuf around Y2038 threshold. */ > +const struct utimbuf t3 = { 0x7FFFFFFE, 0x80000002ULL }; Use static on these. > + > +#define PREPARE do_prepare > +static void > +do_prepare (int argc, char *argv[]) > +{ > + temp_fd = create_temp_file ("utime", &testfile); > + TEST_VERIFY_EXIT (temp_fd > 0); > +} > + > +static int > +test_utime_helper (const struct utimbuf *ut) > +{ > + struct stat64 st; > + int result; > + time_t t; > + > + /* Check if we run on port with 32 bit time_t size */ > + if (__builtin_add_overflow (ut->actime, 0, &t)) > + return 0; Maybe add a warning that this specific test is not executed due 32 bit time_t? Same for futimens. > + > + result = utime(testfile, ut); > + TEST_VERIFY_EXIT (result == 0); > + > + xfstat (temp_fd, &st); > + > + /* Check if seconds for actime match */ > + TEST_COMPARE (st.st_atime, ut->actime); > + > + /* Check if seconds for modtime match */ > + TEST_COMPARE (st.st_mtime, ut->modtime); > + > + return 0; > +} > + > +static int > +do_test (void) > +{ > + test_utime_helper (&t1); > + test_utime_helper (&t2); > + test_utime_helper (&t3); > + > + return 0; > +} > + > +#include > Ok.