1 //===- not.cpp - The 'not' testing tool -----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/Path.h"
11 #include "llvm/Support/Program.h"
12 #include "llvm/Support/raw_ostream.h"
15 int main(int argc, const char **argv) {
16 bool ExpectCrash = false;
21 if (argc > 0 && StringRef(argv[0]) == "--crash") {
30 auto Program = sys::findProgramByName(argv[0]);
32 errs() << "Error: Unable to find `" << argv[0]
33 << "' in PATH: " << Program.getError().message() << "\n";
38 int Result = sys::ExecuteAndWait(*Program, argv, nullptr, nullptr, 0, 0,
41 // Handle abort() in msvcrt -- It has exit code as 3. abort(), aka
42 // unreachable, should be recognized as a crash. However, some binaries use
43 // exit code 3 on non-crash failure paths, so only do this if we expect a
45 if (ExpectCrash && Result == 3)
49 errs() << "Error: " << ErrMsg << "\n";