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

Side by Side Diff: src/tools/windows/dump_syms/dump_syms_unittest.cc

Issue 1782453003: Windows dump_syms: Add unittest for a PDB containing PDATA/XDATA Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@pdb-pdata
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2003 Google Inc. All rights reserved. 1 // Copyright 2003 Google Inc. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer 10 // copyright notice, this list of conditions and the following disclaimer
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // A PDB file with OMAP data for an image that has been function-level 49 // A PDB file with OMAP data for an image that has been function-level
50 // reordered. 50 // reordered.
51 L"omap_reorder_funcs", 51 L"omap_reorder_funcs",
52 // A PDB file with OMAP data for an image that had new content injected, all 52 // A PDB file with OMAP data for an image that had new content injected, all
53 // of it with source data. 53 // of it with source data.
54 L"omap_stretched_filled", 54 L"omap_stretched_filled",
55 // A PDB file with OMAP data for an image that had new content injected, but 55 // A PDB file with OMAP data for an image that had new content injected, but
56 // without source data. 56 // without source data.
57 L"omap_stretched", 57 L"omap_stretched",
58 // A PDB file with OMAP data for an image that has been basic block reordered. 58 // A PDB file with OMAP data for an image that has been basic block reordered.
59 L"omap_reorder_bbs", 59 L"omap_reorder_bbs",
60 // A 64bit PDB file with no OMAP data. 60 // A 64bit PDB file with no OMAP data.
61 L"dump_syms_regtest64", 61 L"dump_syms_regtest64",
62 // A 64bit PDB file with PDATA
63 L"pdb_pdata_in_pdb",
64 // A 64bit PDB file with an exe to provide PDATA
65 L"pdb_pdata_in_exe",
62 }; 66 };
63 67
64 void TrimLastComponent(const std::wstring& path, 68 void TrimLastComponent(const std::wstring& path,
65 std::wstring* trimmed, 69 std::wstring* trimmed,
66 std::wstring* component) { 70 std::wstring* component) {
67 size_t len = path.size(); 71 size_t len = path.size();
68 while (len > 0 && path[len - 1] != '\\') 72 while (len > 0 && path[len - 1] != '\\')
69 --len; 73 --len;
70 74
71 if (component != NULL) 75 if (component != NULL)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 160
157 char buffer[4096] = {}; 161 char buffer[4096] = {};
158 while (true) { 162 while (true) {
159 size_t bytes_read = ::fread(buffer, 1, sizeof(buffer), f); 163 size_t bytes_read = ::fread(buffer, 1, sizeof(buffer), f);
160 if (bytes_read == 0) 164 if (bytes_read == 0)
161 break; 165 break;
162 content->append(buffer, bytes_read); 166 content->append(buffer, bytes_read);
163 } 167 }
164 } 168 }
165 169
166 class DumpSymsRegressionTest : public testing::Test { 170 class DumpSymsRegressionTest : public testing::TestWithParam<const wchar_t *> {
167 public: 171 public:
168 virtual void SetUp() { 172 virtual void SetUp() {
169 std::wstring self_dir; 173 std::wstring self_dir;
170 ASSERT_TRUE(GetSelfDirectory(&self_dir)); 174 ASSERT_TRUE(GetSelfDirectory(&self_dir));
171 dump_syms_exe = self_dir + L"\\dump_syms.exe"; 175 dump_syms_exe = self_dir + L"\\dump_syms.exe";
172 176
173 TrimLastComponent(self_dir, &testdata_dir, NULL); 177 TrimLastComponent(self_dir, &testdata_dir, NULL);
174 testdata_dir += L"\\testdata"; 178 testdata_dir += L"\\testdata";
175 } 179 }
176 180
177 std::wstring dump_syms_exe; 181 std::wstring dump_syms_exe;
178 std::wstring testdata_dir; 182 std::wstring testdata_dir;
179 }; 183 };
180 184
181 } //namespace 185 } //namespace
182 186
183 TEST_F(DumpSymsRegressionTest, EnsureDumpedSymbolsMatch) { 187 TEST_P(DumpSymsRegressionTest, EnsureDumpedSymbolsMatch) {
184 for (size_t i = 0; i < sizeof(kRootNames) / sizeof(kRootNames[0]); ++i) { 188 const wchar_t* root_name = GetParam();
185 const wchar_t* root_name = kRootNames[i];
186 std::wstring root_path = testdata_dir + L"\\" + root_name; 189 std::wstring root_path = testdata_dir + L"\\" + root_name;
187 190
188 std::wstring sym_path = root_path + L".sym"; 191 std::wstring sym_path = root_path + L".sym";
189 std::string expected_symbols; 192 std::string expected_symbols;
190 ASSERT_NO_FATAL_FAILURE(GetFileContents(sym_path, &expected_symbols)); 193 ASSERT_NO_FATAL_FAILURE(GetFileContents(sym_path, &expected_symbols));
191 194
192 std::wstring pdb_path = root_path + L".pdb"; 195 std::wstring pdb_path = root_path + L".pdb";
193 std::wstring command_line = L"\"" + dump_syms_exe + L"\" \"" + 196 std::wstring command_line = L"\"" + dump_syms_exe + L"\" \"" +
194 pdb_path + L"\""; 197 pdb_path + L"\"";
195 std::string symbols; 198 std::string symbols;
196 ASSERT_NO_FATAL_FAILURE(RunCommand(command_line, &symbols)); 199 ASSERT_NO_FATAL_FAILURE(RunCommand(command_line, &symbols));
197 200
198 EXPECT_EQ(expected_symbols, symbols); 201 EXPECT_EQ(expected_symbols, symbols);
199 }
200 } 202 }
201 203
204 INSTANTIATE_TEST_CASE_P(DumpSyms, DumpSymsRegressionTest,
205 testing::ValuesIn(kRootNames));
206
202 } // namespace dump_syms 207 } // namespace dump_syms
203 } // namespace windows 208 } // namespace windows
204 } // namespace tools 209 } // namespace tools
OLDNEW
« no previous file with comments | « src/common/windows/pdb_source_line_writer.cc ('k') | src/tools/windows/dump_syms/testdata/dump_syms_regtest.sym » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698