[lld] r198974 - [PECOFF] Add a unit test for r198925.
Rui Ueyama
ruiu at google.com
Fri Jan 10 15:29:12 PST 2014
Author: ruiu
Date: Fri Jan 10 17:29:12 2014
New Revision: 198974
URL: http://llvm.org/viewvc/llvm-project?rev=198974&view=rev
Log:
[PECOFF] Add a unit test for r198925.
Added:
lld/trunk/unittests/DriverTests/WinLinkModuleDefTest.cpp
Modified:
lld/trunk/unittests/DriverTests/CMakeLists.txt
Modified: lld/trunk/unittests/DriverTests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/CMakeLists.txt?rev=198974&r1=198973&r2=198974&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/CMakeLists.txt (original)
+++ lld/trunk/unittests/DriverTests/CMakeLists.txt Fri Jan 10 17:29:12 2014
@@ -3,6 +3,7 @@ add_lld_unittest(DriverTests
GnuLdDriverTest.cpp
DarwinLdDriverTest.cpp
WinLinkDriverTest.cpp
+ WinLinkModuleDefTest.cpp
InputGraphTest.cpp
)
Added: lld/trunk/unittests/DriverTests/WinLinkModuleDefTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkModuleDefTest.cpp?rev=198974&view=auto
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkModuleDefTest.cpp (added)
+++ lld/trunk/unittests/DriverTests/WinLinkModuleDefTest.cpp Fri Jan 10 17:29:12 2014
@@ -0,0 +1,61 @@
+//===- lld/unittest/WinLinkModuleDefTest.cpp ------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+
+#include "gtest/gtest.h"
+#include "lld/Driver/WinLinkModuleDef.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+using namespace llvm;
+using namespace lld;
+
+class ParserTest : public testing::Test {
+protected:
+ bool parse(const char *contents,
+ std::vector<PECOFFLinkingContext::ExportDesc> &ret) {
+ auto membuf =
+ std::unique_ptr<MemoryBuffer>(MemoryBuffer::getMemBuffer(contents));
+ moduledef::Lexer lexer(std::move(membuf));
+ moduledef::Parser parser(lexer);
+ return parser.parse(ret);
+ }
+};
+
+TEST_F(ParserTest, Exports) {
+ std::vector<PECOFFLinkingContext::ExportDesc> exports;
+ EXPECT_TRUE(parse("EXPORTS\n"
+ " sym1\n"
+ " sym2 @5\n"
+ " sym3 @8 NONAME\n"
+ " sym4 DATA\n"
+ " sym5 @10 NONAME DATA\n",
+ exports));
+ EXPECT_EQ(5U, exports.size());
+ EXPECT_EQ(exports[0].name, "sym1");
+ EXPECT_EQ(exports[0].ordinal, -1);
+ EXPECT_EQ(exports[0].noname, false);
+ EXPECT_EQ(exports[0].isData, false);
+ EXPECT_EQ(exports[1].name, "sym2");
+ EXPECT_EQ(exports[1].ordinal, 5);
+ EXPECT_EQ(exports[1].noname, false);
+ EXPECT_EQ(exports[1].isData, false);
+ EXPECT_EQ(exports[2].name, "sym3");
+ EXPECT_EQ(exports[2].ordinal, 8);
+ EXPECT_EQ(exports[2].noname, true);
+ EXPECT_EQ(exports[2].isData, false);
+ EXPECT_EQ(exports[3].name, "sym4");
+ EXPECT_EQ(exports[3].ordinal, -1);
+ EXPECT_EQ(exports[3].noname, false);
+ EXPECT_EQ(exports[3].isData, true);
+ EXPECT_EQ(exports[4].name, "sym5");
+ EXPECT_EQ(exports[4].ordinal, 10);
+ EXPECT_EQ(exports[4].noname, true);
+ EXPECT_EQ(exports[4].isData, true);
+}
More information about the llvm-commits
mailing list