TestRunner.h 1.6 KB

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