| Index: breakpad/linux/linux_dumper_unittest.cc
|
| ===================================================================
|
| --- breakpad/linux/linux_dumper_unittest.cc (revision 18569)
|
| +++ breakpad/linux/linux_dumper_unittest.cc (working copy)
|
| @@ -64,3 +64,55 @@
|
| }
|
| }
|
| }
|
| +
|
| +TEST(LinuxDumperTest, BuildProcPath) {
|
| + const pid_t pid = getpid();
|
| + LinuxDumper dumper(pid);
|
| +
|
| + char maps_path[256] = "dummymappath";
|
| + char maps_path_expected[256];
|
| + snprintf(maps_path_expected, sizeof(maps_path_expected),
|
| + "/proc/%d/maps", pid);
|
| + dumper.BuildProcPath(maps_path, pid, "maps");
|
| + ASSERT_STREQ(maps_path, maps_path_expected);
|
| +
|
| + // In release mode, we expect BuildProcPath to handle the invalid
|
| + // parameters correctly and fill map_path with an empty
|
| + // NULL-terminated string.
|
| +#ifdef NDEBUG
|
| + snprintf(maps_path, sizeof(maps_path), "dummymappath");
|
| + dumper.BuildProcPath(maps_path, 0, "maps");
|
| + EXPECT_STREQ(maps_path, "");
|
| +
|
| + snprintf(maps_path, sizeof(maps_path), "dummymappath");
|
| + dumper.BuildProcPath(maps_path, getpid(), "");
|
| + EXPECT_STREQ(maps_path, "");
|
| +
|
| + snprintf(maps_path, sizeof(maps_path), "dummymappath");
|
| + dumper.BuildProcPath(maps_path, getpid(), NULL);
|
| + EXPECT_STREQ(maps_path, "");
|
| +#endif
|
| +}
|
| +
|
| +TEST(LinuxDumperTest, MappingsIncludeLinuxGate) {
|
| + LinuxDumper dumper(getpid());
|
| + ASSERT_TRUE(dumper.Init());
|
| +
|
| + void* linux_gate_loc = dumper.FindBeginningOfLinuxGateSharedLibrary(getpid());
|
| + if (linux_gate_loc) {
|
| + bool found_linux_gate = false;
|
| +
|
| + const wasteful_vector<MappingInfo*> mappings = dumper.mappings();
|
| + const MappingInfo* mapping;
|
| + for (unsigned i = 0; i < mappings.size(); ++i) {
|
| + mapping = mappings[i];
|
| + if (!strcmp(mapping->name, kLinuxGateLibraryName)) {
|
| + found_linux_gate = true;
|
| + break;
|
| + }
|
| + }
|
| + EXPECT_TRUE(found_linux_gate);
|
| + EXPECT_EQ(linux_gate_loc, reinterpret_cast<void*>(mapping->start_addr));
|
| + EXPECT_EQ(0, memcmp(linux_gate_loc, ELFMAG, SELFMAG));
|
| + }
|
| +}
|
|
|