TestRunner.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //===-- tools/llvm-reduce/TestRunner.h ---------------------------*- C++ -*-===/
  2. //
  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
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_TOOLS_LLVMREDUCE_TESTRUNNER_H
  9. #define LLVM_TOOLS_LLVMREDUCE_TESTRUNNER_H
  10. #include "llvm/ADT/SmallString.h"
  11. #include "llvm/IR/Module.h"
  12. #include "llvm/Support/Error.h"
  13. #include "llvm/Support/FileSystem.h"
  14. #include "llvm/Support/Path.h"
  15. #include "llvm/Support/Program.h"
  16. #include <vector>
  17. namespace llvm {
  18. // This class contains all the info necessary for running the provided
  19. // interesting-ness test, as well as the most reduced module and its
  20. // respective filename.
  21. class TestRunner {
  22. public:
  23. TestRunner(StringRef TestName, const std::vector<std::string> &TestArgs);
  24. /// Runs the interesting-ness test for the specified file
  25. /// @returns 0 if test was successful, 1 if otherwise
  26. int run(StringRef Filename);
  27. /// Returns the most reduced version of the original testcase
  28. Module *getProgram() const { return Program.get(); }
  29. void setProgram(std::unique_ptr<Module> P) { Program = std::move(P); }
  30. private:
  31. StringRef TestName;
  32. const std::vector<std::string> &TestArgs;
  33. std::unique_ptr<Module> Program;
  34. };
  35. } // namespace llvm
  36. #endif