[llvm] [Support][test] Fix OpenDirectoryAsFileForRead test on AIX and z/OS (PR #216241)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 21:12:20 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Daniel Chen (DanielCChen)

<details>
<summary>Changes</summary>

Commit 9c7ba7b1d12e ("[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.

---
Full diff: https://github.com/llvm/llvm-project/pull/216241.diff


1 Files Affected:

- (modified) llvm/unittests/Support/Path.cpp (+4) 


``````````diff
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); });

``````````

</details>


https://github.com/llvm/llvm-project/pull/216241


More information about the llvm-commits mailing list