From patchwork Tue Mar 23 13:44:45 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: 42745 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 60B173861037; Tue, 23 Mar 2021 13:45:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60B173861037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616507108; bh=OAROPPqUNinN9h0dI6i9cXQSu2l/+M7c7VaQpBW4n5k=; 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=NxHi74aazOu4qcxwKmDFc2hxiSHXMUDkzLoF7qgQZX5fisBFWDmXtv0gY4RxhrKPj fzu8liJ1Zm/wfNAGAHtrLM3QXTyFeSV8cZEJoEdO75aYj6WCRJoX/NVWMI5HXUMCMX /8ZOkPssR64QENpLxcBcMm7KyTpaP/nOKoJGV/Vo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by sourceware.org (Postfix) with ESMTPS id 12107385701F for ; Tue, 23 Mar 2021 13:45:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 12107385701F Received: by mail-qv1-xf2a.google.com with SMTP id d10so10459246qve.7 for ; Tue, 23 Mar 2021 06:45:05 -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=OAROPPqUNinN9h0dI6i9cXQSu2l/+M7c7VaQpBW4n5k=; b=mL+HNMjMaSroGifywPxIyFFgBkrFA9MrEkdJo6cNf3QnK6UzecsPaa46ISRKWVuxv9 Xokblie0eKWFJvQhuYqLHXfHlHjzpytCa1PRNoIqoT3O8HM2kg03VmtO//OP04QjtPU2 +nW03pw0Y13EssTWeHUAb3lZMES/ylVeKN4n2bmbGZOnHhZCSTWyPXM5HjC2+1kD5aSA FRZpxpwdj18IkO0I+GbFIRDMmJMRo5h0rIUdS6kbW2V0361LKmMJBuWijyTNC0pJSTix RVG7SnwIaa6tzr6DCreiP1q/hoTEz8Hnjypyj5SkXm1bDfb5oqIcHzcAOc6vNPBfBoD/ KzQw== X-Gm-Message-State: AOAM532YNW+KP6mYKBPTIdjY51hiOvU+PXCnnmKhhbxqVb9S3R70gVjm Te4ksguoIgKLb+K7i73WJ4b9qSMxrqgg+A== X-Google-Smtp-Source: ABdhPJxfW5B0IUhClrKSgLfZvMbFlHnQWuwTEc/JZ/mJwCBoGVXN+PROrTSylAmFfhWTcFCr897uxg== X-Received: by 2002:a0c:a99a:: with SMTP id a26mr4892208qvb.2.1616507104492; Tue, 23 Mar 2021 06:45:04 -0700 (PDT) Received: from localhost.localdomain ([177.194.41.149]) by smtp.googlemail.com with ESMTPSA id z24sm12783384qkz.65.2021.03.23.06.45.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 06:45:04 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 02/15] linux: Add futimes test Date: Tue, 23 Mar 2021 10:44:45 -0300 Message-Id: <20210323134458.2563022-3-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.3 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" It uses stat to compare against the values set by futimes. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Siddhesh Poyarekar --- io/Makefile | 1 + io/tst-futimes.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 io/tst-futimes.c diff --git a/io/Makefile b/io/Makefile index 3411573cf3..0002e108a6 100644 --- a/io/Makefile +++ b/io/Makefile @@ -71,6 +71,7 @@ tests := test-utime test-stat test-stat2 test-lfs tst-getcwd \ tst-ftw-bz26353 tst-stat tst-stat-lfs \ tst-utime \ tst-utimes \ + tst-futimes \ tst-futimens \ # Likewise for statx, but we do not need static linking here. diff --git a/io/tst-futimes.c b/io/tst-futimes.c new file mode 100644 index 0000000000..ea7ac7d5f8 --- /dev/null +++ b/io/tst-futimes.c @@ -0,0 +1,46 @@ +/* Test for futimes. + 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 + +static int +test_futimens_helper (const char *file, int fd, const struct timeval *tv) +{ + int r = futimes (fd, tv); + TEST_VERIFY_EXIT (r == 0); + + struct stat64 st; + xfstat (fd, &st); + + /* Check if seconds for atime match */ + TEST_COMPARE (st.st_atime, tv[0].tv_sec); + + /* Check if seconds for mtime match */ + TEST_COMPARE (st.st_mtime, tv[1].tv_sec); + + return 0; +} + +#define TEST_CALL(fname, fd, v1, v2) \ + test_futimens_helper (fname, fd, (struct timeval[]) { { v1, 0 }, \ + { v2, 0 } }) + +#include "tst-utimensat-skeleton.c"