From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id DF24F1F4B4 for ; Sat, 2 Jan 2021 18:06:15 +0000 (UTC) Received: from localhost ([::1]:44212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvlI6-0006is-M2 for normalperson@yhbt.net; Sat, 02 Jan 2021 13:06:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvlI2-0006iP-Gr for bug-gnulib@gnu.org; Sat, 02 Jan 2021 13:06:10 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.22]:30023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvlHx-0000Pa-Uw for bug-gnulib@gnu.org; Sat, 02 Jan 2021 13:06:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1609610762; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From: Subject:Sender; bh=/IxfsZn6yjnhIzrloBb2mfOLvuht84fqgvuT9RJrT90=; b=k+YuewAb+CR21dRzTQdBZlYGweV26u6WsqIw+3oUNeylIiAOaBpyBn1FRV21x6MZnu 8Sn+bqmJMxxHrWSKgRKjFLctXkAJqbSd+DqYZTh6oOWcrHpUL6d5963P9EBCzakL37sE c5aIGU5dUT7z+yljHoWefPd4mOqoittl/3mXGvqzPq+5nvK87ICtuXeaV0NQITBPcxOe MalHFNTQJGTECMHM4OGn1zjsIPYGgGSBAQjX5ppPMJQ1bZ45k8cWOFrd5YXYdmbAlbXg KM5UwdbBTlHwZTSKDV2d0x+haNbFp5Fi4NcQuQtzrtAxB+UrELZGcBUvmchQ+GYlNRzO 1Vjg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6f3z/s=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.10.7 DYNA|AUTH) with ESMTPSA id e012d5x02I61Zs0 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sat, 2 Jan 2021 19:06:01 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: utimens: Fix test failures on macOS Date: Sat, 02 Jan 2021 19:06:01 +0100 Message-ID: <4400843.Qz4ycSGf0P@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart6881678.hHsBJC1A3W" Content-Transfer-Encoding: 7Bit Received-SPF: none client-ip=85.215.255.22; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin =?ISO-8859-1?Q?Storsj=F6?= Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This is a multi-part message in MIME format. --nextPart6881678.hHsBJC1A3W Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" On macOS 10.13, I'm seeing test failures: =46AIL: test-futimens =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2E./../gltests/test-futimens.h:170: assertion 'ctime_compare (&st3, &st2) = < 0' failed =46AIL test-futimens (exit status: 134) =46AIL: test-utimens =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2E./../gltests/test-utimens.h:149: assertion 'ctime_compare (&st3, &st2) <= 0' failed =46AIL test-utimens (exit status: 134) I looked at the file timestamps using coreutils' 'stat' program. These two failures are apparently caused by st_ctime being unchanged when you ask for an st_atime change using utimensat(). I think this is not worth working around, because every read access on a file causes st_atime to change witho= ut st_ctime changing. Another test failure, then: =2E/test-utimens.h:164: assertion 'func (BASE "link/", NULL) =3D=3D -1' fai= led Abort trap: 6 2021-01-02 Bruno Haible utimens: Fix test failure on macOS 10.13. * lib/utimens.c (fdutimens): Before calling utimensat, recognize a filename ending in a slash that does not point to a directory. 2021-01-02 Bruno Haible utimens: Avoid test failures on macOS 10.13. Reported by Martin Storsj=F6 in . * tests/test-utimens-common.h (check_ctime): Define to -1 on macOS. * tests/test-utimens.h (test_utimens): Don't expect a ctime change when only the atime is requested to change. * tests/test-futimens.h (test_futimens): Likewise. * tests/test-lutimens.h (test_lutimens): Likewise. --nextPart6881678.hHsBJC1A3W Content-Disposition: attachment; filename="0001-utimens-Avoid-test-failures-on-macOS-10.13.patch" Content-Transfer-Encoding: quoted-printable Content-Type: text/x-patch; charset="UTF-8"; name="0001-utimens-Avoid-test-failures-on-macOS-10.13.patch" =46rom 3b123860925185b7ba330e1f24a7a9389a955f9b Mon Sep 17 00:00:00 2001 =46rom: Bruno Haible Date: Sat, 2 Jan 2021 18:57:10 +0100 Subject: [PATCH 1/2] utimens: Avoid test failures on macOS 10.13. MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Reported by Martin Storsj=C3=B6 in . * tests/test-utimens-common.h (check_ctime): Define to -1 on macOS. * tests/test-utimens.h (test_utimens): Don't expect a ctime change when only the atime is requested to change. * tests/test-futimens.h (test_futimens): Likewise. * tests/test-lutimens.h (test_lutimens): Likewise. =2D-- ChangeLog | 11 +++++++++++ tests/test-futimens.h | 2 +- tests/test-lutimens.h | 2 +- tests/test-utimens-common.h | 3 +++ tests/test-utimens.h | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d95f49..73d1139 100644 =2D-- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2021-01-02 Bruno Haible =20 + utimens: Avoid test failures on macOS 10.13. + Reported by Martin Storsj=C3=B6 in + . + * tests/test-utimens-common.h (check_ctime): Define to -1 on macOS. + * tests/test-utimens.h (test_utimens): Don't expect a ctime change when + only the atime is requested to change. + * tests/test-futimens.h (test_futimens): Likewise. + * tests/test-lutimens.h (test_lutimens): Likewise. + +2021-01-02 Bruno Haible + renameatu: Fix test failures on macOS. Reported by Martin Storsj=C3=B6 in . diff --git a/tests/test-futimens.h b/tests/test-futimens.h index 6a17013..31ff900 100644 =2D-- a/tests/test-futimens.h +++ b/tests/test-futimens.h @@ -166,7 +166,7 @@ test_futimens (int (*func) (int, struct timespec const = *), ASSERT (get_stat_atime_ns (&st2) =3D=3D 0); ASSERT (st3.st_mtime =3D=3D st2.st_mtime); ASSERT (get_stat_mtime_ns (&st3) =3D=3D get_stat_mtime_ns (&st2)); =2D if (check_ctime) + if (check_ctime > 0) ASSERT (ctime_compare (&st3, &st2) < 0); } =20 diff --git a/tests/test-lutimens.h b/tests/test-lutimens.h index f6d5586..589c9cf 100644 =2D-- a/tests/test-lutimens.h +++ b/tests/test-lutimens.h @@ -194,7 +194,7 @@ test_lutimens (int (*func) (char const *, struct timesp= ec const *), bool print) } ASSERT (st3.st_mtime =3D=3D st2.st_mtime); ASSERT (get_stat_mtime_ns (&st3) =3D=3D get_stat_mtime_ns (&st2)); =2D if (check_ctime) + if (check_ctime > 0) ASSERT (ctime_compare (&st3, &st2) < 0); } =20 diff --git a/tests/test-utimens-common.h b/tests/test-utimens-common.h index 5861667..3d665ef 100644 =2D-- a/tests/test-utimens-common.h +++ b/tests/test-utimens-common.h @@ -55,6 +55,9 @@ enum { properly tracked change time. See . */ # define check_ctime 0 +# elif defined __APPLE__ && defined __MACH__ +/* On macOS, the ctime is not updated when only the st_atime changes. */ +# define check_ctime -1 # else # define check_ctime 1 # endif diff --git a/tests/test-utimens.h b/tests/test-utimens.h index c3c7029..9273fd0 100644 =2D-- a/tests/test-utimens.h +++ b/tests/test-utimens.h @@ -145,7 +145,7 @@ test_utimens (int (*func) (char const *, struct timespe= c const *), bool print) ASSERT (get_stat_atime_ns (&st2) =3D=3D 0); ASSERT (st3.st_mtime =3D=3D st2.st_mtime); ASSERT (get_stat_mtime_ns (&st3) =3D=3D get_stat_mtime_ns (&st2)); =2D if (check_ctime) + if (check_ctime > 0) ASSERT (ctime_compare (&st3, &st2) < 0); } =20 =2D-=20 2.7.4 --nextPart6881678.hHsBJC1A3W Content-Disposition: attachment; filename="0002-utimens-Fix-test-failure-on-macOS-10.13.patch" Content-Transfer-Encoding: quoted-printable Content-Type: text/x-patch; charset="UTF-8"; name="0002-utimens-Fix-test-failure-on-macOS-10.13.patch" =46rom 86c8ff740b64f3724de20d71dca481bef30b18dd Mon Sep 17 00:00:00 2001 =46rom: Bruno Haible Date: Sat, 2 Jan 2021 18:59:12 +0100 Subject: [PATCH 2/2] utimens: Fix test failure on macOS 10.13. * lib/utimens.c (fdutimens): Before calling utimensat, recognize a filename ending in a slash that does not point to a directory. =2D-- ChangeLog | 6 ++++++ lib/utimens.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 73d1139..5087bf4 100644 =2D-- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2021-01-02 Bruno Haible =20 + utimens: Fix test failure on macOS 10.13. + * lib/utimens.c (fdutimens): Before calling utimensat, recognize a + filename ending in a slash that does not point to a directory. + +2021-01-02 Bruno Haible + utimens: Avoid test failures on macOS 10.13. Reported by Martin Storsj=C3=B6 in . diff --git a/lib/utimens.c b/lib/utimens.c index 5bbae05..9f9c30a 100644 =2D-- a/lib/utimens.c +++ b/lib/utimens.c @@ -246,6 +246,20 @@ fdutimens (int fd, char const *file, struct timespec c= onst timespec[2]) # if HAVE_UTIMENSAT if (fd < 0) { +# if defined __APPLE__ && defined __MACH__ + size_t len =3D strlen (file); + if (len > 0 && file[len - 1] =3D=3D '/') + { + struct stat statbuf; + if (stat (file, &statbuf) < 0) + return -1; + if (!S_ISDIR (statbuf.st_mode)) + { + errno =3D ENOTDIR; + return -1; + } + } +# endif result =3D utimensat (AT_FDCWD, file, ts, 0); # ifdef __linux__ /* Work around a kernel bug: =2D-=20 2.7.4 --nextPart6881678.hHsBJC1A3W--