Skip to content

Commit 95e2629

Browse files
committed
[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 llvm-svn: 290819
1 parent 89b6f16 commit 95e2629

File tree

7 files changed

+113
-47
lines changed

7 files changed

+113
-47
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
add_subdirectory(PDB)
1+
add_subdirectory(DWARF)
2+
if (LLVM_ENABLE_DIA_SDK)
3+
add_subdirectory(PDB)
4+
endif()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_lldb_unittest(SymbolFileDWARFTests
2+
SymbolFileDWARFTests.cpp
3+
)
4+
5+
set(test_inputs
6+
test-dwarf.exe)
7+
8+
add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//===-- PythonDataObjectsTests.cpp ------------------------------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include "gtest/gtest.h"
11+
12+
#include "llvm/ADT/STLExtras.h"
13+
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
14+
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
15+
#include "llvm/Support/FileSystem.h"
16+
#include "llvm/Support/Path.h"
17+
18+
#include "lldb/Core/Address.h"
19+
#include "lldb/Core/ArchSpec.h"
20+
#include "lldb/Core/Module.h"
21+
#include "lldb/Core/ModuleSpec.h"
22+
#include "lldb/Host/FileSpec.h"
23+
#include "lldb/Host/HostInfo.h"
24+
#include "lldb/Symbol/ClangASTContext.h"
25+
#include "lldb/Symbol/CompileUnit.h"
26+
#include "lldb/Symbol/LineTable.h"
27+
#include "lldb/Symbol/SymbolVendor.h"
28+
29+
#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
30+
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
31+
#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
32+
33+
extern const char *TestMainArgv0;
34+
35+
using namespace lldb_private;
36+
37+
class SymbolFileDWARFTests : public testing::Test {
38+
public:
39+
void SetUp() override {
40+
// Initialize and TearDown the plugin every time, so we get a brand new
41+
// AST every time so that modifications to the AST from each test don't
42+
// leak into the next test.
43+
HostInfo::Initialize();
44+
ObjectFilePECOFF::Initialize();
45+
SymbolFileDWARF::Initialize();
46+
ClangASTContext::Initialize();
47+
SymbolFilePDB::Initialize();
48+
49+
llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0);
50+
llvm::SmallString<128> inputs_folder = exe_folder;
51+
llvm::sys::path::append(inputs_folder, "Inputs");
52+
53+
m_dwarf_test_exe = inputs_folder;
54+
llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe");
55+
}
56+
57+
void TearDown() override {
58+
SymbolFilePDB::Terminate();
59+
ClangASTContext::Initialize();
60+
SymbolFileDWARF::Terminate();
61+
ObjectFilePECOFF::Terminate();
62+
HostInfo::Terminate();
63+
}
64+
65+
protected:
66+
llvm::SmallString<128> m_dwarf_test_exe;
67+
};
68+
69+
TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) {
70+
// Test that when we have Dwarf debug info, SymbolFileDWARF is used.
71+
FileSpec fspec(m_dwarf_test_exe.c_str(), false);
72+
ArchSpec aspec("i686-pc-windows");
73+
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
74+
75+
SymbolVendor *plugin = module->GetSymbolVendor();
76+
EXPECT_NE(nullptr, plugin);
77+
SymbolFile *symfile = plugin->GetSymbolFile();
78+
EXPECT_NE(nullptr, symfile);
79+
EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
80+
81+
uint32_t expected_abilities = SymbolFile::kAllAbilities;
82+
EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
83+
}

lldb/unittests/SymbolFile/PDB/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ add_lldb_unittest(SymbolFilePDBTests
55
set(test_inputs
66
test-pdb.exe
77
test-pdb.pdb
8-
test-dwarf.exe
98
test-pdb-types.exe
109
test-pdb-types.pdb)
1110

12-
add_unittest_inputs(SymbolFilePDBTests "${test_inputs}")
11+
add_unittest_inputs(SymbolFilePDBTests "${test_inputs}")

lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "gtest/gtest.h"
1111

1212
#include "llvm/ADT/STLExtras.h"
13-
#include "llvm/Config/config.h"
1413
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
1514
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
1615
#include "llvm/Support/FileSystem.h"
@@ -63,10 +62,8 @@ class SymbolFilePDBTests : public testing::Test {
6362
llvm::sys::path::append(inputs_folder, "Inputs");
6463

6564
m_pdb_test_exe = inputs_folder;
66-
m_dwarf_test_exe = inputs_folder;
6765
m_types_test_exe = inputs_folder;
6866
llvm::sys::path::append(m_pdb_test_exe, "test-pdb.exe");
69-
llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe");
7067
llvm::sys::path::append(m_types_test_exe, "test-pdb-types.exe");
7168
}
7269

@@ -84,7 +81,6 @@ class SymbolFilePDBTests : public testing::Test {
8481

8582
protected:
8683
llvm::SmallString<128> m_pdb_test_exe;
87-
llvm::SmallString<128> m_dwarf_test_exe;
8884
llvm::SmallString<128> m_types_test_exe;
8985

9086
bool FileSpecMatchesAsBaseOrFull(const FileSpec &left,
@@ -154,29 +150,7 @@ class SymbolFilePDBTests : public testing::Test {
154150
}
155151
};
156152

157-
#if HAVE_DIA_SDK
158-
#define REQUIRES_DIA_SDK(TestName) TestName
159-
#else
160-
#define REQUIRES_DIA_SDK(TestName) DISABLED_##TestName
161-
#endif
162-
163-
TEST_F(SymbolFilePDBTests, TestAbilitiesForDWARF) {
164-
// Test that when we have Dwarf debug info, SymbolFileDWARF is used.
165-
FileSpec fspec(m_dwarf_test_exe.c_str(), false);
166-
ArchSpec aspec("i686-pc-windows");
167-
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
168-
169-
SymbolVendor *plugin = module->GetSymbolVendor();
170-
EXPECT_NE(nullptr, plugin);
171-
SymbolFile *symfile = plugin->GetSymbolFile();
172-
EXPECT_NE(nullptr, symfile);
173-
EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
174-
175-
uint32_t expected_abilities = SymbolFile::kAllAbilities;
176-
EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
177-
}
178-
179-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestAbilitiesForPDB)) {
153+
TEST_F(SymbolFilePDBTests, TestAbilitiesForPDB) {
180154
// Test that when we have PDB debug info, SymbolFilePDB is used.
181155
FileSpec fspec(m_pdb_test_exe.c_str(), false);
182156
ArchSpec aspec("i686-pc-windows");
@@ -193,7 +167,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestAbilitiesForPDB)) {
193167
EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
194168
}
195169

196-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextBasename)) {
170+
TEST_F(SymbolFilePDBTests, TestResolveSymbolContextBasename) {
197171
// Test that attempting to call ResolveSymbolContext with only a basename
198172
// finds all full paths
199173
// with the same basename
@@ -213,7 +187,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextBasename)) {
213187
EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec));
214188
}
215189

216-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextFullPath)) {
190+
TEST_F(SymbolFilePDBTests, TestResolveSymbolContextFullPath) {
217191
// Test that attempting to call ResolveSymbolContext with a full path only
218192
// finds the one source
219193
// file that matches the full path.
@@ -236,7 +210,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextFullPath)) {
236210
}
237211

238212
TEST_F(SymbolFilePDBTests,
239-
REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithInlines)) {
213+
TestLookupOfHeaderFileWithInlines) {
240214
// Test that when looking up a header file via ResolveSymbolContext (i.e. a
241215
// file that was not by itself
242216
// compiled, but only contributes to the combined code of other source files),
@@ -264,8 +238,7 @@ TEST_F(SymbolFilePDBTests,
264238
}
265239
}
266240

267-
TEST_F(SymbolFilePDBTests,
268-
REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithNoInlines)) {
241+
TEST_F(SymbolFilePDBTests, TestLookupOfHeaderFileWithNoInlines) {
269242
// Test that when looking up a header file via ResolveSymbolContext (i.e. a
270243
// file that was not by itself
271244
// compiled, but only contributes to the combined code of other source files),
@@ -289,7 +262,7 @@ TEST_F(SymbolFilePDBTests,
289262
}
290263
}
291264

292-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchAll)) {
265+
TEST_F(SymbolFilePDBTests, TestLineTablesMatchAll) {
293266
// Test that when calling ResolveSymbolContext with a line number of 0, all
294267
// line entries from
295268
// the specified files are returned.
@@ -338,7 +311,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchAll)) {
338311
VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);
339312
}
340313

341-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchSpecific)) {
314+
TEST_F(SymbolFilePDBTests, TestLineTablesMatchSpecific) {
342315
// Test that when calling ResolveSymbolContext with a specific line number,
343316
// only line entries
344317
// which match the requested line are returned.
@@ -390,7 +363,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchSpecific)) {
390363
VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
391364
}
392365

393-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestSimpleClassTypes)) {
366+
TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
394367
FileSpec fspec(m_types_test_exe.c_str(), false);
395368
ArchSpec aspec("i686-pc-windows");
396369
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -413,7 +386,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestSimpleClassTypes)) {
413386
udt_type->GetByteSize());
414387
}
415388

416-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNestedClassTypes)) {
389+
TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
417390
FileSpec fspec(m_types_test_exe.c_str(), false);
418391
ArchSpec aspec("i686-pc-windows");
419392
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -436,7 +409,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNestedClassTypes)) {
436409
udt_type->GetByteSize());
437410
}
438411

439-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace)) {
412+
TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
440413
FileSpec fspec(m_types_test_exe.c_str(), false);
441414
ArchSpec aspec("i686-pc-windows");
442415
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -459,7 +432,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace)) {
459432
udt_type->GetByteSize());
460433
}
461434

462-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes)) {
435+
TEST_F(SymbolFilePDBTests, TestEnumTypes) {
463436
FileSpec fspec(m_types_test_exe.c_str(), false);
464437
ArchSpec aspec("i686-pc-windows");
465438
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -492,21 +465,21 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes)) {
492465
}
493466
}
494467

495-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestArrayTypes)) {
468+
TEST_F(SymbolFilePDBTests, TestArrayTypes) {
496469
// In order to get this test working, we need to support lookup by symbol
497470
// name. Because array
498471
// types themselves do not have names, only the symbols have names (i.e. the
499472
// name of the array).
500473
}
501474

502-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestFunctionTypes)) {
475+
TEST_F(SymbolFilePDBTests, TestFunctionTypes) {
503476
// In order to get this test working, we need to support lookup by symbol
504477
// name. Because array
505478
// types themselves do not have names, only the symbols have names (i.e. the
506479
// name of the array).
507480
}
508481

509-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs)) {
482+
TEST_F(SymbolFilePDBTests, TestTypedefs) {
510483
FileSpec fspec(m_types_test_exe.c_str(), false);
511484
ArchSpec aspec("i686-pc-windows");
512485
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -540,7 +513,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs)) {
540513
}
541514
}
542515

543-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestRegexNameMatch)) {
516+
TEST_F(SymbolFilePDBTests, TestRegexNameMatch) {
544517
FileSpec fspec(m_types_test_exe.c_str(), false);
545518
ArchSpec aspec("i686-pc-windows");
546519
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -557,7 +530,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestRegexNameMatch)) {
557530
EXPECT_EQ(num_results, results.GetSize());
558531
}
559532

560-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches)) {
533+
TEST_F(SymbolFilePDBTests, TestMaxMatches) {
561534
FileSpec fspec(m_types_test_exe.c_str(), false);
562535
ArchSpec aspec("i686-pc-windows");
563536
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
@@ -584,7 +557,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches)) {
584557
}
585558
}
586559

587-
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNullName)) {
560+
TEST_F(SymbolFilePDBTests, TestNullName) {
588561
FileSpec fspec(m_types_test_exe.c_str(), false);
589562
ArchSpec aspec("i686-pc-windows");
590563
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

0 commit comments

Comments
 (0)