[llvm-branch-commits] [llvm] release/23.x: [Support][test] Fix OpenDirectoryAsFileForRead test on AIX and z/OS (#216241) (PR #216342)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 14 08:45:00 PDT 2026


https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/216342

Backport 828d2d7fb65a9cd5946b347ad5173e3bdb21387d

Requested by: @amy-kwan

>From 2fd7e1d6190eb63bfec747264d334dad39db6a26 Mon Sep 17 00:00:00 2001
From: Daniel Chen <cdchen at ca.ibm.com>
Date: Fri, 14 Aug 2026 11:33:43 -0400
Subject: [PATCH] [Support][test] Fix OpenDirectoryAsFileForRead test on AIX
 and z/OS (#216241)

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.

(cherry picked from commit 828d2d7fb65a9cd5946b347ad5173e3bdb21387d)
---
 llvm/unittests/Support/Path.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index b63ab426bb080..31599f6152e92 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -2040,7 +2040,7 @@ TEST_F(FileSystemTest, SetLastAccessAndModificationTimeDirectory) {
 TEST_F(FileSystemTest, OpenDirectoryAsFileForRead) {
   std::string Buf(5, '?');
   Expected<fs::file_t> FD = fs::openNativeFileForRead(TestDirectory);
-#ifdef _WIN32
+#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-branch-commits mailing list