2018-09-06 07:30:17 +08:00
|
|
|
|
|
|
|
#include "llvm/Testing/Support/SupportHelpers.h"
|
|
|
|
|
|
|
|
#include "llvm/ADT/SmallString.h"
|
|
|
|
#include "llvm/ADT/Twine.h"
|
|
|
|
#include "llvm/Support/Error.h"
|
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
#include "llvm/Support/Path.h"
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::unittest;
|
|
|
|
|
2018-09-07 03:51:20 +08:00
|
|
|
SmallString<128> llvm::unittest::getInputFileDirectory(const char *Argv0) {
|
|
|
|
llvm::SmallString<128> Result = llvm::sys::path::parent_path(Argv0);
|
2018-09-06 07:30:17 +08:00
|
|
|
llvm::sys::fs::make_absolute(Result);
|
|
|
|
llvm::sys::path::append(Result, "llvm.srcdir.txt");
|
|
|
|
|
2018-09-06 07:45:48 +08:00
|
|
|
EXPECT_TRUE(llvm::sys::fs::is_regular_file(Result))
|
2018-09-06 07:30:17 +08:00
|
|
|
<< "Unit test source directory file does not exist.";
|
|
|
|
|
|
|
|
auto File = MemoryBuffer::getFile(Result);
|
|
|
|
|
|
|
|
EXPECT_TRUE(static_cast<bool>(File))
|
|
|
|
<< "Could not open unit test source directory file.";
|
|
|
|
|
|
|
|
Result.clear();
|
|
|
|
Result.append((*File)->getBuffer().trim());
|
|
|
|
llvm::sys::path::append(Result, "Inputs");
|
|
|
|
llvm::sys::path::native(Result);
|
2018-09-06 08:06:20 +08:00
|
|
|
return Result;
|
2018-09-06 07:30:17 +08:00
|
|
|
}
|