summaryrefslogtreecommitdiffstats
path: root/lld/unittests/DriverTests/GnuLdDriverTest.cpp
blob: 00cfa9558c1474d161a2183028490496d5d0fe29 (plain)
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
//===- lld/unittest/GnuLdDriverTest.cpp -----------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief GNU ld driver tests.
///
//===----------------------------------------------------------------------===//

#include "DriverTest.h"

#include "lld/ReaderWriter/ELFTargetInfo.h"

using namespace llvm;
using namespace lld;

namespace {

class GnuLdParserTest : public ParserTest<
                                GnuLdDriver, std::unique_ptr<ELFTargetInfo> > {
protected:
  virtual const TargetInfo *targetInfo() {
    return _info.get();
  }
};

TEST_F(GnuLdParserTest, Empty) {
  EXPECT_TRUE(parse("ld", nullptr));
  EXPECT_EQ(targetInfo(), nullptr);
  EXPECT_EQ("No input files\n", errorMessage());
}

TEST_F(GnuLdParserTest, Basic) {
  EXPECT_FALSE(parse("ld", "infile.o", nullptr));
  EXPECT_NE(targetInfo(), nullptr);
  EXPECT_EQ("a.out", targetInfo()->outputPath());
  EXPECT_EQ(1, inputFileCount());
  EXPECT_EQ("infile.o", inputFile(0));
  EXPECT_FALSE(_info->outputYAML());
}

TEST_F(GnuLdParserTest, ManyOptions) {
  EXPECT_FALSE(parse("ld", "-entry", "_start", "-o", "outfile",
        "-emit-yaml", "infile.o", nullptr));
  EXPECT_NE(targetInfo(), nullptr);
  EXPECT_EQ("outfile", targetInfo()->outputPath());
  EXPECT_EQ("_start", targetInfo()->entrySymbolName());
  EXPECT_TRUE(_info->outputYAML());
}

}  // end anonymous namespace
OpenPOWER on IntegriCloud