summaryrefslogtreecommitdiff
path: root/tools/bugpoint
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-02-11 18:37:32 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-02-11 18:37:32 +0000
commitc5cad211d6ec50fe90a0a716dee701c6c4721385 (patch)
tree74e5fae07eb9e8d07c82c01a77b0826e1942dde6 /tools/bugpoint
parent945871df86c4e5e0a12c58f6e12edbd09c813310 (diff)
downloadllvm-c5cad211d6ec50fe90a0a716dee701c6c4721385.tar.gz
llvm-c5cad211d6ec50fe90a0a716dee701c6c4721385.tar.bz2
llvm-c5cad211d6ec50fe90a0a716dee701c6c4721385.tar.xz
Add check-exit-code option, defaulting to true.
Add ProgramExitedNonzero argument to executeProgram(), and make it tell its caller whether the program exited nonzero. Move executeProgramWithCBE() out of line, to ExecutionDriver.cpp, and remove its extra arguments which are always defaulted. Make it turn off check-exit-code if the program exits nonzero while generating a reference output. Make diffProgram() assume that any nonzero exit code is a failure, if check-exit-code is turned on. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11325 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint')
-rw-r--r--tools/bugpoint/BugDriver.h10
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp35
2 files changed, 36 insertions, 9 deletions
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h
index af04a7d61a..354fae54c6 100644
--- a/tools/bugpoint/BugDriver.h
+++ b/tools/bugpoint/BugDriver.h
@@ -178,17 +178,13 @@ private:
std::string executeProgram(std::string RequestedOutputFilename = "",
std::string Bytecode = "",
const std::string &SharedObjects = "",
- AbstractInterpreter *AI = 0);
+ AbstractInterpreter *AI = 0,
+ bool *ProgramExitedNonzero = 0);
/// executeProgramWithCBE - Used to create reference output with the C
/// backend, if reference output is not provided.
///
- std::string executeProgramWithCBE(std::string OutputFile = "",
- std::string BytecodeFile = "",
- const std::string &SharedObj = "") {
- return executeProgram(OutputFile, BytecodeFile, SharedObj,
- (AbstractInterpreter*)cbe);
- }
+ std::string executeProgramWithCBE(std::string OutputFile = "");
/// diffProgram - This method executes the specified module and diffs the
/// output against the file specified by ReferenceOutputFile. If the output
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index e9e21d0aa2..9dc9adf804 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -49,6 +49,11 @@ namespace {
0),
cl::init(AutoPick));
+ cl::opt<bool>
+ CheckProgramExitCode("check-exit-code",
+ cl::desc("Assume nonzero exit code is failure (default on)"),
+ cl::init(true));
+
cl::opt<std::string>
InputFile("input", cl::init("/dev/null"),
cl::desc("Filename to pipe in as stdin (default: /dev/null)"));
@@ -137,7 +142,8 @@ bool BugDriver::initializeExecutionEnvironment() {
std::string BugDriver::executeProgram(std::string OutputFile,
std::string BytecodeFile,
const std::string &SharedObj,
- AbstractInterpreter *AI) {
+ AbstractInterpreter *AI,
+ bool *ProgramExitedNonzero) {
if (AI == 0) AI = Interpreter;
assert(AI && "Interpreter should have been created already!");
bool CreatedBytecode = false;
@@ -167,6 +173,8 @@ std::string BugDriver::executeProgram(std::string OutputFile,
int RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
OutputFile, SharedObjs);
+ if (ProgramExitedNonzero != 0)
+ *ProgramExitedNonzero = (RetVal != 0);
// Remove the temporary bytecode file.
if (CreatedBytecode) removeFile(BytecodeFile);
@@ -175,6 +183,22 @@ std::string BugDriver::executeProgram(std::string OutputFile,
return OutputFile;
}
+/// executeProgramWithCBE - Used to create reference output with the C
+/// backend, if reference output is not provided.
+///
+std::string BugDriver::executeProgramWithCBE(std::string OutputFile) {
+ bool ProgramExitedNonzero;
+ std::string outFN = executeProgram(OutputFile, "", "",
+ (AbstractInterpreter*)cbe,
+ &ProgramExitedNonzero);
+ if (ProgramExitedNonzero) {
+ std::cerr
+ << "Warning: While generating reference output, program exited with\n"
+ << "non-zero exit code. This will NOT be treated as a failure.\n";
+ CheckProgramExitCode = false;
+ }
+ return outFN;
+}
std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
assert(Interpreter && "Interpreter should have been created already!");
@@ -211,8 +235,15 @@ std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
bool BugDriver::diffProgram(const std::string &BytecodeFile,
const std::string &SharedObject,
bool RemoveBytecode) {
+ bool ProgramExitedNonzero;
+
// Execute the program, generating an output file...
- std::string Output = executeProgram("", BytecodeFile, SharedObject);
+ std::string Output = executeProgram("", BytecodeFile, SharedObject, 0,
+ &ProgramExitedNonzero);
+
+ // If we're checking the program exit code, assume anything nonzero is bad.
+ if (CheckProgramExitCode && ProgramExitedNonzero)
+ return true;
std::string Error;
bool FilesDifferent = false;