summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/Object/MinidumpTest.cpp35
-rw-r--r--llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp2
2 files changed, 35 insertions, 2 deletions
diff --git a/llvm/unittests/Object/MinidumpTest.cpp b/llvm/unittests/Object/MinidumpTest.cpp
index 97fde12c0f8..06034e1e5ad 100644
--- a/llvm/unittests/Object/MinidumpTest.cpp
+++ b/llvm/unittests/Object/MinidumpTest.cpp
@@ -249,3 +249,38 @@ TEST(MinidumpFile, getSystemInfo) {
EXPECT_EQ(0x08070605u, Info.CPU.X86.FeatureInfo);
EXPECT_EQ(0x02010009u, Info.CPU.X86.AMDExtendedFeatures);
}
+
+TEST(MinidumpFile, getString) {
+ std::vector<uint8_t> ManyStrings{
+ // Header
+ 'M', 'D', 'M', 'P', 0x93, 0xa7, 0, 0, // Signature, Version
+ 2, 0, 0, 0, // NumberOfStreams,
+ 0x20, 0, 0, 0, // StreamDirectoryRVA
+ 0, 1, 2, 3, 4, 5, 6, 7, // Checksum, TimeDateStamp
+ 8, 9, 0, 1, 2, 3, 4, 5, // Flags
+ // Stream Directory
+ 0, 0, 0, 0, 0, 0, 0, 0, // Type, DataSize,
+ 0x20, 0, 0, 0, // RVA
+ 1, 0, 0, 0, 0, 0, // String1 - odd length
+ 0, 0, 1, 0, 0, 0, // String2 - too long
+ 2, 0, 0, 0, 0, 0xd8, // String3 - invalid utf16
+ 0, 0, 0, 0, 0, 0, // String4 - ""
+ 2, 0, 0, 0, 'a', 0, // String5 - "a"
+ 0, // Mis-align next string
+ 2, 0, 0, 0, 'a', 0, // String6 - "a"
+
+ };
+ auto ExpectedFile = create(ManyStrings);
+ ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+ const MinidumpFile &File = **ExpectedFile;
+ EXPECT_THAT_EXPECTED(File.getString(44), Failed<BinaryError>());
+ EXPECT_THAT_EXPECTED(File.getString(50), Failed<BinaryError>());
+ EXPECT_THAT_EXPECTED(File.getString(56), Failed<BinaryError>());
+ EXPECT_THAT_EXPECTED(File.getString(62), HasValue(""));
+ EXPECT_THAT_EXPECTED(File.getString(68), HasValue("a"));
+ EXPECT_THAT_EXPECTED(File.getString(75), HasValue("a"));
+
+ // Check the case when the size field does not fit into the remaining data.
+ EXPECT_THAT_EXPECTED(File.getString(ManyStrings.size() - 2),
+ Failed<BinaryError>());
+}
diff --git a/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp b/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
index d172ccf9301..66d44e06759 100644
--- a/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
+++ b/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
@@ -33,7 +33,6 @@ Streams:
- Type: SystemInfo
Processor Arch: ARM64
Platform ID: Linux
- CSD Version RVA: 0x01020304
CPU:
CPUID: 0x05060708
- Type: LinuxMaps
@@ -54,7 +53,6 @@ Streams:
const SystemInfo &SysInfo = *ExpectedSysInfo;
EXPECT_EQ(ProcessorArchitecture::ARM64, SysInfo.ProcessorArch);
EXPECT_EQ(OSPlatform::Linux, SysInfo.PlatformId);
- EXPECT_EQ(0x01020304u, SysInfo.CSDVersionRVA);
EXPECT_EQ(0x05060708u, SysInfo.CPU.Arm.CPUID);
EXPECT_EQ(StreamType::LinuxMaps, File.streams()[1].Type);
OpenPOWER on IntegriCloud