[libcxx-commits] [libcxx] b8c12af - [SystemZ][z/OS] Fix handling of dirs with filesystem tests

Muiez Ahmed via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 13 08:02:36 PST 2021


Author: Muiez Ahmed
Date: 2021-12-13T11:02:23-05:00
New Revision: b8c12af9dd761c5118b70b1e2952e6c1a63628a8

URL: https://github.com/llvm/llvm-project/commit/b8c12af9dd761c5118b70b1e2952e6c1a63628a8
DIFF: https://github.com/llvm/llvm-project/commit/b8c12af9dd761c5118b70b1e2952e6c1a63628a8.diff

LOG: [SystemZ][z/OS] Fix handling of dirs with filesystem tests

The aim of this patch is to fix the post processing that is happening on the temporary test directories upon scope exit. In particular, ~scoped_test_env aims to chmod and remove the temporary directories; however,

bad symlinks are followed and we get "No such file or directory". FIX: use find as alternative to chmod and avoid -follow option.
Attempting to remove read-only files on z/OS prompts a message asking for confirmation. FIX: use the -f option to delete read-only files immediately without asking for confirmation.
Some libcxx tests such as libcxx/test/std/input.output/filesystems/cl ass.directory_entry/directory_entry.cons/path.pass.cpp set the dir permissions to none. In turn, recursively doing chmod (-R) does not set the file permissions needed to be able to remove the dir on z/OS only. FIX: use find as alternative to chmod -R, which does not run into this issue on z/OS.

Differential Revision: https://reviews.llvm.org/D108326

Added: 
    

Modified: 
    libcxx/test/support/filesystem_test_helper.h

Removed: 
    


################################################################################
diff  --git a/libcxx/test/support/filesystem_test_helper.h b/libcxx/test/support/filesystem_test_helper.h
index ea645e28e285c..00f4701e881af 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -138,12 +138,18 @@ struct scoped_test_env
         std::string cmd = "rmdir /s /q " + test_root.string();
         int ret = std::system(cmd.c_str());
         assert(ret == 0);
+#else
+#if defined(__MVS__)
+        // The behaviour of chmod -R on z/OS prevents recursive
+        // permission change for directories that do not have read permission.
+        std::string cmd = "find  " + test_root.string() + " -exec chmod 777 {} \\;";
 #else
         std::string cmd = "chmod -R 777 " + test_root.string();
+#endif // defined(__MVS__)
         int ret = std::system(cmd.c_str());
         assert(ret == 0);
 
-        cmd = "rm -r " + test_root.string();
+        cmd = "rm -rf " + test_root.string();
         ret = std::system(cmd.c_str());
         assert(ret == 0);
 #endif


        


More information about the libcxx-commits mailing list