[llvm] [Support][test] Fix OpenDirectoryAsFileForRead test on AIX and z/OS (PR #216241)
Daniel Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 14 07:37:31 PDT 2026
https://github.com/DanielCChen updated https://github.com/llvm/llvm-project/pull/216241
>From d2983e082141b8b2fbbf71c1b2952bd6fe9b7a5f Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Fri, 14 Aug 2026 00:09:01 -0400
Subject: [PATCH 1/2] [Support][test] Fix OpenDirectoryAsFileForRead test on
AIX and z/OS
---
llvm/unittests/Support/Path.cpp | 4 ++++
1 file changed, 4 insertions(+)
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); });
>From 32123bed31e364be0ef07a1ce1c2e7733c1739a6 Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Fri, 14 Aug 2026 10:36:59 -0400
Subject: [PATCH 2/2] To address review comments.
---
llvm/unittests/Support/Path.cpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 6e0cf878ac664..31599f6152e92 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -2040,11 +2040,7 @@ TEST_F(FileSystemTest, SetLastAccessAndModificationTimeDirectory) {
TEST_F(FileSystemTest, OpenDirectoryAsFileForRead) {
std::string Buf(5, '?');
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.
+#if defined(_WIN32) || defined(_AIX) || defined(__MVS__)
EXPECT_EQ(errorToErrorCode(FD.takeError()), errc::is_a_directory);
#else
ASSERT_THAT_EXPECTED(FD, Succeeded());
More information about the llvm-commits
mailing list