Skip to content

Conversation

cmtice
Copy link
Contributor

@cmtice cmtice commented Sep 10, 2025

Replace sub-shell for-loops with python calls so this test can run in the lit internal shell. This is part of our work migrating to use the internal shell as the default for lit tests.

Replace sub-shell for-loops with python calls so this test can run
in the lit internal shell. This is part of our work migrating
to use the internal shell as the default for lit tests.
@llvmbot
Copy link
Member

llvmbot commented Sep 10, 2025

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

Author: None (cmtice)

Changes

Replace sub-shell for-loops with python calls so this test can run in the lit internal shell. This is part of our work migrating to use the internal shell as the default for lit tests.


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

1 Files Affected:

  • (modified) compiler-rt/test/fuzzer/focus-function.test (+4-5)
diff --git a/compiler-rt/test/fuzzer/focus-function.test b/compiler-rt/test/fuzzer/focus-function.test
index aa15692db358d..b9f0408cfa6d0 100644
--- a/compiler-rt/test/fuzzer/focus-function.test
+++ b/compiler-rt/test/fuzzer/focus-function.test
@@ -1,8 +1,7 @@
 # Tests -focus_function
 #
 # TODO: don't require linux.
-# Requires full shell support for the `for` loop syntax.
-# REQUIRES: shell, linux
+# REQUIRES: linux
 UNSUPPORTED: target=aarch64{{.*}}
 
 RUN: %cpp_compiler %S/OnlySomeBytesTest.cpp -o %t-exe
@@ -22,9 +21,9 @@ FOCUS_F0: INFO: 0/1 inputs touch the focus function
 RUN: rm -rf %t-corpus
 RUN: mkdir %t-corpus
 # ABC triggers the focus function, others don't.
-RUN: echo ABC$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/ABC
-RUN: echo AXY$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/AXY
-RUN: echo ABX$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/ABX
+RUN: %python -c 'x_str = "ABC" + "x" * 2048; print(x_str)' > %t-corpus/ABC
+RUN: %python -c 'x_str = "AXY" + "x" * 2048; print(x_str)' > %t-corpus/AXY
+RUN: %python -c 'x_str = "ABX" + "x" * 2048; print(x_str)' > %t-corpus/ABX
 
 RUN: %run %t-exe -runs=10000 -focus_function=f0 %t-corpus 2>&1 | FileCheck %s --check-prefix=CORPUS_1_3
 CORPUS_1_3: INFO: 1/3 inputs touch the focus function

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

This is way cleaner than the bashisms actually. I forgot about multiplying strings in Python.

@cmtice cmtice merged commit 14cf515 into llvm:main Sep 11, 2025
9 checks passed
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.

4 participants