summaryrefslogtreecommitdiffstats
path: root/lld/unittests/DriverTests/GnuLdDriverTest.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-01-28 18:38:50 +0000
committerRui Ueyama <ruiu@google.com>2015-01-28 18:38:50 +0000
commit0b55151d3e191cebe5083ba1e587f5c53c32d918 (patch)
tree838a35065742ca86f06bc6c7d48a61ce7e9e70d5 /lld/unittests/DriverTests/GnuLdDriverTest.cpp
parentd558ffaf69e252c22415e4f622cc3ab5d8373266 (diff)
downloadbcm5719-llvm-0b55151d3e191cebe5083ba1e587f5c53c32d918.tar.gz
bcm5719-llvm-0b55151d3e191cebe5083ba1e587f5c53c32d918.zip
Add a unit test for LinkerScript.
llvm-svn: 227341
Diffstat (limited to 'lld/unittests/DriverTests/GnuLdDriverTest.cpp')
-rw-r--r--lld/unittests/DriverTests/GnuLdDriverTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lld/unittests/DriverTests/GnuLdDriverTest.cpp b/lld/unittests/DriverTests/GnuLdDriverTest.cpp
index a1445ab95b7..b5a819cf916 100644
--- a/lld/unittests/DriverTests/GnuLdDriverTest.cpp
+++ b/lld/unittests/DriverTests/GnuLdDriverTest.cpp
@@ -14,6 +14,7 @@
#include "DriverTest.h"
#include "lld/ReaderWriter/ELFLinkingContext.h"
+#include "llvm/Support/MemoryBuffer.h"
using namespace llvm;
using namespace lld;
@@ -145,3 +146,21 @@ TEST_F(GnuLdParserTest, DefsymMisssingSymbol) {
TEST_F(GnuLdParserTest, DefsymMisssingValue) {
EXPECT_FALSE(parse("ld", "a.o", "--defsym=sym=", nullptr));
}
+
+// Linker script
+
+TEST_F(GnuLdParserTest, LinkerScriptGroup) {
+ parse("ld", "a.o", nullptr);
+ std::unique_ptr<MemoryBuffer> mb = MemoryBuffer::getMemBuffer(
+ "GROUP(/x /y)", "foo.so");
+ std::string s;
+ raw_string_ostream out(s);
+ std::error_code ec = GnuLdDriver::evalLinkerScript(
+ *_context, std::move(mb), out);
+ EXPECT_FALSE(ec);
+ std::vector<std::unique_ptr<Node>> &nodes = _context->getNodes();
+ EXPECT_EQ((size_t)4, nodes.size());
+ EXPECT_EQ("/x", cast<FileNode>(nodes[1].get())->getFile()->path());
+ EXPECT_EQ("/y", cast<FileNode>(nodes[2].get())->getFile()->path());
+ EXPECT_EQ(2, cast<GroupEnd>(nodes[3].get())->getSize());
+}
OpenPOWER on IntegriCloud