1 //===-- tools/llvm-reduce/TestRunner.h ---------------------------*- C++ -*-===/
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 #ifndef LLVM_TOOLS_LLVMREDUCE_TESTRUNNER_H
10 #define LLVM_TOOLS_LLVMREDUCE_TESTRUNNER_H
12 #include "llvm/ADT/SmallString.h"
13 #include "llvm/IR/Module.h"
14 #include "llvm/Support/Error.h"
15 #include "llvm/Support/FileSystem.h"
16 #include "llvm/Support/Path.h"
17 #include "llvm/Support/Program.h"
22 // This class contains all the info necessary for running the provided
23 // interesting-ness test, as well as the most reduced module and its
24 // respective filename.
27 TestRunner(StringRef TestName
, std::vector
<std::string
> TestArgs
,
28 StringRef ReducedFilepath
);
30 /// Runs the interesting-ness test for the specified file
31 /// @returns 0 if test was successful, 1 if otherwise
32 int run(StringRef Filename
);
34 /// Filename to the most reduced testcase
35 StringRef
getReducedFilepath() const { return ReducedFilepath
; }
36 /// Directory where tmp files are created
37 StringRef
getTmpDir() const { return TmpDirectory
; }
38 /// Returns the most reduced version of the original testcase
39 Module
*getProgram() const { return Program
.get(); }
41 void setReducedFilepath(SmallString
<128> F
) {
42 ReducedFilepath
= std::move(F
);
44 void setProgram(std::unique_ptr
<Module
> P
) { Program
= std::move(P
); }
47 SmallString
<128> TestName
;
48 std::vector
<std::string
> TestArgs
;
49 SmallString
<128> ReducedFilepath
;
50 SmallString
<128> TmpDirectory
;
51 std::unique_ptr
<Module
> Program
;