Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: src/client/linux/microdump_writer/microdump_writer_unittest.cc

Issue 1125153008: [microdump] Add build fingerprint and product info metadata. (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk
Patch Set: Addressing changes from https://breakpad.appspot.com/9794002 Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/client/linux/microdump_writer/microdump_writer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/client/linux/microdump_writer/microdump_writer_unittest.cc
diff --git a/src/client/linux/microdump_writer/microdump_writer_unittest.cc b/src/client/linux/microdump_writer/microdump_writer_unittest.cc
index 52b1d9a9756b3968746e9093fe36ee2fb1c00a03..1fa6f1ff0a27ecb9c2202086173dc74fe7c5b4be 100644
--- a/src/client/linux/microdump_writer/microdump_writer_unittest.cc
+++ b/src/client/linux/microdump_writer/microdump_writer_unittest.cc
@@ -48,7 +48,11 @@ namespace {
typedef testing::Test MicrodumpWriterTest;
-TEST(MicrodumpWriterTest, Setup) {
+void CrashAndGetMicrodump(
+ const MappingList& mappings,
+ const char* build_fingerprint,
+ const char* product_info,
+ scoped_array<char>* buf) {
int fds[2];
ASSERT_NE(-1, pipe(fds));
@@ -73,6 +77,36 @@ TEST(MicrodumpWriterTest, Setup) {
// Set a non-zero tid to avoid tripping asserts.
context.tid = child;
+ // Redirect temporarily stderr to the stderr.log file.
+ int save_err = dup(STDERR_FILENO);
+ ASSERT_NE(-1, save_err);
+ ASSERT_NE(-1, dup2(err_fd, STDERR_FILENO));
+
+ ASSERT_TRUE(WriteMicrodump(child, &context, sizeof(context), mappings,
+ build_fingerprint, product_info));
+
+ // Revert stderr back to the console.
+ dup2(save_err, STDERR_FILENO);
+ close(save_err);
+
+ // Read back the stderr file and check for the microdump marker.
+ fsync(err_fd);
+ lseek(err_fd, 0, SEEK_SET);
+ const size_t kBufSize = 64 * 1024;
+ buf->reset(new char[kBufSize]);
+ ASSERT_GT(read(err_fd, buf->get(), kBufSize), 0);
+
+ close(err_fd);
+ close(fds[1]);
+
+ ASSERT_NE(static_cast<char*>(0), strstr(
+ buf->get(), "-----BEGIN BREAKPAD MICRODUMP-----"));
+ ASSERT_NE(static_cast<char*>(0), strstr(
+ buf->get(), "-----END BREAKPAD MICRODUMP-----"));
+
+}
+
+TEST(MicrodumpWriterTest, BasicWithMappings) {
// Push some extra mapping to check the MappingList logic.
const uint32_t memory_size = sysconf(_SC_PAGESIZE);
const char* kMemoryName = "libfoo.so";
@@ -93,28 +127,8 @@ TEST(MicrodumpWriterTest, Setup) {
memcpy(mapping.second, kModuleGUID, sizeof(MDGUID));
mappings.push_back(mapping);
- // Redirect temporarily stderr to the stderr.log file.
- int save_err = dup(STDERR_FILENO);
- ASSERT_NE(-1, save_err);
- ASSERT_NE(-1, dup2(err_fd, STDERR_FILENO));
-
- ASSERT_TRUE(WriteMicrodump(child, &context, sizeof(context), mappings));
-
- // Revert stderr back to the console.
- dup2(save_err, STDERR_FILENO);
- close(save_err);
-
- // Read back the stderr file and check for the microdump marker.
- fsync(err_fd);
- lseek(err_fd, 0, SEEK_SET);
- const size_t kBufSize = 64 * 1024;
- scoped_array<char> buf(new char[kBufSize]);
- ASSERT_GT(read(err_fd, buf.get(), kBufSize), 0);
-
- ASSERT_NE(static_cast<char*>(0), strstr(
- buf.get(), "-----BEGIN BREAKPAD MICRODUMP-----"));
- ASSERT_NE(static_cast<char*>(0), strstr(
- buf.get(), "-----END BREAKPAD MICRODUMP-----"));
+ scoped_array<char> buf;
+ CrashAndGetMicrodump(mappings, NULL, NULL, &buf);
#ifdef __LP64__
ASSERT_NE(static_cast<char*>(0), strstr(
@@ -126,8 +140,25 @@ TEST(MicrodumpWriterTest, Setup) {
"33221100554477668899AABBCCDDEEFF0 libfoo.so"));
#endif
- close(err_fd);
- close(fds[1]);
+ // In absence of a product info in the minidump, the writer should just write
+ // an unknown marker.
+ ASSERT_NE(static_cast<char*>(0), strstr(
+ buf.get(), "V UNKNOWN:0.0.0.0"));
+}
+
+// Ensure that the product info and build fingerprint metadata show up in the
+// final microdump if present.
+TEST(MicrodumpWriterTest, BuildFingerprintAndProductInfo) {
+ const char kProductInfo[] = "MockProduct:42.0.2311.99";
+ const char kBuildFingerprint[] =
+ "aosp/occam/mako:5.1.1/LMY47W/12345678:userdegbug/dev-keys";
+ scoped_array<char> buf;
+ MappingList no_mappings;
+
+ CrashAndGetMicrodump(no_mappings, kBuildFingerprint, kProductInfo, &buf);
+
+ ASSERT_NE(static_cast<char*>(0), strstr(buf.get(), kBuildFingerprint));
+ ASSERT_NE(static_cast<char*>(0), strstr(buf.get(), kProductInfo));
}
} // namespace
« no previous file with comments | « src/client/linux/microdump_writer/microdump_writer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698