1 //===- ELFTest.cpp --------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/BinaryFormat/ELF.h"
10 #include "gtest/gtest.h"
13 using namespace llvm::ELF
;
16 TEST(ELFTest
, OSABI
) {
17 EXPECT_EQ(ELFOSABI_GNU
, convertNameToOSABI("gnu"));
18 EXPECT_EQ(ELFOSABI_FREEBSD
, convertNameToOSABI("freebsd"));
19 EXPECT_EQ(ELFOSABI_STANDALONE
, convertNameToOSABI("standalone"));
20 EXPECT_EQ(ELFOSABI_NONE
, convertNameToOSABI("none"));
21 // Test unrecognized strings.
22 EXPECT_EQ(ELFOSABI_NONE
, convertNameToOSABI(""));
23 EXPECT_EQ(ELFOSABI_NONE
, convertNameToOSABI("linux"));
25 EXPECT_EQ("gnu", convertOSABIToName(ELFOSABI_GNU
));
26 EXPECT_EQ("freebsd", convertOSABIToName(ELFOSABI_FREEBSD
));
27 EXPECT_EQ("standalone", convertOSABIToName(ELFOSABI_STANDALONE
));
28 EXPECT_EQ("none", convertOSABIToName(ELFOSABI_NONE
));
29 // Test unrecognized values.
30 EXPECT_EQ("none", convertOSABIToName(0xfe));