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