2009-09-24 06:23:57 +00:00
|
|
|
//===- not.cpp - The 'not' testing tool -----------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-11-29 18:16:10 +00:00
|
|
|
#include "llvm/Support/Path.h"
|
|
|
|
#include "llvm/Support/Program.h"
|
2010-10-29 20:20:29 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2009-09-24 06:23:57 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
int main(int argc, const char **argv) {
|
2013-07-05 02:50:03 +00:00
|
|
|
bool ExpectCrash = false;
|
|
|
|
|
|
|
|
++argv;
|
|
|
|
--argc;
|
|
|
|
|
|
|
|
if (argc > 0 && StringRef(argv[0]) == "--crash") {
|
|
|
|
++argv;
|
|
|
|
--argc;
|
|
|
|
ExpectCrash = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
std::string Program = sys::FindProgramByName(argv[0]);
|
2010-10-29 20:20:29 +00:00
|
|
|
|
|
|
|
std::string ErrMsg;
|
2013-07-05 02:50:03 +00:00
|
|
|
int Result = sys::ExecuteAndWait(Program, argv, 0, 0, 0, 0, &ErrMsg);
|
2010-10-29 20:20:29 +00:00
|
|
|
if (Result < 0) {
|
|
|
|
errs() << "Error: " << ErrMsg << "\n";
|
2013-07-05 02:50:03 +00:00
|
|
|
if (ExpectCrash)
|
|
|
|
return 0;
|
2010-10-29 20:20:29 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-07-05 02:50:03 +00:00
|
|
|
if (ExpectCrash)
|
|
|
|
return 1;
|
|
|
|
|
2010-10-29 20:20:29 +00:00
|
|
|
return Result == 0;
|
2009-09-24 06:23:57 +00:00
|
|
|
}
|