[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] renameatu: work around macOS 11.2 renameatx_np bug
From: |
Bruno Haible |
Subject: |
Re: [PATCH] renameatu: work around macOS 11.2 renameatx_np bug |
Date: |
Sat, 27 Mar 2021 17:50:38 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; ) |
> +2021-03-24 Paul Eggert <eggert@cs.ucla.edu>
> +
> + renameatu: work around macOS 11.2 renameatx_np bug
> + * lib/renameatu.c (renameatu) [RENAME_EXCL]: Use lstatat test here too.
It's useful to add a unit test for this bug, in case it occurs on other
platforms as well. I know that the coreutils tests 'tests/mv/force' and
'tests/mv/into-self-4' would fail when this bug occurs, but since renameatu
is a gnulib module, it should better contain all its self-tests.
2021-03-27 Bruno Haible <bruno@clisp.org>
renameatu tests: Add unit test for bug found on macOS.
* tests/test-renameatu.c (main): Add test for identical rename with
RENAME_NOREPLACE.
diff --git a/tests/test-renameatu.c b/tests/test-renameatu.c
index db8b56a..28d1470 100644
--- a/tests/test-renameatu.c
+++ b/tests/test-renameatu.c
@@ -189,9 +189,19 @@ main (void)
/* Finally, make sure we cannot overwrite existing files. */
ASSERT (close (creat (BASE "sub2/file", 0600)) == 0);
errno = 0;
+ ASSERT ((renameatu (dfd, BASE "sub2/file", dfd, BASE "sub2/file",
+ RENAME_NOREPLACE)
+ == -1)
+ && errno == EEXIST);
+ errno = 0;
+ ASSERT ((renameatu (dfd, BASE "sub2", dfd, BASE "sub2", RENAME_NOREPLACE)
+ == -1)
+ && errno == EEXIST);
+ errno = 0;
ASSERT ((renameatu (dfd, BASE "sub2", dfd, BASE "sub1", RENAME_NOREPLACE)
== -1)
&& errno == EEXIST);
+ errno = 0;
ASSERT ((renameatu (dfd, BASE "sub2/file", dfd, BASE "17", RENAME_NOREPLACE)
== -1)
&& errno == EEXIST);