[Lldb-commits] [lldb] r290819 - [unittests] Split DWARF tests out of PDB, fix standalone build

Michal Gorny via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 2 10:20:33 PST 2017


Author: mgorny
Date: Mon Jan  2 12:20:33 2017
New Revision: 290819

URL: http://llvm.org/viewvc/llvm-project?rev=290819&view=rev
Log:
[unittests] Split DWARF tests out of PDB, fix standalone build

Split the PDB tests into DWARF test and actual PDB tests, the latter
requiring DIA SDK. Use the new LLVMConfig.cmake LLVM_ENABLE_DIA_SDK
symbol to enable the PDB tests rather than relying on
llvm/Config/config.h private include file that is not available when
building standalone.

Differential Revision: https://reviews.llvm.org/D26249

Added:
    lldb/trunk/unittests/SymbolFile/DWARF/
    lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt
    lldb/trunk/unittests/SymbolFile/DWARF/Inputs/
    lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp
      - copied, changed from r290688, lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp
    lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.exe
      - copied, changed from r290688, lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe
    lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
Removed:
    lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp
    lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe
Modified:
    lldb/trunk/unittests/SymbolFile/CMakeLists.txt
    lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt
    lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Modified: lldb/trunk/unittests/SymbolFile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/CMakeLists.txt?rev=290819&r1=290818&r2=290819&view=diff
==============================================================================
--- lldb/trunk/unittests/SymbolFile/CMakeLists.txt (original)
+++ lldb/trunk/unittests/SymbolFile/CMakeLists.txt Mon Jan  2 12:20:33 2017
@@ -1 +1,4 @@
-add_subdirectory(PDB)
+add_subdirectory(DWARF)
+if (LLVM_ENABLE_DIA_SDK)
+  add_subdirectory(PDB)
+endif()

Added: lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt?rev=290819&view=auto
==============================================================================
--- lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt (added)
+++ lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt Mon Jan  2 12:20:33 2017
@@ -0,0 +1,8 @@
+add_lldb_unittest(SymbolFileDWARFTests
+  SymbolFileDWARFTests.cpp
+  )
+
+set(test_inputs
+   test-dwarf.exe)
+
+add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")

Copied: lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp (from r290688, lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp?p2=lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp&p1=lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp&r1=290688&r2=290819&rev=290819&view=diff
==============================================================================
    (empty)

Copied: lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.exe (from r290688, lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.exe?p2=lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.exe&p1=lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe&r1=290688&r2=290819&rev=290819&view=diff
==============================================================================
    (empty)

Added: lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp?rev=290819&view=auto
==============================================================================
--- lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp (added)
+++ lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp Mon Jan  2 12:20:33 2017
@@ -0,0 +1,83 @@
+//===-- PythonDataObjectsTests.cpp ------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+#include "lldb/Core/Address.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/SymbolVendor.h"
+
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
+
+extern const char *TestMainArgv0;
+
+using namespace lldb_private;
+
+class SymbolFileDWARFTests : public testing::Test {
+public:
+  void SetUp() override {
+// Initialize and TearDown the plugin every time, so we get a brand new
+// AST every time so that modifications to the AST from each test don't
+// leak into the next test.
+    HostInfo::Initialize();
+    ObjectFilePECOFF::Initialize();
+    SymbolFileDWARF::Initialize();
+    ClangASTContext::Initialize();
+    SymbolFilePDB::Initialize();
+
+    llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0);
+    llvm::SmallString<128> inputs_folder = exe_folder;
+    llvm::sys::path::append(inputs_folder, "Inputs");
+
+    m_dwarf_test_exe = inputs_folder;
+    llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe");
+  }
+
+  void TearDown() override {
+    SymbolFilePDB::Terminate();
+    ClangASTContext::Initialize();
+    SymbolFileDWARF::Terminate();
+    ObjectFilePECOFF::Terminate();
+    HostInfo::Terminate();
+  }
+
+protected:
+  llvm::SmallString<128> m_dwarf_test_exe;
+};
+
+TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) {
+  // Test that when we have Dwarf debug info, SymbolFileDWARF is used.
+  FileSpec fspec(m_dwarf_test_exe.c_str(), false);
+  ArchSpec aspec("i686-pc-windows");
+  lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  EXPECT_NE(nullptr, plugin);
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  EXPECT_NE(nullptr, symfile);
+  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+
+  uint32_t expected_abilities = SymbolFile::kAllAbilities;
+  EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
+}

Modified: lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt?rev=290819&r1=290818&r2=290819&view=diff
==============================================================================
--- lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt (original)
+++ lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt Mon Jan  2 12:20:33 2017
@@ -5,8 +5,7 @@ add_lldb_unittest(SymbolFilePDBTests
 set(test_inputs
    test-pdb.exe
    test-pdb.pdb
-   test-dwarf.exe
    test-pdb-types.exe
    test-pdb-types.pdb)
 
-add_unittest_inputs(SymbolFilePDBTests "${test_inputs}")  
+add_unittest_inputs(SymbolFilePDBTests "${test_inputs}")

Removed: lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp?rev=290818&view=auto
==============================================================================
--- lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp (original)
+++ lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp (removed)
@@ -1,6 +0,0 @@
-// Compile with "cl /c /Zi /GR- test.cpp"
-// Link with "link test.obj /debug /nodefaultlib /entry:main /out:test.exe"
-
-int __cdecl _purecall(void) { return 0; }
-
-int main(int argc, char **argv) { return 0; }

Removed: lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe?rev=290818&view=auto
==============================================================================
Binary files lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe (original) and lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.exe (removed) differ

Modified: lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp?rev=290819&r1=290818&r2=290819&view=diff
==============================================================================
--- lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp (original)
+++ lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Mon Jan  2 12:20:33 2017
@@ -10,7 +10,6 @@
 #include "gtest/gtest.h"
 
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/Config/config.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
 #include "llvm/Support/FileSystem.h"
@@ -63,10 +62,8 @@ public:
     llvm::sys::path::append(inputs_folder, "Inputs");
 
     m_pdb_test_exe = inputs_folder;
-    m_dwarf_test_exe = inputs_folder;
     m_types_test_exe = inputs_folder;
     llvm::sys::path::append(m_pdb_test_exe, "test-pdb.exe");
-    llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe");
     llvm::sys::path::append(m_types_test_exe, "test-pdb-types.exe");
   }
 
@@ -84,7 +81,6 @@ public:
 
 protected:
   llvm::SmallString<128> m_pdb_test_exe;
-  llvm::SmallString<128> m_dwarf_test_exe;
   llvm::SmallString<128> m_types_test_exe;
 
   bool FileSpecMatchesAsBaseOrFull(const FileSpec &left,
@@ -154,29 +150,7 @@ protected:
   }
 };
 
-#if HAVE_DIA_SDK
-#define REQUIRES_DIA_SDK(TestName) TestName
-#else
-#define REQUIRES_DIA_SDK(TestName) DISABLED_##TestName
-#endif
-
-TEST_F(SymbolFilePDBTests, TestAbilitiesForDWARF) {
-  // Test that when we have Dwarf debug info, SymbolFileDWARF is used.
-  FileSpec fspec(m_dwarf_test_exe.c_str(), false);
-  ArchSpec aspec("i686-pc-windows");
-  lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
-
-  SymbolVendor *plugin = module->GetSymbolVendor();
-  EXPECT_NE(nullptr, plugin);
-  SymbolFile *symfile = plugin->GetSymbolFile();
-  EXPECT_NE(nullptr, symfile);
-  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
-
-  uint32_t expected_abilities = SymbolFile::kAllAbilities;
-  EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
-}
-
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestAbilitiesForPDB)) {
+TEST_F(SymbolFilePDBTests, TestAbilitiesForPDB) {
   // Test that when we have PDB debug info, SymbolFilePDB is used.
   FileSpec fspec(m_pdb_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
@@ -193,7 +167,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextBasename)) {
+TEST_F(SymbolFilePDBTests, TestResolveSymbolContextBasename) {
   // Test that attempting to call ResolveSymbolContext with only a basename
   // finds all full paths
   // with the same basename
@@ -213,7 +187,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec));
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextFullPath)) {
+TEST_F(SymbolFilePDBTests, TestResolveSymbolContextFullPath) {
   // Test that attempting to call ResolveSymbolContext with a full path only
   // finds the one source
   // file that matches the full path.
@@ -236,7 +210,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
 }
 
 TEST_F(SymbolFilePDBTests,
-       REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithInlines)) {
+       TestLookupOfHeaderFileWithInlines) {
   // Test that when looking up a header file via ResolveSymbolContext (i.e. a
   // file that was not by itself
   // compiled, but only contributes to the combined code of other source files),
@@ -264,8 +238,7 @@ TEST_F(SymbolFilePDBTests,
   }
 }
 
-TEST_F(SymbolFilePDBTests,
-       REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithNoInlines)) {
+TEST_F(SymbolFilePDBTests, TestLookupOfHeaderFileWithNoInlines) {
   // Test that when looking up a header file via ResolveSymbolContext (i.e. a
   // file that was not by itself
   // compiled, but only contributes to the combined code of other source files),
@@ -289,7 +262,7 @@ TEST_F(SymbolFilePDBTests,
   }
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchAll)) {
+TEST_F(SymbolFilePDBTests, TestLineTablesMatchAll) {
   // Test that when calling ResolveSymbolContext with a line number of 0, all
   // line entries from
   // the specified files are returned.
@@ -338,7 +311,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchSpecific)) {
+TEST_F(SymbolFilePDBTests, TestLineTablesMatchSpecific) {
   // Test that when calling ResolveSymbolContext with a specific line number,
   // only line entries
   // which match the requested line are returned.
@@ -390,7 +363,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestSimpleClassTypes)) {
+TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -413,7 +386,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
             udt_type->GetByteSize());
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNestedClassTypes)) {
+TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -436,7 +409,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
             udt_type->GetByteSize());
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace)) {
+TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -459,7 +432,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
             udt_type->GetByteSize());
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes)) {
+TEST_F(SymbolFilePDBTests, TestEnumTypes) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -492,21 +465,21 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   }
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestArrayTypes)) {
+TEST_F(SymbolFilePDBTests, TestArrayTypes) {
   // In order to get this test working, we need to support lookup by symbol
   // name.  Because array
   // types themselves do not have names, only the symbols have names (i.e. the
   // name of the array).
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestFunctionTypes)) {
+TEST_F(SymbolFilePDBTests, TestFunctionTypes) {
   // In order to get this test working, we need to support lookup by symbol
   // name.  Because array
   // types themselves do not have names, only the symbols have names (i.e. the
   // name of the array).
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs)) {
+TEST_F(SymbolFilePDBTests, TestTypedefs) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -540,7 +513,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   }
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestRegexNameMatch)) {
+TEST_F(SymbolFilePDBTests, TestRegexNameMatch) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -557,7 +530,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   EXPECT_EQ(num_results, results.GetSize());
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches)) {
+TEST_F(SymbolFilePDBTests, TestMaxMatches) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -584,7 +557,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_
   }
 }
 
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNullName)) {
+TEST_F(SymbolFilePDBTests, TestNullName) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
   lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);




More information about the lldb-commits mailing list