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
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)"));
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;
int RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
OutputFile, SharedObjs);
+ if (ProgramExitedNonzero != 0)
+ *ProgramExitedNonzero = (RetVal != 0);
// Remove the temporary bytecode file.
if (CreatedBytecode) removeFile(BytecodeFile);
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!");
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;