Skip to content

Commit dfe7da5

Browse files
committed
Update test
1 parent 57145ec commit dfe7da5

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ class SymbolFileDWARFDebugMapTests : public testing::Test {
2525
SubsystemRAII<ObjectFileELF, ObjectFileMachO> subsystems;
2626
};
2727

28-
#ifdef __APPLE__
2928
TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
30-
// The file header represents an arm64 Mach-O file.
29+
// A Mach-O file built for arm64 CPU type and macOS platform.
3130
const char *yamldata = R"(
3231
--- !mach-o
3332
FileHeader:
@@ -36,16 +35,22 @@ TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
3635
cpusubtype: 0x00000000
3736
filetype: 0x00000001
3837
ncmds: 1
39-
sizeofcmds: 152
38+
sizeofcmds: 176
4039
flags: 0x00002000
4140
reserved: 0x00000000
4241
LoadCommands:
42+
- cmd: LC_BUILD_VERSION
43+
cmdsize: 24
44+
platform: 1
45+
minos: 658944
46+
sdk: 658944
47+
ntools: 0
4348
- cmd: LC_SEGMENT_64
4449
cmdsize: 152
4550
segname: __TEXT
4651
vmaddr: 0
4752
vmsize: 4
48-
fileoff: 184
53+
fileoff: 208
4954
filesize: 4
5055
maxprot: 7
5156
initprot: 7
@@ -57,7 +62,7 @@ TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
5762
addr: 0x0000000000000000
5863
content: 'AABBCCDD'
5964
size: 4
60-
offset: 184
65+
offset: 208
6166
align: 0
6267
reloff: 0x00000000
6368
nreloc: 0
@@ -68,29 +73,22 @@ TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
6873
...
6974
)";
7075

76+
// Set up
7177
llvm::Expected<TestFile> file = TestFile::fromYaml(yamldata);
7278
EXPECT_THAT_EXPECTED(file, llvm::Succeeded());
73-
74-
// Set the triple explicitly.
75-
ModuleSpec module_spec = file->moduleSpec();
76-
module_spec.GetArchitecture().SetTriple("arm64-apple-macosx15.0.0");
77-
78-
// Create module and get object file.
79-
auto module_sp = std::make_shared<Module>(module_spec);
79+
auto module_sp = std::make_shared<Module>(file->moduleSpec());
8080
ASSERT_NE(module_sp, nullptr);
8181
auto object_file = module_sp->GetObjectFile();
8282
ASSERT_NE(object_file, nullptr);
8383

84-
// The debug map should be non-null, because the file is Apple Mach-O.
84+
// The debug map should be non-null for Mach-O file.
8585
auto debug_map =
8686
SymbolFileDWARFDebugMap::CreateInstance(object_file->shared_from_this());
8787
ASSERT_NE(debug_map, nullptr);
8888
}
89-
#endif
9089

91-
#ifdef __linux__
9290
TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNullForNonMachOFile) {
93-
// Make sure we don't crash parsing a null unit DIE.
91+
// An ELF file.
9492
const char *yamldata = R"(
9593
--- !ELF
9694
FileHeader:
@@ -141,14 +139,16 @@ TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNullForNonMachOFile) {
141139
Length: 0
142140
)";
143141

142+
// Set up
144143
llvm::Expected<TestFile> file = TestFile::fromYaml(yamldata);
145144
EXPECT_THAT_EXPECTED(file, llvm::Succeeded());
146145
auto module_sp = std::make_shared<Module>(file->moduleSpec());
147146
ASSERT_NE(module_sp, nullptr);
148147
auto object_file = module_sp->GetObjectFile();
149148
ASSERT_NE(object_file, nullptr);
149+
150+
// The debug map should be null for non-Mach-O (ELF) file.
150151
auto debug_map =
151152
SymbolFileDWARFDebugMap::CreateInstance(object_file->shared_from_this());
152153
ASSERT_EQ(debug_map, nullptr);
153154
}
154-
#endif

0 commit comments

Comments
 (0)