blob: 3fe9f3f5e95a0ad15d8588ed068380eb4870c51c [file] [log] [blame]
Stephen Hinesf33f6de2014-02-14 18:00:16 -08001//===- 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//===----------------------------------------------------------------------===//
Stephen Hines37b74a32014-11-26 18:48:20 -08009#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"
Stephen Hinesf33f6de2014-02-14 18:00:16 -080016
17#include "ELFBinaryReaderTest.h"
18
19using namespace mcld;
20using namespace mcld::test;
21
Stephen Hinesf33f6de2014-02-14 18:00:16 -080022// Constructor can do set-up work for all test here.
Stephen Hines37b74a32014-11-26 18:48:20 -080023ELFBinaryReaderTest::ELFBinaryReaderTest() {
Stephen Hinesf33f6de2014-02-14 18:00:16 -080024}
25
26// Destructor can do clean-up work that doesn't throw exceptions here.
Stephen Hines37b74a32014-11-26 18:48:20 -080027ELFBinaryReaderTest::~ELFBinaryReaderTest() {
Stephen Hinesf33f6de2014-02-14 18:00:16 -080028}
29
30// SetUp() will be called immediately before each test.
Stephen Hines37b74a32014-11-26 18:48:20 -080031void ELFBinaryReaderTest::SetUp() {
Stephen Hinesf33f6de2014-02-14 18:00:16 -080032}
33
34// TearDown() will be called immediately after each test.
Stephen Hines37b74a32014-11-26 18:48:20 -080035void ELFBinaryReaderTest::TearDown() {
Stephen Hinesf33f6de2014-02-14 18:00:16 -080036}
37
38//===----------------------------------------------------------------------===//
39// Testcases
40//===----------------------------------------------------------------------===//
Stephen Hines37b74a32014-11-26 18:48:20 -080041TEST_F(ELFBinaryReaderTest, is_myformat) {
Stephen Hinesf33f6de2014-02-14 18:00:16 -080042 LinkerScript script;
43 Module module("test", script);
44 LinkerConfig config;
45 IRBuilder builder(module, config);
Stephen Hines37b74a32014-11-26 18:48:20 -080046 ELFBinaryReader* reader = new ELFBinaryReader(builder, config);
Stephen Hinesf33f6de2014-02-14 18:00:16 -080047
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}