mgorny retitled this revision from "[unittests] Avoid the dependency on private LLVM headers outside MSVC" to "[unittests] Split DWARF tests out of PDB, fix standalone build". mgorny updated the summary for this revision. mgorny updated this revision to Diff 76766. mgorny added a comment. Herald added a subscriber: modocache.
Here's an updated patch. I've decided to go for the initial idea of splitting the tests, combined with LLVMConfig update. https://reviews.llvm.org/D26255 updates LLVM to include LLVM_ENABLE_DIA_SDK in LLVMConfig.cmake (it already provides similar variables). The variable is also still used to set HAVE_DIA_SDK in config.h, so old versions of LLDB will continue to build fine in-tree. This one splits the previous test into DWARF and actual PDB tests. The DWARF test is run unconditionally, while the other is run only when DIA SDK is available. As I said, I don't have Windows handy, so I wasn't able to test the latter part. However, unless I failed at syntax when modifying it, it should work (I only removed the include, the DWARF test and file, and removed the DIA SDK magic). https://reviews.llvm.org/D26249 Files: unittests/SymbolFile/CMakeLists.txt unittests/SymbolFile/DWARF/CMakeLists.txt unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp unittests/SymbolFile/DWARF/Inputs/test-dwarf.exe unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp unittests/SymbolFile/PDB/CMakeLists.txt unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp unittests/SymbolFile/PDB/Inputs/test-dwarf.exe unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp =================================================================== --- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -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 @@ 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 @@ 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 @@ } }; -#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 @@ 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 @@ 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_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, - 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, 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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_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 @@ 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_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); Index: unittests/SymbolFile/PDB/CMakeLists.txt =================================================================== --- unittests/SymbolFile/PDB/CMakeLists.txt +++ unittests/SymbolFile/PDB/CMakeLists.txt @@ -5,8 +5,7 @@ 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}") Index: unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp =================================================================== --- /dev/null +++ unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp @@ -0,0 +1,96 @@ +//===-- 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" + +#if defined(_MSC_VER) +#include "lldb/Host/windows/windows.h" +#include <objbase.h> +#endif + +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. +#if defined(_MSC_VER) + ::CoInitializeEx(nullptr, COINIT_MULTITHREADED); +#endif + + 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(); + +#if defined(_MSC_VER) + ::CoUninitialize(); +#endif + } + +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()); +} Index: unittests/SymbolFile/DWARF/CMakeLists.txt =================================================================== --- /dev/null +++ unittests/SymbolFile/DWARF/CMakeLists.txt @@ -0,0 +1,8 @@ +add_lldb_unittest(SymbolFileDWARFTests + SymbolFileDWARFTests.cpp + ) + +set(test_inputs + test-dwarf.exe) + +add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}") Index: unittests/SymbolFile/CMakeLists.txt =================================================================== --- unittests/SymbolFile/CMakeLists.txt +++ unittests/SymbolFile/CMakeLists.txt @@ -1 +1,4 @@ -add_subdirectory(PDB) +add_subdirectory(DWARF) +if (LLVM_ENABLE_DIA_SDK) + add_subdirectory(PDB) +endif()
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits