Skip to content

Commit 2ef58b6

Browse files
authored
[DTLTO][TEST] Make Clang driver tests more robust (llvm#159151)
The Clang driver tests tried to match the Clang executable name via a regular expression. This failed on some buildbots where the name was not anticipated. Make the test more robust by extracting the filename with Python and appending a line to the output. This is then captured into a FileCheck variable and used directly in the check for the executable name. Should fix buildbot failures caused by the merge of PR llvm#159129.
1 parent 41cef78 commit 2ef58b6

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

clang/test/Driver/DTLTO/dtlto.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
/// Check DTLTO options are forwarded to the linker.
77

88
/// Check that options are forwarded as expected with --thinlto-distributor=.
9+
// RUN: %python %S/filename.py %clang > %t_forward.log
910
// RUN: %clang -flto=thin %s -### -fuse-ld=lld --target=x86_64-linux-gnu \
1011
// RUN: -Xthinlto-distributor=a1 -Xthinlto-distributor=a2,a3 \
11-
// RUN: -fthinlto-distributor=d.exe -Werror 2>&1 | \
12-
// RUN: FileCheck %s --check-prefix=FORWARD
12+
// RUN: -fthinlto-distributor=d.exe -Werror >>%t_forward.log 2>&1
13+
// RUN: FileCheck %s --input-file=%t_forward.log --check-prefix=FORWARD
1314

15+
// FORWARD: filename.py:[[CLANG:.*]]
1416
// FORWARD: ld.lld
1517
// FORWARD-SAME: "--thinlto-distributor=d.exe"
16-
// FORWARD-SAME: "--thinlto-remote-compiler={{.*}}clang{{[^\"]*}}"
18+
// FORWARD-SAME: "--thinlto-remote-compiler={{.*}}[[CLANG]]"
1719
// FORWARD-SAME: "--thinlto-distributor-arg=a1"
1820
// FORWARD-SAME: "--thinlto-distributor-arg=a2"
1921
// FORWARD-SAME: "--thinlto-distributor-arg=a3"
@@ -22,30 +24,32 @@
2224
/// that a warning is issued for unused -Xthinlto-distributor options.
2325
// RUN: %clang -flto=thin %s -### -fuse-ld=lld --target=x86_64-linux-gnu \
2426
// RUN: -Xthinlto-distributor=a1 -Xthinlto-distributor=a2,a3 2>&1 | \
25-
// RUN: FileCheck %s --check-prefix=NODIST --implicit-check-not=distributor \
26-
// RUN: --implicit-check-not=remote-compiler
27+
// RUN: FileCheck %s --check-prefix=NODIST --implicit-check-not=distributor \
28+
// RUN: --implicit-check-not=remote-compiler
2729

2830
// NODIST: warning: argument unused during compilation: '-Xthinlto-distributor=a1'
2931
// NODIST: warning: argument unused during compilation: '-Xthinlto-distributor=a2,a3'
3032
// NODIST: ld.lld
3133

3234
/// Check the expected arguments are forwarded by default with only
3335
/// --thinlto-distributor=.
36+
// RUN: %python %S/filename.py %clang > %t_default.log
3437
// RUN: %clang -flto=thin %s -### -fuse-ld=lld --target=x86_64-linux-gnu \
35-
// RUN: -fthinlto-distributor=d.exe -Werror 2>&1 | \
36-
// RUN: FileCheck %s --check-prefix=DEFAULT --implicit-check-not=distributor \
37-
// RUN: --implicit-check-not=remote-compiler
38+
// RUN: -fthinlto-distributor=d.exe -Werror >>%t_default.log 2>&1
39+
// RUN: FileCheck %s --input-file=%t_default.log --check-prefix=DEFAULT \
40+
// RUN: --implicit-check-not=distributor --implicit-check-not=remote-compiler
3841

3942
// DEFAULT: ld.lld
4043
// DEFAULT-SAME: "--thinlto-distributor=d.exe"
4144
// DEFAULT-SAME: "--thinlto-remote-compiler={{[^"]+}}"
4245

4346
/// Check that nothing is forwarded when the compiler is not in LTO mode, and that
4447
/// appropriate unused option warnings are issued.
48+
// RUN: %python %S/filename.py %clang > %t_noflto.log
4549
// RUN: %clang %s -### -fuse-ld=lld --target=x86_64-linux-gnu \
46-
// RUN: -fthinlto-distributor=d.exe 2>&1 | \
47-
// RUN: FileCheck %s --check-prefix=NOFLTO --implicit-check-not=distributor \
48-
// RUN: --implicit-check-not=remote-compiler
50+
// RUN: -fthinlto-distributor=d.exe >>%t_noflto.log 2>&1
51+
// RUN: FileCheck %s --input-file=%t_noflto.log --check-prefix=NOFLTO \
52+
// RUN: --implicit-check-not=distributor --implicit-check-not=remote-compiler
4953

5054
// NOFLTO: warning: argument unused during compilation: '-fthinlto-distributor=d.exe'
5155
// NOFLTO: ld.lld
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pathlib import Path
2+
import sys
3+
4+
print(f"filename.py:{Path(sys.argv[1]).resolve().name}")

clang/test/Driver/DTLTO/ps5-dtlto.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
/// Check DTLTO options are forwarded to the linker.
77

88
/// Check that options are forwarded as expected with --thinlto-distributor=.
9+
// RUN: %python %S/filename.py %clang > %t_forward.log
910
// RUN: %clang -flto=thin %s -### --target=x86_64-sie-ps5 \
1011
// RUN: -Xthinlto-distributor=a1 -Xthinlto-distributor=a2,a3 \
11-
// RUN: -fthinlto-distributor=d.exe -Werror 2>&1 | \
12-
// RUN: FileCheck %s --check-prefix=FORWARD
12+
// RUN: -fthinlto-distributor=d.exe -Werror >>%t_forward.log 2>&1
13+
// RUN: FileCheck %s --input-file=%t_forward.log --check-prefix=FORWARD
1314

15+
// FORWARD: filename.py:[[CLANG:.*]]
1416
// FORWARD: prospero-lld
1517
// FORWARD-SAME: "--thinlto-distributor=d.exe"
16-
// FORWARD-SAME: "--thinlto-remote-compiler={{.*}}clang{{[^\"]*}}"
18+
// FORWARD-SAME: "--thinlto-remote-compiler={{.*}}[[CLANG]]"
1719
// FORWARD-SAME: "--thinlto-distributor-arg=a1"
1820
// FORWARD-SAME: "--thinlto-distributor-arg=a2"
1921
// FORWARD-SAME: "--thinlto-distributor-arg=a3"
@@ -22,27 +24,30 @@
2224
/// that a warning is issued for unused -Xthinlto-distributor options.
2325
// RUN: %clang -flto=thin %s -### --target=x86_64-sie-ps5 \
2426
// RUN: -Xthinlto-distributor=a1 -Xthinlto-distributor=a2,a3 2>&1 | \
25-
// RUN: FileCheck %s --check-prefix=NODIST --implicit-check-not=distributor \
26-
// RUN: --implicit-check-not=remote-compiler
27+
// RUN: FileCheck %s --check-prefix=NODIST --implicit-check-not=distributor \
28+
// RUN: --implicit-check-not=remote-compiler
2729

2830
// NODIST: warning: argument unused during compilation: '-Xthinlto-distributor=a1'
2931
// NODIST: warning: argument unused during compilation: '-Xthinlto-distributor=a2,a3'
3032
// NODIST: prospero-lld
3133

3234
/// Check the expected arguments are forwarded by default with only
3335
/// --thinlto-distributor=.
36+
// RUN: %python %S/filename.py %clang > %t_default.log
3437
// RUN: %clang -flto=thin %s -### --target=x86_64-sie-ps5 \
35-
// RUN: -fthinlto-distributor=d.exe -Werror 2>&1 | \
36-
// RUN: FileCheck %s --check-prefix=DEFAULT --implicit-check-not=distributor \
37-
// RUN: --implicit-check-not=remote-compiler
38+
// RUN: -fthinlto-distributor=d.exe -Werror >>%t_default.log 2>&1
39+
// RUN: FileCheck %s --input-file=%t_default.log --check-prefix=DEFAULT \
40+
// RUN: --implicit-check-not=distributor --implicit-check-not=remote-compiler
3841

42+
// DEFAULT: filename.py:[[CLANG:.*]]
3943
// DEFAULT: prospero-lld
4044
// DEFAULT-SAME: "--thinlto-distributor=d.exe"
41-
// DEFAULT-SAME: "--thinlto-remote-compiler={{[^"]+}}"
45+
// DEFAULT-SAME: "--thinlto-remote-compiler={{.*}}[[CLANG]]"
4246

4347
/// Check that the arguments are forwarded unconditionally even when the
4448
/// compiler is not in LTO mode.
49+
// RUN: %python %S/filename.py %clang > %t_noflto.log
4550
// RUN: %clang %s -### --target=x86_64-sie-ps5 \
46-
// RUN: -fthinlto-distributor=d.exe -Werror 2>&1 | \
47-
// RUN: FileCheck %s --check-prefix=DEFAULT --implicit-check-not=distributor \
48-
// RUN: --implicit-check-not=remote-compiler
51+
// RUN: -fthinlto-distributor=d.exe -Werror >>%t_noflto.log 2>&1
52+
// RUN: FileCheck %s --input-file=%t_noflto.log --check-prefix=DEFAULT \
53+
// RUN: --implicit-check-not=distributor --implicit-check-not=remote-compiler

0 commit comments

Comments
 (0)