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

#include "DriverTest.h"

#include "lld/ReaderWriter/ELFTargetInfo.h"

using namespace llvm;
using namespace lld;

namespace {

class GnuLdParserTest : public ParserTest<GnuLdDriver, ELFTargetInfo> {
protected:
  virtual ELFTargetInfo* doParse(int argc, const char **argv,
                                 raw_ostream &diag) {
    std::unique_ptr<ELFTargetInfo> info(GnuLdDriver::parse(argc, argv, diag));
    return info.release();
  }
};

TEST_F(GnuLdParserTest, Basic) {
  parse("ld", "infile.o", nullptr);
  ASSERT_TRUE(!!info);
  EXPECT_EQ("a.out", info->outputPath());
  EXPECT_EQ(1, (int)inputFiles.size());
  EXPECT_EQ("infile.o", inputFiles[0]);
  EXPECT_FALSE(info->outputYAML());
}

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

}  // end anonymous namespace
OpenPOWER on IntegriCloud