Convert minidump unittests to use llvm::yaml::convertYAML

previously they used a minidump-specific function for this purpose, but
this is no longer needed now that whole of yaml2obj is available as a
library.

llvm-svn: 369379
This commit is contained in:
Pavel Labath 2019-08-20 12:53:42 +00:00
parent 59d5abaa71
commit 5877fb7cd7
1 changed files with 7 additions and 6 deletions

View File

@ -19,10 +19,11 @@
#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/FileSpec.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/ObjectYAML/MinidumpYAML.h" #include "llvm/ObjectYAML/yaml2obj.h"
#include "llvm/Support/FileSystem.h" #include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Testing/Support/Error.h" #include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@ -54,7 +55,8 @@ public:
llvm::Error SetUpFromYaml(llvm::StringRef yaml) { llvm::Error SetUpFromYaml(llvm::StringRef yaml) {
std::string data; std::string data;
llvm::raw_string_ostream os(data); llvm::raw_string_ostream os(data);
if (llvm::Error E = llvm::MinidumpYAML::writeAsBinary(yaml, os)) llvm::yaml::Input YIn(yaml);
if (llvm::Error E = llvm::yaml::convertYAML(YIn, os))
return E; return E;
os.flush(); os.flush();
@ -73,16 +75,15 @@ public:
TEST_F(MinidumpParserTest, InvalidMinidump) { TEST_F(MinidumpParserTest, InvalidMinidump) {
std::string duplicate_streams; std::string duplicate_streams;
llvm::raw_string_ostream os(duplicate_streams); llvm::raw_string_ostream os(duplicate_streams);
ASSERT_THAT_ERROR(llvm::MinidumpYAML::writeAsBinary(R"( llvm::yaml::Input YIn(R"(
--- !minidump --- !minidump
Streams: Streams:
- Type: LinuxAuxv - Type: LinuxAuxv
Content: DEADBEEFBAADF00D Content: DEADBEEFBAADF00D
- Type: LinuxAuxv - Type: LinuxAuxv
Content: DEADBEEFBAADF00D Content: DEADBEEFBAADF00D
)", )");
os), ASSERT_THAT_ERROR(llvm::yaml::convertYAML(YIn, os), llvm::Succeeded());
llvm::Succeeded());
os.flush(); os.flush();
auto data_buffer_sp = std::make_shared<DataBufferHeap>( auto data_buffer_sp = std::make_shared<DataBufferHeap>(
duplicate_streams.data(), duplicate_streams.size()); duplicate_streams.data(), duplicate_streams.size());