-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Fuzzer] make big-file-copy.test work with the internal shell #168658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fuzzer] make big-file-copy.test work with the internal shell #168658
Conversation
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.
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Aiden Grossman (boomanaiden154) ChangesThis 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:
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})"
|
🐧 Linux x64 Test Results
|
| 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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})" |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.
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.