[compiler-rt] c7a9be8 - [XRay] Rewrite tests to not use subshells

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 07:08:12 PST 2025


Author: Aiden Grossman
Date: 2025-11-17T15:08:03Z
New Revision: c7a9be81be9a08a4be208a89fa514ff0fe4de915

URL: https://github.com/llvm/llvm-project/commit/c7a9be81be9a08a4be208a89fa514ff0fe4de915
DIFF: https://github.com/llvm/llvm-project/commit/c7a9be81be9a08a4be208a89fa514ff0fe4de915.diff

LOG: [XRay] Rewrite tests to not use subshells

So that they will actually function with the internal shell.

Added: 
    

Modified: 
    compiler-rt/test/xray/TestCases/Posix/basic-filtering.cpp
    compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
    compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp
    compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp
    compiler-rt/test/xray/TestCases/Posix/fdr-mode.cpp
    compiler-rt/test/xray/TestCases/Posix/fork_basic_logging.cpp
    compiler-rt/test/xray/TestCases/Posix/profiling-multi-threaded.cpp
    compiler-rt/test/xray/TestCases/Posix/profiling-single-threaded.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/xray/TestCases/Posix/basic-filtering.cpp b/compiler-rt/test/xray/TestCases/Posix/basic-filtering.cpp
index 47e7a0710131d..7b46fe29a00e3 100644
--- a/compiler-rt/test/xray/TestCases/Posix/basic-filtering.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/basic-filtering.cpp
@@ -8,8 +8,9 @@
 // RUN:     xray_naive_log_func_duration_threshold_us=1000 \
 // RUN:     xray_naive_log_max_stack_depth=2" %run %t 2>&1 | \
 // RUN:     FileCheck %s
+// RUN: ls basic-filtering-* | head -1 | tr -d '\n' > %t.log
 // RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t \
-// RUN:     "`ls basic-filtering-* | head -1`" | \
+// RUN:     "%{readfile:%t.log}" | \
 // RUN:     FileCheck %s --check-prefix TRACE
 // RUN: rm -f basic-filtering-*
 //
@@ -18,8 +19,9 @@
 // RUN:     xray_logfile_base=basic-filtering-" \
 // RUN: env XRAY_BASIC_OPTIONS="func_duration_threshold_us=1000 max_stack_depth=2" \
 // RUN:     %run %t 2>&1 | FileCheck %s
+// RUN: ls basic-filtering-* | head -1 | tr -d '\n' > %t.log
 // RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t \
-// RUN:     "`ls basic-filtering-* | head -1`" | \
+// RUN:     "%{readfile:%t.log}" | \
 // RUN:     FileCheck %s --check-prefix TRACE
 // RUN: rm -f basic-filtering-*
 

diff  --git a/compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp b/compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
index eb76d5f95b6cd..954c7ef9626d8 100644
--- a/compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
@@ -5,7 +5,8 @@
 // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testlib.so -Wl,-rpath,%t -o %t/main.o
 
 // RUN: env XRAY_OPTIONS="patch_premain=false,xray_mode=xray-basic,xray_logfile_base=basic-mode-dso-,verbosity=1" XRAY_BASIC_OPTIONS="func_duration_threshold_us=0" %run %t/main.o 2>&1 | FileCheck %s
-// RUN: %llvm_xray account --format=csv --sort=funcid "`ls basic-mode-dso-* | head -1`" | FileCheck --check-prefix=ACCOUNT %s
+// RUN: ls basic-mode-dso-* | head -1 | tr -d '\n' > %t.log
+// RUN: %llvm_xray account --format=csv --sort=funcid "%{readfile:%t.log}" | FileCheck --check-prefix=ACCOUNT %s
 // RUN: rm basic-mode-dso-*
 
 // REQUIRES: target={{(aarch64|x86_64)-.*}}

diff  --git a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp
index 0517c9a9b47e5..58a800a7c382a 100644
--- a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp
@@ -6,8 +6,8 @@
 // RUN:     verbosity=1" \
 // RUN: env XRAY_FDR_OPTIONS="no_file_flush=true func_duration_threshold_us=0" \
 // RUN:     %run %t 2>&1 | FileCheck %s
-// RUN: FILES=`find %t.dir -name 'fdr-inmemory-test-*' | wc -l`
-// RUN: [ $FILES -eq 0 ]
+// RUN: find %t.dir -name 'fdr-inmemory-test-*' | wc -l | tr -d '\n' > %t.file_count
+// RUN: %python -c "import sys; sys.exit(int(sys.argv[1]))" %{readfile:%t.file_count} 
 // RUN: rm -rf %t.dir
 //
 // REQUIRES: built-in-llvm-tree

diff  --git a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp
index a545f540bc6e7..ffe43c9b516d7 100644
--- a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp
@@ -6,8 +6,8 @@
 // RUN:     verbosity=1" \
 // RUN: env XRAY_FDR_OPTIONS="no_file_flush=true func_duration_threshold_us=0" \
 // RUN:     %run %t 2>&1 | FileCheck %s
-// RUN: FILES=`find %t.dir -name 'fdr-inmemory-test-*' | wc -l`
-// RUN: [ $FILES -eq 0 ]
+// RUN: find %t.dir -name 'fdr-inmemory-test-*' | wc -l | tr -d '\n' > %t.file_count
+// RUN: %python -c "import sys; sys.exit(int(sys.argv[1]))" %{readfile:%t.file_count} 
 // RUN: rm -rf %t.dir
 //
 // REQUIRES: built-in-llvm-tree

diff  --git a/compiler-rt/test/xray/TestCases/Posix/fdr-mode.cpp b/compiler-rt/test/xray/TestCases/Posix/fdr-mode.cpp
index e74cacd1fe9ff..fa83b5767e015 100644
--- a/compiler-rt/test/xray/TestCases/Posix/fdr-mode.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/fdr-mode.cpp
@@ -10,11 +10,13 @@
 // RUN:     verbosity=1" \
 // RUN: env XRAY_FDR_OPTIONS="func_duration_threshold_us=5000" \
 // RUN:     %run %t 2>&1 | FileCheck %s
+// RUN: ls fdr-logging-test-* | head -1 | tr -d '\n' > %t.log
 // RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t \
-// RUN:     "`ls fdr-logging-test-* | head -1`" \
+// RUN:     "%{readfile:%t.log}" \
 // RUN:     | FileCheck %s --check-prefix=TRACE
+// RUN: ls fdr-unwrite-test-* | head -1 | tr -d '\n' > %t.log
 // RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t \
-// RUN:     "`ls fdr-unwrite-test-* | head -1`" \
+// RUN:     "%{readfile:%t.log}" \
 // RUN:     | FileCheck %s --check-prefix=UNWRITE
 // RUN: rm fdr-logging-test-*
 // RUN: rm fdr-unwrite-test-*

diff  --git a/compiler-rt/test/xray/TestCases/Posix/fork_basic_logging.cpp b/compiler-rt/test/xray/TestCases/Posix/fork_basic_logging.cpp
index 6f201a329db24..d0905c18cdc14 100644
--- a/compiler-rt/test/xray/TestCases/Posix/fork_basic_logging.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/fork_basic_logging.cpp
@@ -4,8 +4,9 @@
 // RUN: env XRAY_OPTIONS="patch_premain=true xray_logfile_base=fork-basic-logging-test- \
 // RUN:     xray_mode=xray-basic verbosity=1 xray_naive_log_func_duration_threshold_us=0" \
 // RUN:     %run %t 2>&1 | FileCheck %s
+// RUN: ls -S fork-basic-logging-test-* | head -1 | tr -d '\n' > %t.log
 // RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t \
-// RUN:     "`ls -S fork-basic-logging-test-* | head -1`" \
+// RUN:     "%{readfile:%t.log}" \
 // RUN:     | FileCheck %s --check-prefix=TRACE
 
 // REQUIRES: x86_64-target-arch

diff  --git a/compiler-rt/test/xray/TestCases/Posix/profiling-multi-threaded.cpp b/compiler-rt/test/xray/TestCases/Posix/profiling-multi-threaded.cpp
index 5d00d0f02b3e1..b1b8edc659ea6 100644
--- a/compiler-rt/test/xray/TestCases/Posix/profiling-multi-threaded.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/profiling-multi-threaded.cpp
@@ -7,8 +7,8 @@
 // RUN: env XRAY_OPTIONS=verbosity=1 \
 // RUN:     XRAY_PROFILING_OPTIONS=no_flush=1 %run %t
 // RUN: env XRAY_OPTIONS=verbosity=1 %run %t
-// RUN: PROFILES=`ls xray-log.profiling-multi-* | wc -l`
-// RUN: [ $PROFILES -eq 1 ]
+// RUN: ls xray-log.profiling-multi-* | wc -l | tr -d '\n' > %t.profiles
+// RUN: %python -c "import sys; sys.exit(int(sys.argv[1]) - 1)" %{readfile:%t.profiles} 
 // RUN: rm -f xray-log.profiling-multi-*
 //
 // REQUIRES: built-in-llvm-tree

diff  --git a/compiler-rt/test/xray/TestCases/Posix/profiling-single-threaded.cpp b/compiler-rt/test/xray/TestCases/Posix/profiling-single-threaded.cpp
index d0226613db7c1..d84f75bcac0da 100644
--- a/compiler-rt/test/xray/TestCases/Posix/profiling-single-threaded.cpp
+++ b/compiler-rt/test/xray/TestCases/Posix/profiling-single-threaded.cpp
@@ -7,8 +7,8 @@
 // RUN: env XRAY_OPTIONS=verbosity=1 \
 // RUN:     XRAY_PROFILING_OPTIONS=no_flush=true %run %t
 // RUN: env XRAY_OPTIONS=verbosity=1 %run %t
-// RUN: PROFILES=`ls xray-log.profiling-single-* | wc -l`
-// RUN: [ $PROFILES -eq 2 ]
+// RUN: ls xray-log.profiling-single-* | wc -l | tr -d '\n' > %t.profiles
+// RUN: %python -c "import sys; sys.exit(int(sys.argv[1]) - 2)" %{readfile:%t.profiles} 
 // RUN: rm -f xray-log.profiling-single-*
 //
 // REQUIRES: built-in-llvm-tree


        


More information about the llvm-commits mailing list