• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- ELFBinaryReaderTest.cpp --------------------------------------------===//
2 //
3 //                     The MCLinker Project
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include "mcld/LD/ELFBinaryReader.h"
10 #include "mcld/Module.h"
11 #include "mcld/LinkerScript.h"
12 #include "mcld/LinkerConfig.h"
13 #include "mcld/IRBuilder.h"
14 #include "mcld/GeneralOptions.h"
15 #include "mcld/MC/Input.h"
16 
17 #include "ELFBinaryReaderTest.h"
18 
19 using namespace mcld;
20 using namespace mcld::test;
21 
22 // Constructor can do set-up work for all test here.
ELFBinaryReaderTest()23 ELFBinaryReaderTest::ELFBinaryReaderTest() {
24 }
25 
26 // Destructor can do clean-up work that doesn't throw exceptions here.
~ELFBinaryReaderTest()27 ELFBinaryReaderTest::~ELFBinaryReaderTest() {
28 }
29 
30 // SetUp() will be called immediately before each test.
SetUp()31 void ELFBinaryReaderTest::SetUp() {
32 }
33 
34 // TearDown() will be called immediately after each test.
TearDown()35 void ELFBinaryReaderTest::TearDown() {
36 }
37 
38 //===----------------------------------------------------------------------===//
39 // Testcases
40 //===----------------------------------------------------------------------===//
TEST_F(ELFBinaryReaderTest,is_myformat)41 TEST_F(ELFBinaryReaderTest, is_myformat) {
42   LinkerScript script;
43   Module module("test", script);
44   LinkerConfig config;
45   IRBuilder builder(module, config);
46   ELFBinaryReader* reader = new ELFBinaryReader(builder, config);
47 
48   Input input("test.bin");
49 
50   bool doContinue = false;
51   config.options().setBinaryInput();
52   ASSERT_TRUE(reader->isMyFormat(input, doContinue));
53 
54   config.options().setBinaryInput(false);
55   ASSERT_FALSE(reader->isMyFormat(input, doContinue));
56 
57   delete reader;
58 }
59