[Support][test] Fix OpenDirectoryAsFileForRead test on AIX and z/OS - #216241
Conversation
|
@llvm/pr-subscribers-llvm-support Author: Daniel Chen (DanielCChen) ChangesCommit 9c7ba7b ("[AIX][SystemZ][Support] Check if file is dir on Add a Full diff: https://github.com/llvm/llvm-project/pull/216241.diff 1 Files Affected:
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index b63ab426bb080..6e0cf878ac664 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -2042,6 +2042,10 @@ TEST_F(FileSystemTest, OpenDirectoryAsFileForRead) {
Expected<fs::file_t> FD = fs::openNativeFileForRead(TestDirectory);
#ifdef _WIN32
EXPECT_EQ(errorToErrorCode(FD.takeError()), errc::is_a_directory);
+#elif defined(_AIX) || defined(__MVS__)
+ // On AIX and z/OS, open() on a directory with O_RDONLY fails immediately
+ // with EISDIR, unlike Linux where open() succeeds and read() returns EISDIR.
+ EXPECT_EQ(errorToErrorCode(FD.takeError()), errc::is_a_directory);
#else
ASSERT_THAT_EXPECTED(FD, Succeeded());
scope_exit Close([&] { fs::closeFile(*FD); });
|
perry-ca
left a comment
There was a problem hiding this comment.
LGTM
@hubert-reinterpretcast had cherry picked the original into llvm 23. You probably need to do the same.
|
/cherry-pick 828d2d7 |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/200/builds/35340 Here is the relevant piece of the build log for the reference |
|
/pull-request #216342 |
…lvm#216241) Commit 9c7ba7b ("[AIX][SystemZ][Support] Check if file is dir on open instead of read") moved the `fstat`/`EISDIR` check from `readNativeFile()` to `openNativeFileForRead()` on AIX and z/OS. This means `openNativeFileForRead()` now returns `EISDIR` immediately on those platforms, but the test `FileSystemTest.OpenDirectoryAsFileForRead` was not updated to match, causing it to fail at the `ASSERT_THAT_EXPECTED(FD, Succeeded())` assertion. Add a `#elif defined(_AIX) || defined(__MVS__)` branch to the test that expects the error to be returned from `openNativeFileForRead()` rather than from `readNativeFile()`, consistent with the behavior introduced by that commit.
…lvm#216241) Commit 9c7ba7b ("[AIX][SystemZ][Support] Check if file is dir on open instead of read") moved the `fstat`/`EISDIR` check from `readNativeFile()` to `openNativeFileForRead()` on AIX and z/OS. This means `openNativeFileForRead()` now returns `EISDIR` immediately on those platforms, but the test `FileSystemTest.OpenDirectoryAsFileForRead` was not updated to match, causing it to fail at the `ASSERT_THAT_EXPECTED(FD, Succeeded())` assertion. Add a `#elif defined(_AIX) || defined(__MVS__)` branch to the test that expects the error to be returned from `openNativeFileForRead()` rather than from `readNativeFile()`, consistent with the behavior introduced by that commit. (cherry picked from commit 828d2d7)
Commit 9c7ba7b ("[AIX][SystemZ][Support] Check if file is dir on
open instead of read") moved the
fstat/EISDIRcheck fromreadNativeFile()toopenNativeFileForRead()on AIX and z/OS. Thismeans
openNativeFileForRead()now returnsEISDIRimmediately on thoseplatforms, but the test
FileSystemTest.OpenDirectoryAsFileForReadwasnot updated to match, causing it to fail at the
ASSERT_THAT_EXPECTED(FD, Succeeded())assertion.Add a
#elif defined(_AIX) || defined(__MVS__)branch to the test thatexpects the error to be returned from
openNativeFileForRead()ratherthan from
readNativeFile(), consistent with the behavior introduced bythat commit.