diff options
| author | Rui Ueyama <ruiu@google.com> | 2013-05-31 02:12:34 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2013-05-31 02:12:34 +0000 |
| commit | 7eb1d49a589d5b87cd097f74eba48481f99a02d2 (patch) | |
| tree | cff5dcd8620b98df4aa877c3c1b663f48dd34bbc /lld/unittests/DriverTests/GnuLdDriverTest.cpp | |
| parent | fc3d80bda15098c48fb615662d5fc42a9b390c28 (diff) | |
| download | bcm5719-llvm-7eb1d49a589d5b87cd097f74eba48481f99a02d2.tar.gz bcm5719-llvm-7eb1d49a589d5b87cd097f74eba48481f99a02d2.zip | |
[Driver] Add unit tests for GnuLdDriver.
llvm-svn: 182980
Diffstat (limited to 'lld/unittests/DriverTests/GnuLdDriverTest.cpp')
| -rw-r--r-- | lld/unittests/DriverTests/GnuLdDriverTest.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lld/unittests/DriverTests/GnuLdDriverTest.cpp b/lld/unittests/DriverTests/GnuLdDriverTest.cpp new file mode 100644 index 00000000000..2483559cd58 --- /dev/null +++ b/lld/unittests/DriverTests/GnuLdDriverTest.cpp @@ -0,0 +1,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 |

