On Wed, 22 Jun 2022 at 08:02, Alexandre Oliva via Libstdc++ <libstd...@gcc.gnu.org> wrote: > > Hello, Sebastian, > > On Jun 22, 2022, Sebastian Huber <sebastian.hu...@embedded-brains.de> wrote: > > > On 22/06/2022 08:24, Alexandre Oliva via Libstdc++ wrote: > >> rtems6's rename() implementation errors with EEXIST when the rename-to > >> filename exists, even when renaming a file to itself or when renaming > >> a nonexisting file. Adjust expectations. > >> > >> Regstrapped on x86_64-linux-gnu, also tested with a cross to > >> aarch64-rtems6. Ok to install? > >> > >> PS:https://devel.rtems.org/ticket/2169 doesn't seem to suggest plans to > >> change behavior so as to comply with POSIX. > > > I would not adjust the test case to cope with systems which are not in > > line with POSIX. > > My understanding is that the libstdc++ testsuite is not meant to test > for POSIX conformance, but for conformance with the C++ language > standards. > > C++ inherits rename from C, and C says the behavior is implementation > defined if the new name already exists.
std::filesystem::rename is explicitly specified in terms of POSIX rename, not C rename. POSIX says: "If the old argument and the new argument resolve to either the same existing directory entry or different directory entries for the same existing file, rename() shall return successfully and perform no other action." and "If the link named by the new argument exists, it shall be removed and old renamed to new." So I agree with Sebastian, the tests are correct. Instead, the implementation of std::filesystem::rename should have a special-case for rtems (and maybe other targets) that implements the POSIX rename semantics if calling ::rename isn't good enough. > > RTEMS is thus comformant with the requirements from C (and thus C++), > and it is therefore reasonable for libstdc++'s testsuite to accept > RTEMS' behavior as such. > > > That said, because libstdc++ tests are all-or-nothing, perhaps it would > make sense to have a separate test for strict POSIX conformance in > rename, XFAILed on RTEMS targets. How about that? > > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > Disinformation flourishes because many people care deeply about injustice > but very few check the facts. Ask me about <https://stallmansupport.org> >