mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-02 13:12:09 +00:00
Don't use PathV1.h in IncludeExcludeTest.cpp.
llvm-svn: 184959
This commit is contained in:
parent
b8db1cd13e
commit
b6d9c0001a
@ -1,9 +1,21 @@
|
|||||||
#include "Core/IncludeExcludeInfo.h"
|
#include "Core/IncludeExcludeInfo.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
#include "llvm/Support/PathV1.h"
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
// FIXME: copied from unittests/Support/Path.cpp
|
||||||
|
#define ASSERT_NO_ERROR(x) \
|
||||||
|
if (llvm::error_code ASSERT_NO_ERROR_ec = x) { \
|
||||||
|
llvm::SmallString<128> MessageStorage; \
|
||||||
|
llvm::raw_svector_ostream Message(MessageStorage); \
|
||||||
|
Message << #x ": did not return errc::success.\n" \
|
||||||
|
<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
|
||||||
|
<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
|
||||||
|
GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
|
||||||
|
} else { \
|
||||||
|
}
|
||||||
|
|
||||||
TEST(IncludeExcludeTest, ParseString) {
|
TEST(IncludeExcludeTest, ParseString) {
|
||||||
IncludeExcludeInfo IEManager;
|
IncludeExcludeInfo IEManager;
|
||||||
llvm::error_code Err = IEManager.readListFromString(
|
llvm::error_code Err = IEManager.readListFromString(
|
||||||
@ -38,29 +50,35 @@ struct InputFiles {
|
|||||||
// This function uses fatal assertions. The caller is responsible for making
|
// This function uses fatal assertions. The caller is responsible for making
|
||||||
// sure fatal assertions propagate.
|
// sure fatal assertions propagate.
|
||||||
void CreateFiles(bool UnixMode) {
|
void CreateFiles(bool UnixMode) {
|
||||||
IncludeDataPath = llvm::sys::Path::GetTemporaryDirectory();
|
llvm::SmallString<128> Path;
|
||||||
ExcludeDataPath = IncludeDataPath;
|
int FD;
|
||||||
|
|
||||||
ASSERT_FALSE(IncludeDataPath.createTemporaryFileOnDisk());
|
ASSERT_NO_ERROR(
|
||||||
std::ofstream IncludeDataFile(IncludeDataPath.c_str());
|
llvm::sys::fs::unique_file("include-%%%%%%", FD, Path));
|
||||||
ASSERT_TRUE(IncludeDataFile.good());
|
IncludeDataPath = Path.str();
|
||||||
for (unsigned i = 0; i < sizeof(IncludeData)/sizeof(char*); ++i) {
|
{
|
||||||
IncludeDataFile << IncludeData[i] << (UnixMode ? "\n" : "\r\n");
|
llvm::raw_fd_ostream IncludeDataFile(FD, true);
|
||||||
|
for (unsigned i = 0; i < sizeof(IncludeData) / sizeof(char *); ++i) {
|
||||||
|
IncludeDataFile << IncludeData[i] << (UnixMode ? "\n" : "\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_FALSE(ExcludeDataPath.createTemporaryFileOnDisk());
|
ASSERT_NO_ERROR(
|
||||||
std::ofstream ExcludeDataFile(ExcludeDataPath.c_str());
|
llvm::sys::fs::unique_file("exclude-%%%%%%", FD, Path));
|
||||||
ASSERT_TRUE(ExcludeDataFile.good());
|
ExcludeDataPath = Path.str();
|
||||||
for (unsigned i = 0; i < sizeof(ExcludeData)/sizeof(char*); ++i) {
|
{
|
||||||
ExcludeDataFile << ExcludeData[i] << (UnixMode ? "\n" : "\r\n");;
|
llvm::raw_fd_ostream ExcludeDataFile(FD, true);
|
||||||
|
for (unsigned i = 0; i < sizeof(ExcludeData) / sizeof(char *); ++i) {
|
||||||
|
ExcludeDataFile << ExcludeData[i] << (UnixMode ? "\n" : "\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *IncludeData[3];
|
static const char *IncludeData[3];
|
||||||
static const char *ExcludeData[4];
|
static const char *ExcludeData[4];
|
||||||
|
|
||||||
llvm::sys::Path IncludeDataPath;
|
std::string IncludeDataPath;
|
||||||
llvm::sys::Path ExcludeDataPath;
|
std::string ExcludeDataPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *InputFiles::IncludeData[3] = { "a", "b/b2", "c/c2" };
|
const char *InputFiles::IncludeData[3] = { "a", "b/b2", "c/c2" };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user