diff options
| author | Rui Ueyama <ruiu@google.com> | 2013-06-11 23:07:43 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2013-06-11 23:07:43 +0000 |
| commit | 9f56df8e4368b1408f2b446df6607aa5d381dfdf (patch) | |
| tree | 68ce08b57460bc0a7d36b9ca856b972224077d4e /lld/unittests/DriverTests/DarwinLdDriverTest.cpp | |
| parent | e34ade798647d528600ff885216e84666e9184d8 (diff) | |
| download | bcm5719-llvm-9f56df8e4368b1408f2b446df6607aa5d381dfdf.tar.gz bcm5719-llvm-9f56df8e4368b1408f2b446df6607aa5d381dfdf.zip | |
[Darwin][Driver] Add unit tests.
llvm-svn: 183806
Diffstat (limited to 'lld/unittests/DriverTests/DarwinLdDriverTest.cpp')
| -rw-r--r-- | lld/unittests/DriverTests/DarwinLdDriverTest.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/lld/unittests/DriverTests/DarwinLdDriverTest.cpp b/lld/unittests/DriverTests/DarwinLdDriverTest.cpp new file mode 100644 index 00000000000..303871990f5 --- /dev/null +++ b/lld/unittests/DriverTests/DarwinLdDriverTest.cpp @@ -0,0 +1,89 @@ +//===- lld/unittest/DarwinLdDriverTest.cpp --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief Darwin's ld driver tests. +/// +//===----------------------------------------------------------------------===// + +#include "DriverTest.h" + +#include "lld/ReaderWriter/MachOTargetInfo.h" +#include "../../lib/ReaderWriter/MachO/MachOFormat.hpp" + +using namespace llvm; +using namespace lld; + +namespace { + +class DarwinLdParserTest : public ParserTest<DarwinLdDriver, MachOTargetInfo> { +protected: + virtual MachOTargetInfo* doParse(int argc, const char **argv, + raw_ostream &diag) { + auto *info = new MachOTargetInfo(); + DarwinLdDriver::parse(argc, argv, *info, diag); + return info; + } +}; + +TEST_F(DarwinLdParserTest, Basic) { + parse("ld", "foo.o", "bar.o", nullptr); + EXPECT_FALSE(info->allowRemainingUndefines()); + EXPECT_FALSE(info->deadStrip()); + EXPECT_EQ(2, (int)inputFiles.size()); + EXPECT_EQ("foo.o", inputFiles[0]); + EXPECT_EQ("bar.o", inputFiles[1]); +} + +TEST_F(DarwinLdParserTest, Dylib) { + parse("ld", "-dylib", "foo.o", nullptr); + EXPECT_EQ(mach_o::MH_DYLIB, info->outputFileType()); +} + +TEST_F(DarwinLdParserTest, Relocatable) { + parse("ld", "-r", "foo.o", nullptr); + EXPECT_EQ(mach_o::MH_OBJECT, info->outputFileType()); +} + +TEST_F(DarwinLdParserTest, Bundle) { + parse("ld", "-bundle", "foo.o", nullptr); + EXPECT_EQ(mach_o::MH_BUNDLE, info->outputFileType()); +} + +TEST_F(DarwinLdParserTest, Preload) { + parse("ld", "-preload", "foo.o", nullptr); + EXPECT_EQ(mach_o::MH_PRELOAD, info->outputFileType()); +} + +TEST_F(DarwinLdParserTest, Static) { + parse("ld", "-static", "foo.o", nullptr); + EXPECT_EQ(mach_o::MH_EXECUTE, info->outputFileType()); +} + +TEST_F(DarwinLdParserTest, Entry) { + parse("ld", "-e", "entryFunc", "foo.o", nullptr); + EXPECT_EQ("entryFunc", info->entrySymbolName()); +} + +TEST_F(DarwinLdParserTest, OutputPath) { + parse("ld", "-o", "foo", "foo.o", nullptr); + EXPECT_EQ("foo", info->outputPath()); +} + +TEST_F(DarwinLdParserTest, DeadStrip) { + parse("ld", "-dead_strip", "foo.o", nullptr); + EXPECT_TRUE(info->deadStrip()); +} + +TEST_F(DarwinLdParserTest, Arch) { + parse("ld", "-arch", "x86_64", "foo.o", nullptr); + EXPECT_EQ(MachOTargetInfo::arch_x86_64, info->arch()); +} + +} // end anonymous namespace |

