[llvm-nm] - Fix a bug and unbreak ASan BB.
[llvm-complete.git] / unittests / ObjectYAML / YAML2ObjTest.cpp
blob0a383881687b646749ba41449dfa5fe0469b2ad6
1 //===- YAML2ObjTest.cpp --------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ObjectYAML/yaml2obj.h"
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/Object/ObjectFile.h"
12 #include "llvm/Support/Error.h"
13 #include "llvm/Testing/Support/Error.h"
14 #include "gtest/gtest.h"
16 using namespace llvm;
17 using namespace object;
18 using namespace yaml;
20 TEST(yaml2ObjectFile, ELF) {
21 SmallString<0> Storage;
22 Expected<std::unique_ptr<ObjectFile>> ErrOrObj = yaml2ObjectFile(Storage, R"(
23 --- !ELF
24 FileHeader:
25 Class: ELFCLASS64
26 Data: ELFDATA2LSB
27 Type: ET_REL
28 Machine: EM_X86_64)");
30 ASSERT_THAT_EXPECTED(ErrOrObj, Succeeded());
32 std::unique_ptr<ObjectFile> ObjFile = std::move(ErrOrObj.get());
34 ASSERT_TRUE(ObjFile->isELF());
35 ASSERT_TRUE(ObjFile->isRelocatableObject());