Skip to content

Commit 823e942

Browse files
authored
[compiler-rt][test] Expand and Rewrite Tests for lit Internal Shell Compatibility (#106115)
This patch addresses compatibility issues with the lit internal shell by expanding and rewriting test scripts in the compiler-rt subproject. These changes were prompted by the FileNotFound unresolved errors encountered during the testing process, specifically when running the command `LIT_USE_INTERNAL_SHELL=1 ninja check compiler-rt`. **Why the error occurred:** The error occurred because the original test scripts used process substitution `(<(...))` in their diff commands. Process substitution creates temporary files or FIFOs to hold command output, and these are then passed to `diff`. However, the lit internal shell, which is more limited than a typical shell like `bash`, does not support process substitution. When lit tries to execute these commands, it is unable to create or access the temporary files or FIFOs generated by process substitution. As a result, lit attempts to open a file or directory that doesn't exist, leading to the `FileNotFoundError`. **Changes Made:** - Instead of using process substitution, the commands now explicitly redirect the output of `llvm-profdata show` to temporary files before performing the `diff` comparison. This ensures that the lit internal shell can correctly find and open these files, resolving the `FileNotFoundError`. [This change is relevant [RFC] Enabling the lit internal shell by Default](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179) fixes: #106111
1 parent d28c0fb commit 823e942

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

compiler-rt/test/profile/Linux/counter_promo_for.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// RUN: %run %t.nopromo.gen
1313
// RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/
1414
// RUN: llvm-profdata show --counts --all-functions %t.nopromo.profdata > %t.nopromo.dump
15-
// RUN: diff <(llvm-profdata show %t.promo.profdata) <(llvm-profdata show %t.nopromo.profdata)
15+
// RUN: llvm-profdata show %t.promo.profdata > %t.promo.dump
16+
// RUN: llvm-profdata show %t.nopromo.profdata > %t.nopromo.dump
17+
// RUN: diff %t.promo.dump %t.nopromo.dump
1618

1719
int g;
1820
__attribute__((noinline)) void bar(int i) { g += i; }

compiler-rt/test/profile/Linux/counter_promo_nest.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
// RUN: %run %t.nopromo.gen
1111
// RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/
1212
// RUN: llvm-profdata show --counts --all-functions %t.nopromo.profdata > %t.nopromo.dump
13-
// RUN: diff <(llvm-profdata show %t.promo.profdata) <(llvm-profdata show %t.nopromo.profdata)
13+
// RUN: llvm-profdata show %t.promo.profdata > %t.promo.dump
14+
// RUN: llvm-profdata show %t.nopromo.profdata > %t.nopromo.dump
15+
// RUN: diff %t.promo.dump %t.nopromo.dump
1416
int g;
1517
__attribute__((noinline)) void bar() {
1618
g++;

compiler-rt/test/profile/Linux/counter_promo_while.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// RUN: %run %t.nopromo.gen
1313
// RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/
1414
// RUN: llvm-profdata show --counts --all-functions %t.nopromo.profdata > %t.nopromo.dump
15-
// RUN: diff <(llvm-profdata show %t.promo.profdata) <(llvm-profdata show %t.nopromo.profdata)
15+
// RUN: llvm-profdata show %t.promo.profdata > %t.promo.dump
16+
// RUN: llvm-profdata show %t.nopromo.profdata > %t.nopromo.dump
17+
// RUN: diff %t.promo.dump %t.nopromo.dump
1618
int g;
1719
__attribute__((noinline)) void bar(int i) { g += i; }
1820
__attribute__((noinline)) void foo(int n, int N) {

compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
// RUN: env LLVM_PROFILE_FILE=%t.d4.proflite %run %t.d4
88
// RUN: llvm-profdata merge -o %t.d4.profdata --debug-info=%t.d4 %t.d4.proflite
99

10-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.d4.profdata)
10+
// RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal.dump
11+
// RUN: llvm-profdata show --all-functions --counts %t.d4.profdata > %t.d4.dump
12+
// RUN: diff %t.normal.dump %t.d4.dump
1113

1214
// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
1315
// RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t
1416
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite
1517

16-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
18+
// RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal2.dump
19+
// RUN: llvm-profdata show --all-functions --counts %t.profdata > %t.prof.dump
20+
// RUN: diff %t.normal2.dump %t.prof.dump
1721

1822
// RUN: %clang_pgogen -o %t.cov -g -mllvm --debug-info-correlate -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
1923
// RUN: env LLVM_PROFILE_FILE=%t.cov.proflite %run %t.cov
@@ -23,7 +27,9 @@
2327
// RUN: env LLVM_PROFILE_FILE=%t.cov.profraw %run %t.cov.normal
2428
// RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
2529

26-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
30+
// RUN: llvm-profdata show --all-functions --counts %t.cov.normal.profdata > %t.cov.normal.dump
31+
// RUN: llvm-profdata show --all-functions --counts %t.cov.profdata > %t.cov.dump
32+
// RUN: diff %t.cov.normal.dump %t.cov.dump
2733

2834
// Test debug info correlate with online merging.
2935

@@ -36,11 +42,15 @@
3642
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
3743
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir/
3844

39-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
45+
// RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal3.dump
46+
// RUN: llvm-profdata show --all-functions --counts %t.profdata > %t.prof3.dump
47+
// RUN: diff %t.normal3.dump %t.prof3.dump
4048

4149
// RUN: rm -rf %t.profdir && mkdir %t.profdir
4250
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
4351
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
4452
// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.profdir/
4553

46-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
54+
// RUN: llvm-profdata show --all-functions --counts %t.cov.normal.profdata > %t.cov.normal2.dump
55+
// RUN: llvm-profdata show --all-functions --counts %t.cov.profdata > %t.cov2.dump
56+
// RUN: diff %t.cov.normal2.dump %t.cov2.dump

0 commit comments

Comments
 (0)