From c141c8c59ad90c0ca4e65294e85dea2f3074bf4d Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 6 Apr 2014 21:15:05 +0000 Subject: [ELF] Fix driver bug. GNU LD-comptaible driver wrongly requires a space after '=' for a few options such as "-init=" or "-entry=". This patch is to fix that bug and add a few tests for it. llvm-svn: 205693 --- lld/unittests/DriverTests/GnuLdDriverTest.cpp | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'lld/unittests/DriverTests') diff --git a/lld/unittests/DriverTests/GnuLdDriverTest.cpp b/lld/unittests/DriverTests/GnuLdDriverTest.cpp index 3e01a032a16..f1b63904e62 100644 --- a/lld/unittests/DriverTests/GnuLdDriverTest.cpp +++ b/lld/unittests/DriverTests/GnuLdDriverTest.cpp @@ -40,6 +40,43 @@ TEST_F(GnuLdParserTest, Empty) { EXPECT_EQ("No input files\n", errorMessage()); } +// --entry + +TEST_F(GnuLdParserTest, Entry) { + EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "--entry", "foo", + nullptr)); + EXPECT_EQ("foo", _context->entrySymbolName()); +} + +TEST_F(GnuLdParserTest, EntryShort) { + EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "-e", "foo", + nullptr)); + EXPECT_EQ("foo", _context->entrySymbolName()); +} + +TEST_F(GnuLdParserTest, EntryJoined) { + EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "--entry=foo", + nullptr)); + EXPECT_EQ("foo", _context->entrySymbolName()); +} + +// --init + +TEST_F(GnuLdParserTest, Init) { + EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "-init", "foo", + "-init", "bar", nullptr)); + EXPECT_EQ(2, _context->initFunctions().size()); + EXPECT_EQ("foo", _context->initFunctions()[0]); + EXPECT_EQ("bar", _context->initFunctions()[1]); +} + +TEST_F(GnuLdParserTest, InitJoined) { + EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "-init=foo", + nullptr)); + EXPECT_EQ(1, _context->initFunctions().size()); + EXPECT_EQ("foo", _context->initFunctions()[0]); +} + // --soname TEST_F(GnuLdParserTest, SOName) { -- cgit v1.2.1