[llvm] [BOLT] Port additional test to internal shell (PR #156487)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 09:34:15 PDT 2025
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/156487
This test was broken by #156083 because it was never ported to the internal shell. It requires fuser which is not installed by default on premerge and none of the BOLT buildbots have been online in a while.
This was actually causing a timeout because of #156484, worked around using a manual bash invocation with a wait call to ensure all of the subprocesses have exited.
>From a6442b35c88573e488fbc30f71f3018f336505b0 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Tue, 2 Sep 2025 16:32:00 +0000
Subject: [PATCH] [BOLT] Port additional test to internal shell
This test was broken by #156083 because it was never ported to the
internal shell. It requires fuser which is not installed by default on
premerge and none of the BOLT buildbots have been online in a while.
This was actually causing a timeout because of #156484, worked around
using a manual bash invocation with a wait call to ensure all of the
subprocesses have exited.
---
bolt/test/runtime/copy_file.py | 15 ++++++++++++
.../test/runtime/instrumentation-indirect-2.c | 24 +++++++++----------
2 files changed, 26 insertions(+), 13 deletions(-)
create mode 100644 bolt/test/runtime/copy_file.py
diff --git a/bolt/test/runtime/copy_file.py b/bolt/test/runtime/copy_file.py
new file mode 100644
index 0000000000000..14db9d0c7be3c
--- /dev/null
+++ b/bolt/test/runtime/copy_file.py
@@ -0,0 +1,15 @@
+import sys
+import shutil
+
+with open(sys.argv[1] + ".output") as log_file:
+ lines = log_file.readlines()
+ for line in lines:
+ if line.startswith(sys.argv[2]):
+ pid = line.split(" ")[1].strip()
+ shutil.copy(
+ sys.argv[1] + "." + pid + ".fdata",
+ sys.argv[1] + "." + sys.argv[3] + ".fdata",
+ )
+ sys.exit(0)
+
+sys.exit(1)
diff --git a/bolt/test/runtime/instrumentation-indirect-2.c b/bolt/test/runtime/instrumentation-indirect-2.c
index 7d19db14b77f0..4883d9b4e619f 100644
--- a/bolt/test/runtime/instrumentation-indirect-2.c
+++ b/bolt/test/runtime/instrumentation-indirect-2.c
@@ -50,7 +50,7 @@ int main() {
return 0;
}
/*
-REQUIRES: system-linux,shell,fuser
+REQUIRES: system-linux,fuser
RUN: %clang %cflags %s -o %t.exe -Wl,-q -pie -fpie
@@ -61,10 +61,14 @@ RUN: --instrumentation-wait-forks
# Instrumented program needs to finish returning zero
# Both output and profile must contain all 16 functions
-RUN: %t.instrumented_conservative > %t.output
-# Wait for profile and output to be fully written
-RUN: bash %S/wait_file.sh %t.output
-RUN: bash %S/wait_file.sh %t.fdata
+# We need to use bash to invoke this as otherwise we hang inside a
+# popen.communicate call in lit's internal shell. Eventually we should not
+# need this.
+# TODO(boomanaiden154): Remove once
+# https://github.com/llvm/llvm-project/issues/156484 is fixed.
+RUN: bash -c "%t.instrumented_conservative; wait" > %t.output
+# We can just read because we ensure the profile will be fully written by
+# calling wait inside the bash invocation.
RUN: cat %t.output | FileCheck %s --check-prefix=CHECK-OUTPUT
RUN: cat %t.fdata | FileCheck %s --check-prefix=CHECK-COMMON-PROF
@@ -112,14 +116,8 @@ RUN: bash %S/wait_file.sh %t.output
# Make sure all functions were called
RUN: cat %t.output | FileCheck %s --check-prefix=CHECK-OUTPUT
-RUN: child_pid=$(cat %t.output | grep funcA | awk '{print $2;}')
-RUN: par_pid=$(cat %t.output | grep funcB | awk '{print $2;}')
-
-RUN: bash %S/wait_file.sh %t.$child_pid.fdata
-RUN: bash %S/wait_file.sh %t.$par_pid.fdata
-
-RUN: mv %t.$child_pid.fdata %t.child.fdata
-RUN: mv %t.$par_pid.fdata %t.parent.fdata
+RUN: %python %S/copy_file.py %t funcA child
+RUN: %python %S/copy_file.py %t funcB parent
# Instrumented binary must produce two profiles with only local calls
# recorded. Functions called only in child should not appear in parent's
More information about the llvm-commits
mailing list