Skip to content

[Support][test] Fix OpenDirectoryAsFileForRead test on AIX and z/OS - #216241

Merged
DanielCChen merged 2 commits into
llvm:mainfrom
DanielCChen:daniel_tc_fix
Aug 14, 2026
Merged

[Support][test] Fix OpenDirectoryAsFileForRead test on AIX and z/OS#216241
DanielCChen merged 2 commits into
llvm:mainfrom
DanielCChen:daniel_tc_fix

Conversation

@DanielCChen

Copy link
Copy Markdown
Contributor

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.

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-support

Author: Daniel Chen (DanielCChen)

Changes

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.


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

1 Files Affected:

  • (modified) llvm/unittests/Support/Path.cpp (+4)
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); });

Comment thread llvm/unittests/Support/Path.cpp Outdated

@perry-ca perry-ca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hubert-reinterpretcast had cherry picked the original into llvm 23. You probably need to do the same.

@DanielCChen
DanielCChen merged commit 828d2d7 into llvm:main Aug 14, 2026
10 of 12 checks passed
@amy-kwan amy-kwan added this to the LLVM 23.x Release milestone Aug 14, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in LLVM Release Status Aug 14, 2026
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in LLVM Release Status Aug 14, 2026
@amy-kwan

Copy link
Copy Markdown
Member

/cherry-pick 828d2d7

@llvm-ci

llvm-ci commented Aug 14, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-dbg-bootstrap-build running on libc-x86_64-debian while building llvm at step 4 "annotate".

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
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
-- Skipping test for 'libc.src.string.memset_x86_64_opt_avx512' insufficient host cpu features 'AVX512F'
-- Skipping test for 'libc.src.strings.bcmp_x86_64_opt_avx512' insufficient host cpu features 'AVX512BW'
-- Skipping test for 'libc.src.strings.bzero_x86_64_opt_avx512' insufficient host cpu features 'AVX512F'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins
[4/5] cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins && /usr/bin/cmake --build /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/ --target check-libc --config Debug
[0/1] Running libc tests via lit
-- Testing: 3830 tests, 32 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: libc :: src/sys/statfs/linux/libc.test.src.sys.statfs.linux.statfs_test.__build__ (2869 of 3830)
******************** TEST 'libc :: src/sys/statfs/linux/libc.test.src.sys.statfs.linux.statfs_test.__build__' FAILED ********************
�[32m[==========] �[0mRunning 2 tests from 1 test suite.
�[32m[ RUN      ] �[0mLlvmLibcSysStatfsTest.StatfsBasic
�[32m[       OK ] �[0mLlvmLibcSysStatfsTest.StatfsBasic (12 us)
�[32m[ RUN      ] �[0mLlvmLibcSysStatfsTest.StatfsInvalidPath
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/test/src/sys/statfs/linux/statfs_test.cpp:53: FAILURE
Failed to match LIBC_NAMESPACE::rmdir(TEST_DIR) against Succeeds(0).
Expected return value to be equal to 0 but got -1.
Expected errno to be equal to 0(0) but got ENOENT(2).
�[31m[  FAILED  ] �[0mLlvmLibcSysStatfsTest.StatfsInvalidPath
Ran 2 tests.  PASS: 1  FAIL: 1

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
********************
Failed Tests (1):
  libc :: src/sys/statfs/linux/libc.test.src.sys.statfs.linux.statfs_test.__build__


Testing Time: 3.53s

Total Discovered Tests: 3830
  Passed: 3829 (99.97%)
  Failed:    1 (0.03%)
FAILED: libc/test/CMakeFiles/check-libc /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/test/CMakeFiles/check-libc 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/test && /usr/bin/python3 /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/./bin/llvm-lit -sv /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/test
ninja: build stopped: subcommand failed.
FAILED: runtimes/CMakeFiles/check-libc /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/CMakeFiles/check-libc 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins && /usr/bin/cmake --build /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/ --target check-libc --config Debug
ninja: build stopped: subcommand failed.
['ninja', 'check-libc'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 181, in step
    yield
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 151, in main
    run_command(['ninja', 'check-libc'])
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 196, in run_command
Step 7 (check-libc) failure: check-libc (failure)
...
-- Skipping test for 'libc.src.string.memset_x86_64_opt_avx512' insufficient host cpu features 'AVX512F'
-- Skipping test for 'libc.src.strings.bcmp_x86_64_opt_avx512' insufficient host cpu features 'AVX512BW'
-- Skipping test for 'libc.src.strings.bzero_x86_64_opt_avx512' insufficient host cpu features 'AVX512F'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins
[4/5] cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins && /usr/bin/cmake --build /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/ --target check-libc --config Debug
[0/1] Running libc tests via lit
-- Testing: 3830 tests, 32 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: libc :: src/sys/statfs/linux/libc.test.src.sys.statfs.linux.statfs_test.__build__ (2869 of 3830)
******************** TEST 'libc :: src/sys/statfs/linux/libc.test.src.sys.statfs.linux.statfs_test.__build__' FAILED ********************
�[32m[==========] �[0mRunning 2 tests from 1 test suite.
�[32m[ RUN      ] �[0mLlvmLibcSysStatfsTest.StatfsBasic
�[32m[       OK ] �[0mLlvmLibcSysStatfsTest.StatfsBasic (12 us)
�[32m[ RUN      ] �[0mLlvmLibcSysStatfsTest.StatfsInvalidPath
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/test/src/sys/statfs/linux/statfs_test.cpp:53: FAILURE
Failed to match LIBC_NAMESPACE::rmdir(TEST_DIR) against Succeeds(0).
Expected return value to be equal to 0 but got -1.
Expected errno to be equal to 0(0) but got ENOENT(2).
�[31m[  FAILED  ] �[0mLlvmLibcSysStatfsTest.StatfsInvalidPath
Ran 2 tests.  PASS: 1  FAIL: 1

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
********************
Failed Tests (1):
  libc :: src/sys/statfs/linux/libc.test.src.sys.statfs.linux.statfs_test.__build__


Testing Time: 3.53s

Total Discovered Tests: 3830
  Passed: 3829 (99.97%)
  Failed:    1 (0.03%)
FAILED: libc/test/CMakeFiles/check-libc /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/test/CMakeFiles/check-libc 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/test && /usr/bin/python3 /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/./bin/llvm-lit -sv /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/test
ninja: build stopped: subcommand failed.
FAILED: runtimes/CMakeFiles/check-libc /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/CMakeFiles/check-libc 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins && /usr/bin/cmake --build /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/ --target check-libc --config Debug
ninja: build stopped: subcommand failed.
['ninja', 'check-libc'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 181, in step
    yield
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 151, in main
    run_command(['ninja', 'check-libc'])
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 196, in run_command

@llvmbot

llvmbot commented Aug 14, 2026

Copy link
Copy Markdown
Member

/pull-request #216342

zhangweize9-cyber pushed a commit to zhangweize9-cyber/llvm-project that referenced this pull request Aug 16, 2026
…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.
dyung pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 21, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

5 participants