llvm.org GIT mirror llvm / a5db79d
Add a --crash option to not. Now the two possible uses of not are * not cmd Will return true if cmd doesn't crash and returns false. * not --crash cmd Will return true if cmd crashes. It will be used/tested in a followup commit for the clang crash recovery testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185678 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
1 changed file(s) with 21 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
1212 using namespace llvm;
1313
1414 int main(int argc, const char **argv) {
15 std::string Program = sys::FindProgramByName(argv[1]);
15 bool ExpectCrash = false;
16
17 ++argv;
18 --argc;
19
20 if (argc > 0 && StringRef(argv[0]) == "--crash") {
21 ++argv;
22 --argc;
23 ExpectCrash = true;
24 }
25
26 if (argc == 0)
27 return 1;
28
29 std::string Program = sys::FindProgramByName(argv[0]);
1630
1731 std::string ErrMsg;
18 int Result = sys::ExecuteAndWait(Program, argv + 1, 0, 0, 0, 0, &ErrMsg);
32 int Result = sys::ExecuteAndWait(Program, argv, 0, 0, 0, 0, &ErrMsg);
1933 if (Result < 0) {
2034 errs() << "Error: " << ErrMsg << "\n";
35 if (ExpectCrash)
36 return 0;
2137 return 1;
2238 }
2339
40 if (ExpectCrash)
41 return 1;
42
2443 return Result == 0;
2544 }