Skip to content

Conversation

@boomanaiden154
Copy link
Contributor

This patch uses several shell features not supported by the internal shell, such as $? to get the exit code of a command, and exit. This patch adjusts the test to work with the internal shell by using bash to run the actual command with a zero exit code to ensure the file is deleted, and python to propagate the exit code up to lit.

This patch uses several shell features not supported by the internal shell,
such as $? to get the exit code of a command, and exit. This patch adjusts
the test to work with the internal shell by using bash to run the actual command
with a zero exit code to ensure the file is deleted, and python to propagate
the exit code up to lit.
@llvmbot
Copy link
Member

llvmbot commented Nov 19, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Aiden Grossman (boomanaiden154)

Changes

This patch uses several shell features not supported by the internal shell, such as $? to get the exit code of a command, and exit. This patch adjusts the test to work with the internal shell by using bash to run the actual command with a zero exit code to ensure the file is deleted, and python to propagate the exit code up to lit.


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

1 Files Affected:

  • (modified) compiler-rt/test/fuzzer/big-file-copy.test (+2-2)
diff --git a/compiler-rt/test/fuzzer/big-file-copy.test b/compiler-rt/test/fuzzer/big-file-copy.test
index 9565ed4e0bca2..3008933794ae1 100644
--- a/compiler-rt/test/fuzzer/big-file-copy.test
+++ b/compiler-rt/test/fuzzer/big-file-copy.test
@@ -1,6 +1,6 @@
 REQUIRES: darwin
 UNSUPPORTED: ios
 RUN: %cpp_compiler %S/BigFileCopy.cpp -o %t
-RUN: %run %t -runs=1 -rss_limit_mb=4096 2>big-file-out.txt; result=$?
+RUN: bash -c "%run %t -runs=1 -rss_limit_mb=4096 2>big-file-out.txt; echo -n $? > %t.result"
 RUN: %run rm -f big-file.txt big-file-out.txt
-RUN: (exit $result)
+RUN: %python -c "import sys; sys.exit(%{readfile:%t.result})"

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 5820 tests passed
  • 1319 tests skipped

UNSUPPORTED: ios
RUN: %cpp_compiler %S/BigFileCopy.cpp -o %t
RUN: %run %t -runs=1 -rss_limit_mb=4096 2>big-file-out.txt; result=$?
RUN: bash -c "%run %t -runs=1 -rss_limit_mb=4096 2>big-file-out.txt; echo -n $? > %t.result"
Copy link
Contributor

Choose a reason for hiding this comment

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

This will no longer work with an external shell (same reason as the other test: outer shell expands $? before inner shell has executed anything), please make the internal shell the default at the same time you merge this.

Quite unexpectedly with an external shell this writes an empty file and thus below will execute sys.exit() (without passing a return code) which will always pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to using single quotes so this also works with the external shell.

RUN: bash -c "%run %t -runs=1 -rss_limit_mb=4096 2>big-file-out.txt; echo -n $? > %t.result"
RUN: %run rm -f big-file.txt big-file-out.txt
RUN: (exit $result)
RUN: %python -c "import sys; sys.exit(%{readfile:%t.result})"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is sort of ridiculous, no? If we are going out to bash anyway, could we do something like:

RUN: bash -c "%run %t -runs=1 -rss_limit_mb=4096 2>big-file-out.txt; result=$?; \
RUN: %run rm -f big-file.txt big-file-out.txt && exit $result"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Updated to use something more similar to what you proposed to avoid all the indirection through files that is mostly pointless.

@boomanaiden154 boomanaiden154 merged commit ed0c36c into llvm:main Nov 19, 2025
8 of 9 checks passed
@boomanaiden154 boomanaiden154 deleted the fuzzer-internal-shell-darwin branch November 19, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants