| Index: src/client/linux/minidump_writer/minidump_writer_unittest.cc
|
| diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest.cc b/src/client/linux/minidump_writer/minidump_writer_unittest.cc
|
| index e1046e12a0b2d46e07fcf90485e2194e51b1cf3c..db7d4f5de0f38ae5d19c7fad6128529d51703b41 100644
|
| --- a/src/client/linux/minidump_writer/minidump_writer_unittest.cc
|
| +++ b/src/client/linux/minidump_writer/minidump_writer_unittest.cc
|
| @@ -54,10 +54,6 @@
|
|
|
| using namespace google_breakpad;
|
|
|
| -// Length of a formatted GUID string =
|
| -// sizeof(MDGUID) * 2 + 4 (for dashes) + 1 (null terminator)
|
| -const int kGUIDStringSize = 37;
|
| -
|
| namespace {
|
|
|
| typedef testing::Test MinidumpWriterTest;
|
| @@ -137,19 +133,7 @@ TEST(MinidumpWriterTest, MappingInfo) {
|
| 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
| 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
|
| };
|
| - char module_identifier_buffer[kGUIDStringSize];
|
| - FileID::ConvertIdentifierToString(kModuleGUID,
|
| - module_identifier_buffer,
|
| - sizeof(module_identifier_buffer));
|
| - string module_identifier(module_identifier_buffer);
|
| - // Strip out dashes
|
| - size_t pos;
|
| - while ((pos = module_identifier.find('-')) != string::npos) {
|
| - module_identifier.erase(pos, 1);
|
| - }
|
| - // And append a zero, because module IDs include an "age" field
|
| - // which is always zero on Linux.
|
| - module_identifier += "0";
|
| + const string module_identifier = "33221100554477668899AABBCCDDEEFF0";
|
|
|
| // Get some memory.
|
| char* memory =
|
| @@ -230,6 +214,53 @@ TEST(MinidumpWriterTest, MappingInfo) {
|
| close(fds[1]);
|
| }
|
|
|
| +// Test that a binary with a longer-than-usual build id note
|
| +// makes its way all the way through to the minidump unscathed.
|
| +// The linux_client_unittest is linked with an explicit --build-id
|
| +// in Makefile.am.
|
| +TEST(MinidumpWriterTest, BuildIDLong) {
|
| + int fds[2];
|
| + ASSERT_NE(-1, pipe(fds));
|
| +
|
| + const pid_t child = fork();
|
| + if (child == 0) {
|
| + close(fds[1]);
|
| + char b;
|
| + IGNORE_RET(HANDLE_EINTR(read(fds[0], &b, sizeof(b))));
|
| + close(fds[0]);
|
| + syscall(__NR_exit);
|
| + }
|
| + close(fds[0]);
|
| +
|
| + ExceptionHandler::CrashContext context;
|
| + memset(&context, 0, sizeof(context));
|
| + ASSERT_EQ(0, getcontext(&context.context));
|
| + context.tid = child;
|
| +
|
| + AutoTempDir temp_dir;
|
| + const string dump_path = temp_dir.path() + kMDWriterUnitTestFileName;
|
| +
|
| + EXPECT_TRUE(WriteMinidump(dump_path.c_str(),
|
| + child, &context, sizeof(context)));
|
| + close(fds[1]);
|
| +
|
| + // Read the minidump. Load the module list, and ensure that
|
| + // the main module has the correct debug id and code id.
|
| + Minidump minidump(dump_path);
|
| + ASSERT_TRUE(minidump.Read());
|
| +
|
| + MinidumpModuleList* module_list = minidump.GetModuleList();
|
| + ASSERT_TRUE(module_list);
|
| + const MinidumpModule* module = module_list->GetMainModule();
|
| + ASSERT_TRUE(module);
|
| + const string module_identifier = "030201000504070608090A0B0C0D0E0F0";
|
| + // This is passed explicitly to the linker in Makefile.am
|
| + const string build_id =
|
| + "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
|
| + EXPECT_EQ(module_identifier, module->debug_identifier());
|
| + EXPECT_EQ(build_id, module->code_identifier());
|
| +}
|
| +
|
| // Test that mapping info can be specified, and that it overrides
|
| // existing mappings that are wholly contained within the specified
|
| // range.
|
| @@ -245,19 +276,7 @@ TEST(MinidumpWriterTest, MappingInfoContained) {
|
| 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
| 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
|
| };
|
| - char module_identifier_buffer[kGUIDStringSize];
|
| - FileID::ConvertIdentifierToString(kModuleGUID,
|
| - module_identifier_buffer,
|
| - sizeof(module_identifier_buffer));
|
| - string module_identifier(module_identifier_buffer);
|
| - // Strip out dashes
|
| - size_t pos;
|
| - while ((pos = module_identifier.find('-')) != string::npos) {
|
| - module_identifier.erase(pos, 1);
|
| - }
|
| - // And append a zero, because module IDs include an "age" field
|
| - // which is always zero on Linux.
|
| - module_identifier += "0";
|
| + const string module_identifier = "33221100554477668899AABBCCDDEEFF0";
|
|
|
| // mmap a file
|
| AutoTempDir temp_dir;
|
| @@ -410,12 +429,10 @@ TEST(MinidumpWriterTest, DeletedBinary) {
|
| EXPECT_STREQ(binpath.c_str(), module->code_file().c_str());
|
| // Check that the file ID is correct.
|
| FileID fileid(helper_path.c_str());
|
| - uint8_t identifier[sizeof(MDGUID)];
|
| + PageAllocator allocator;
|
| + wasteful_vector<uint8_t> identifier(&allocator, kDefaultBuildIdSize);
|
| EXPECT_TRUE(fileid.ElfFileIdentifier(identifier));
|
| - char identifier_string[kGUIDStringSize];
|
| - FileID::ConvertIdentifierToString(identifier,
|
| - identifier_string,
|
| - kGUIDStringSize);
|
| + string identifier_string = FileID::ConvertIdentifierToUUIDString(identifier);
|
| string module_identifier(identifier_string);
|
| // Strip out dashes
|
| size_t pos;
|
|
|