llvm-reduce: Make tests shell-independent by passing the interpreter on the command line rather than using #! in the test file

llvm-svn: 372049
This commit is contained in:
David Blaikie 2019-09-16 23:41:19 +00:00
parent 4a249553fe
commit cb4aee7318
5 changed files with 15 additions and 51 deletions

View File

@ -1,16 +1,7 @@
; Test that llvm-reduce can remove uninteresting function arguments from function definitions as well as their calls.
;
; RUN: rm -rf %t
; RUN: mkdir %t
; get the python path from lit
; RUN: echo "#!" %python > %t/test.py
; then include the rest of the test script
; RUN: cat %p/Inputs/remove-args.py >> %t/test.py
; RUN: chmod +x %t/test.py
; RUN: llvm-reduce --test %t/test.py %s -o %t/out.ll
; RUN: cat %t/out.ll | FileCheck -implicit-check-not=uninteresting %s
; REQUIRES: shell
; RUN: llvm-reduce --test %python --test-arg %p/Inputs/remove-args.py %s -o %t
; RUN: cat %t | FileCheck -implicit-check-not=uninteresting %s
; CHECK: @interesting(i32 %interesting)
define void @interesting(i32 %uninteresting1, i32 %interesting, i32 %uninteresting2) {

View File

@ -1,17 +1,8 @@
; Test that llvm-reduce can remove uninteresting functions as well as
; their InstCalls.
;
; RUN: rm -rf %t
; RUN: mkdir %t
; get the python path from lit
; RUN: echo "#!" %python > %t/test.py
; then include the rest of the test script
; RUN: cat %p/Inputs/remove-funcs.py >> %t/test.py
; RUN: chmod +x %t/test.py
; RUN: llvm-reduce --test %t/test.py %s -o %t/out.ll
; RUN: cat %t/out.ll | FileCheck -implicit-check-not=uninteresting %s
; REQUIRES: shell
; RUN: llvm-reduce --test %python --test-arg %p/Inputs/remove-funcs.py %s -o %t
; RUN: cat %t | FileCheck -implicit-check-not=uninteresting %s
define i32 @uninteresting1() {
entry:

View File

@ -1,17 +1,8 @@
; Test that llvm-reduce can remove uninteresting Global Variables as well as
; their direct uses (which in turn are replaced with 'undef').
;
; RUN: rm -rf %t
; RUN: mkdir %t
; get the python path from lit
; RUN: echo "#!" %python > %t/test.py
; then include the rest of the test script
; RUN: cat %p/Inputs/remove-global-vars.py >> %t/test.py
; RUN: chmod +x %t/test.py
; RUN: llvm-reduce --test %t/test.py %s -o %t/out.ll
; RUN: cat %t/out.ll | FileCheck -implicit-check-not=uninteresting %s
; REQUIRES: shell
; RUN: llvm-reduce --test %python --test-arg %p/Inputs/remove-global-vars.py %s -o %t
; RUN: cat %t | FileCheck -implicit-check-not=uninteresting %s
; CHECK: @interesting = global
@interesting = global i32 0, align 4

View File

@ -1,17 +1,8 @@
; Test that llvm-reduce can remove uninteresting metadata from an IR file.
; The Metadata pass erases named & unnamed metadata nodes.
;
; RUN: rm -rf %t
; RUN: mkdir %t
; get the python path from lit
; RUN: echo "#!" %python > %t/test.py
; then include the rest of the test script
; RUN: cat %p/Inputs/remove-metadata.py >> %t/test.py
; RUN: chmod +x %t/test.py
; RUN: llvm-reduce --test %t/test.py %s -o %t/out.ll
; RUN: cat %t/out.ll | FileCheck -implicit-check-not=! %s
; REQUIRES: shell
; RUN: llvm-reduce --test %python --test-arg %p/Inputs/remove-metadata.py %s -o %t
; RUN: cat %t | FileCheck -implicit-check-not=! %s
@global = global i32 0, !dbg !0

View File

@ -36,16 +36,16 @@ TestRunner::TestRunner(StringRef TestName, std::vector<std::string> TestArgs)
int TestRunner::run(StringRef Filename) {
std::vector<StringRef> ProgramArgs;
ProgramArgs.push_back(TestName);
for (const auto &Arg : TestArgs)
ProgramArgs.push_back(Arg);
ProgramArgs.push_back(Filename);
for (auto Arg : TestArgs)
ProgramArgs.push_back(Arg.c_str());
Optional<StringRef> Redirects[3]; // STDIN, STDOUT, STDERR
std::string ErrMsg;
int Result =
sys::ExecuteAndWait(TestName, ProgramArgs, None, Redirects,
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
int Result = sys::ExecuteAndWait(
TestName, ProgramArgs, /*Env=*/None, /*Redirects=*/None,
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
if (Result < 0) {
Error E = make_error<StringError>("Error running interesting-ness test: " +