2017-06-29 21:02:11 +08:00
|
|
|
//===- TestUtilities.h ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-06-29 21:02:11 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-02-18 07:57:45 +08:00
|
|
|
#ifndef LLDB_UNITTESTS_TESTINGSUPPORT_TESTUTILITIES_H
|
|
|
|
#define LLDB_UNITTESTS_TESTINGSUPPORT_TESTUTILITIES_H
|
2017-06-29 21:02:11 +08:00
|
|
|
|
2020-07-10 05:14:36 +08:00
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
|
|
|
#include "lldb/Utility/DataBuffer.h"
|
2019-05-07 04:01:21 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2017-06-29 21:02:11 +08:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2019-05-07 04:01:21 +08:00
|
|
|
#include "llvm/Support/Error.h"
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
#include "llvm/Support/FileUtilities.h"
|
2017-06-29 21:02:11 +08:00
|
|
|
#include <string>
|
|
|
|
|
2019-05-07 04:01:21 +08:00
|
|
|
#define ASSERT_NO_ERROR(x) \
|
|
|
|
if (std::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 { \
|
|
|
|
}
|
|
|
|
|
2017-06-29 21:02:11 +08:00
|
|
|
namespace lldb_private {
|
|
|
|
std::string GetInputFilePath(const llvm::Twine &name);
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
|
|
|
|
class TestFile {
|
|
|
|
public:
|
|
|
|
static llvm::Expected<TestFile> fromYaml(llvm::StringRef Yaml);
|
|
|
|
static llvm::Expected<TestFile> fromYamlFile(const llvm::Twine &Name);
|
|
|
|
|
2020-07-10 05:14:36 +08:00
|
|
|
ModuleSpec moduleSpec() {
|
|
|
|
return ModuleSpec(FileSpec(), UUID(), dataBuffer());
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
}
|
|
|
|
|
2020-07-10 05:14:36 +08:00
|
|
|
private:
|
|
|
|
TestFile(std::string &&Buffer) : Buffer(std::move(Buffer)) {}
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
|
2020-07-10 05:14:36 +08:00
|
|
|
lldb::DataBufferSP dataBuffer() {
|
|
|
|
auto *Data = reinterpret_cast<const uint8_t *>(Buffer.data());
|
|
|
|
return std::make_shared<DataBufferUnowned>(const_cast<uint8_t *>(Data),
|
|
|
|
Buffer.size());
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
}
|
|
|
|
|
2020-07-10 05:14:36 +08:00
|
|
|
std::string Buffer;
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
};
|
2017-06-29 21:02:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|