1 //===-- TestRunner.cpp ----------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "TestRunner.h"
13 TestRunner::TestRunner(StringRef TestName
,
14 const std::vector
<std::string
> &TestArgs
,
15 std::unique_ptr
<ReducerWorkItem
> Program
)
16 : TestName(TestName
), TestArgs(TestArgs
), Program(std::move(Program
)) {
17 assert(this->Program
&& "Initialized with null program?");
20 /// Runs the interestingness test, passes file to be tested as first argument
21 /// and other specified test arguments after that.
22 int TestRunner::run(StringRef Filename
) {
23 std::vector
<StringRef
> ProgramArgs
;
24 ProgramArgs
.push_back(TestName
);
26 for (const auto &Arg
: TestArgs
)
27 ProgramArgs
.push_back(Arg
);
29 ProgramArgs
.push_back(Filename
);
32 int Result
= sys::ExecuteAndWait(
33 TestName
, ProgramArgs
, /*Env=*/None
, /*Redirects=*/None
,
34 /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg
);
37 Error E
= make_error
<StringError
>("Error running interesting-ness test: " +
39 inconvertibleErrorCode());
40 errs() << toString(std::move(E
));