From patchwork Thu Jun 10 08:10:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 43800 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 DA2273896831 for ; Thu, 10 Jun 2021 08:11:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA2273896831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623312667; bh=0wYbUteNR3q08VyQVCzOT4eHtOeInIi3EbwWyxK4fPM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=WwMjovcrJtEsBWVc0gtUXl4TU4RUmKuJuTr4Z8criILFAm5i3GqtqLoe1IlvfHSb3 ThviQS3nKWIJoFthl8pqYAdSrpX3w74Gb+pJ/1haQ79VmcfVC7fvBDh5C6LeQfh9wN c+bFcFw9JVpnfTx+/LyXDAYSbrv9DqbdSIzuBRdo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 444013854809 for ; Thu, 10 Jun 2021 08:10:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 444013854809 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-c6hWESVuNOuBX0S4u5J4Hw-1; Thu, 10 Jun 2021 04:10:43 -0400 X-MC-Unique: c6hWESVuNOuBX0S4u5J4Hw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06E55805EF1; Thu, 10 Jun 2021 08:10:43 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-60.ams2.redhat.com [10.36.115.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDBCB5D6AD; Thu, 10 Jun 2021 08:10:41 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] io: Fix sporadic test failures in io/tst-stat Date: Thu, 10 Jun 2021 10:10:40 +0200 Message-ID: <87h7i62l8f.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Cc: Stefan Liebler Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" support_stat_nanoseconds cannot restore the ctime time, and this may lead to sporadic test failures. Therefore, probe for nanoseconds support before the initial statx call. Reviewed-by: Adhemerval Zanella --- io/tst-stat.c | 10 +++++----- support/support.h | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/io/tst-stat.c b/io/tst-stat.c index b3e8dc2170..82e965de6a 100644 --- a/io/tst-stat.c +++ b/io/tst-stat.c @@ -69,15 +69,15 @@ do_test (void) TEST_VERIFY_EXIT (fd >= 0); support_write_file_string (path, "abc"); - struct statx stx; - TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0); - - test_t tests[] = { stat_check, lstat_check, fstat_check, fstatat_check }; - bool check_ns = support_stat_nanoseconds (path); if (!check_ns) printf ("warning: timestamp with nanoseconds not supported\n"); + struct statx stx; + TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0); + + test_t tests[] = { stat_check, lstat_check, fstat_check, fstatat_check }; + for (int i = 0; i < array_length (tests); i++) { struct stat st; diff --git a/support/support.h b/support/support.h index db264e3db7..874204b7fc 100644 --- a/support/support.h +++ b/support/support.h @@ -141,7 +141,8 @@ static __inline bool support_path_support_time64 (const char *path) 0x80000002ULL); } -/* Return true if stat supports nanoseconds resolution. */ +/* Return true if stat supports nanoseconds resolution. PATH is used + for tests and its ctime may change. */ extern bool support_stat_nanoseconds (const char *path); /* Return true if select modify the timeout to reflect the amount of time