Skip to content

Commit 8130166

Browse files
committed
[BTF] Fix BTFParserTest.cpp for big-endian after D149058
Ideally BTFParserTest.cpp should test both little-endian and big-endian, but I push this commit to fix the immediate issue for now.
1 parent dd2cfab commit 8130166

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "llvm/DebugInfo/BTF/BTFContext.h"
1010
#include "llvm/ObjectYAML/YAML.h"
1111
#include "llvm/ObjectYAML/yaml2obj.h"
12+
#include "llvm/Support/SwapByteOrder.h"
1213
#include "llvm/Testing/Support/Error.h"
1314

1415
using namespace llvm;
@@ -112,8 +113,12 @@ struct MockData1 {
112113
Yaml << R"(
113114
!ELF
114115
FileHeader:
115-
Class: ELFCLASS64
116-
Data: ELFDATA2LSB
116+
Class: ELFCLASS64)";
117+
if (sys::IsBigEndianHost)
118+
Yaml << "\n Data: ELFDATA2MSB";
119+
else
120+
Yaml << "\n Data: ELFDATA2LSB";
121+
Yaml << R"(
117122
Type: ET_REL
118123
Machine: EM_BPF
119124
Sections:
@@ -162,21 +167,21 @@ TEST(BTFParserTest, simpleCorrectInput) {
162167
EXPECT_EQ(BTF.findString(sizeof(MockData1::B::S)), StringRef());
163168

164169
const BTF::BPFLineInfo *I1 = BTF.findLineInfo({16, 1});
165-
EXPECT_TRUE(I1);
170+
ASSERT_TRUE(I1);
166171
EXPECT_EQ(I1->getLine(), 7u);
167172
EXPECT_EQ(I1->getCol(), 1u);
168173
EXPECT_EQ(BTF.findString(I1->FileNameOff), "a.c");
169174
EXPECT_EQ(BTF.findString(I1->LineOff), "first line");
170175

171176
const BTF::BPFLineInfo *I2 = BTF.findLineInfo({32, 1});
172-
EXPECT_TRUE(I2);
177+
ASSERT_TRUE(I2);
173178
EXPECT_EQ(I2->getLine(), 14u);
174179
EXPECT_EQ(I2->getCol(), 5u);
175180
EXPECT_EQ(BTF.findString(I2->FileNameOff), "a.c");
176181
EXPECT_EQ(BTF.findString(I2->LineOff), "second line");
177182

178183
const BTF::BPFLineInfo *I3 = BTF.findLineInfo({0, 2});
179-
EXPECT_TRUE(I3);
184+
ASSERT_TRUE(I3);
180185
EXPECT_EQ(I3->getLine(), 42u);
181186
EXPECT_EQ(I3->getCol(), 4u);
182187
EXPECT_EQ(BTF.findString(I3->FileNameOff), "b.c");

0 commit comments

Comments
 (0)