@@ -25,14 +25,15 @@ class SymbolFileDWARFDebugMapTests : public testing::Test {
25
25
SubsystemRAII<ObjectFileELF, ObjectFileMachO> subsystems;
26
26
};
27
27
28
+ #ifdef __APPLE__
28
29
TEST_F (SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
29
- // Make sure we don't crash parsing a null unit DIE .
30
+ // The file header represents an arm64 Mach-O file .
30
31
const char *yamldata = R"(
31
32
--- !mach-o
32
33
FileHeader:
33
34
magic: 0xFEEDFACF
34
- cputype: 0x01000007
35
- cpusubtype: 0x80000003
35
+ cputype: 0x0100000C
36
+ cpusubtype: 0x00000000
36
37
filetype: 0x00000001
37
38
ncmds: 1
38
39
sizeofcmds: 152
@@ -69,15 +70,25 @@ TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
69
70
70
71
llvm::Expected<TestFile> file = TestFile::fromYaml (yamldata);
71
72
EXPECT_THAT_EXPECTED (file, llvm::Succeeded ());
72
- auto module_sp = std::make_shared<Module>(file->moduleSpec ());
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);
73
80
ASSERT_NE (module_sp, nullptr );
74
81
auto object_file = module_sp->GetObjectFile ();
75
82
ASSERT_NE (object_file, nullptr );
83
+
84
+ // The debug map should be non-null, because the file is Apple Mach-O.
76
85
auto debug_map =
77
86
SymbolFileDWARFDebugMap::CreateInstance (object_file->shared_from_this ());
78
87
ASSERT_NE (debug_map, nullptr );
79
88
}
89
+ #endif
80
90
91
+ #ifdef __linux__
81
92
TEST_F (SymbolFileDWARFDebugMapTests, CreateInstanceReturnNullForNonMachOFile) {
82
93
// Make sure we don't crash parsing a null unit DIE.
83
94
const char *yamldata = R"(
@@ -140,3 +151,4 @@ TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNullForNonMachOFile) {
140
151
SymbolFileDWARFDebugMap::CreateInstance (object_file->shared_from_this ());
141
152
ASSERT_EQ (debug_map, nullptr );
142
153
}
154
+ #endif
0 commit comments