OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file provides reliablity test which runs under UI test framework. The | 5 // This file provides reliablity test which runs under UI test framework. The |
6 // test is intended to run within QEMU environment. | 6 // test is intended to run within QEMU environment. |
7 // | 7 // |
8 // Usage 1: reliability_test | 8 // Usage 1: reliability_test |
9 // Upon invocation, it visits a hard coded list of URLs. This is mainly used | 9 // Upon invocation, it visits a hard coded list of sample pages. This is mainly |
10 // by buildbot, to verify reliability_test itself runs ok. | 10 // used by buildbot, to verify reliability_test itself runs ok. |
11 // | 11 // |
12 // Usage 2: reliability_test --site=url --startpage=start --endpage=end [...] | 12 // Usage 2: reliability_test --site=url --startpage=start --endpage=end [...] |
13 // Upon invocation, it visits a list of URLs constructed as | 13 // Upon invocation, it visits a list of URLs constructed as |
14 // "http://url/page?id=k". (start <= k <= end). | 14 // "http://url/page?id=k". (start <= k <= end). |
15 // | 15 // |
16 // Usage 3: reliability_test --list=file --startline=start --endline=end [...] | 16 // Usage 3: reliability_test --list=file --startline=start --endline=end [...] |
17 // Upon invocation, it visits each of the URLs on line numbers between start | 17 // Upon invocation, it visits each of the URLs on line numbers between start |
18 // and end, inclusive, stored in the input file. The line number starts from 1. | 18 // and end, inclusive, stored in the input file. The line number starts from 1. |
19 // | 19 // |
20 // If both "--site" and "--list" are provided, the "--site" set of arguments | 20 // If both "--site" and "--list" are provided, the "--site" set of arguments |
21 // are ignored. | 21 // are ignored. |
22 // | 22 // |
23 // Optional Switches: | 23 // Optional Switches: |
24 // --iterations=num: goes through the list of URLs constructed in usage 2 or 3 | 24 // --iterations=num: goes through the list of URLs constructed in usage 2 or 3 |
25 // num times. | 25 // num times. |
26 // --continuousload: continuously visits the list of URLs without restarting | 26 // --continuousload: continuously visits the list of URLs without restarting |
27 // browser for each page load. | 27 // browser for each page load. |
28 // --memoryusage: prints out memory usage when visiting each page. | 28 // --memoryusage: prints out memory usage when visiting each page. |
29 // --endurl=url: visits the specified url in the end. | 29 // --endurl=url: visits the specified url in the end. |
30 // --logfile=filepath: saves the visit log to the specified path. | 30 // --logfile=filepath: saves the visit log to the specified path. |
31 // --timeout=millisecond: time out as specified in millisecond during each | 31 // --timeout=millisecond: time out as specified in millisecond during each |
32 // page load. | 32 // page load. |
33 // --nopagedown: won't simulate page down key presses after page load. | 33 // --nopagedown: won't simulate page down key presses after page load. |
34 // --savedebuglog: save Chrome and v8 debug log for each page loaded. | 34 // --savedebuglog: save Chrome, V8, and test debug log for each page loaded. |
35 | 35 |
36 #include <fstream> | 36 #include <fstream> |
37 #include <iostream> | 37 #include <iostream> |
38 | 38 |
39 #include "base/command_line.h" | 39 #include "base/command_line.h" |
40 #include "base/file_path.h" | |
40 #include "base/file_util.h" | 41 #include "base/file_util.h" |
41 #include "base/path_service.h" | 42 #include "base/path_service.h" |
42 #include "base/string_util.h" | 43 #include "base/string_util.h" |
43 #include "base/time.h" | 44 #include "base/time.h" |
44 #include "base/time_format.h" | 45 #include "base/time_format.h" |
45 #include "chrome/browser/net/url_fixer_upper.h" | 46 #include "chrome/browser/net/url_fixer_upper.h" |
46 #include "chrome/common/chrome_constants.h" | 47 #include "chrome/common/chrome_constants.h" |
47 #include "chrome/common/chrome_paths.h" | 48 #include "chrome/common/chrome_paths.h" |
48 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/logging_chrome.h" | 50 #include "chrome/common/logging_chrome.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
71 const wchar_t kIterationSwitch[] = L"iterations"; | 72 const wchar_t kIterationSwitch[] = L"iterations"; |
72 const wchar_t kContinuousLoadSwitch[] = L"continuousload"; | 73 const wchar_t kContinuousLoadSwitch[] = L"continuousload"; |
73 const wchar_t kMemoryUsageSwitch[] = L"memoryusage"; | 74 const wchar_t kMemoryUsageSwitch[] = L"memoryusage"; |
74 const wchar_t kEndURLSwitch[] = L"endurl"; | 75 const wchar_t kEndURLSwitch[] = L"endurl"; |
75 const wchar_t kLogFileSwitch[] = L"logfile"; | 76 const wchar_t kLogFileSwitch[] = L"logfile"; |
76 const wchar_t kTimeoutSwitch[] = L"timeout"; | 77 const wchar_t kTimeoutSwitch[] = L"timeout"; |
77 const wchar_t kNoPageDownSwitch[] = L"nopagedown"; | 78 const wchar_t kNoPageDownSwitch[] = L"nopagedown"; |
78 const wchar_t kSaveDebugLogSwitch[] = L"savedebuglog"; | 79 const wchar_t kSaveDebugLogSwitch[] = L"savedebuglog"; |
79 | 80 |
80 std::wstring server_url = L"http://urllist.com"; | 81 std::wstring server_url = L"http://urllist.com"; |
81 const wchar_t test_url_1[] = L"http://www.google.com"; | 82 const wchar_t test_page_1[] = L"page1.html"; |
82 const wchar_t test_url_2[] = L"about:crash"; | 83 const wchar_t test_page_2[] = L"page2.html"; |
83 const wchar_t test_url_3[] = L"http://www.youtube.com"; | 84 const wchar_t crash_url[] = L"about:crash"; |
84 | 85 |
85 // These are copied from v8 definitions as we cannot include them. | 86 // These are copied from v8 definitions as we cannot include them. |
86 const wchar_t kV8LogFileSwitch[] = L"logfile"; | 87 const wchar_t kV8LogFileSwitch[] = L"logfile"; |
87 const wchar_t kV8LogFileDefaultName[] = L"v8.log"; | 88 const wchar_t kV8LogFileDefaultName[] = L"v8.log"; |
88 | 89 |
89 bool append_page_id = false; | 90 bool append_page_id = false; |
90 int32 start_page; | 91 int32 start_page; |
91 int32 end_page; | 92 int32 end_page; |
92 std::wstring url_file_path; | 93 std::wstring url_file_path; |
93 int32 start_index = 1; | 94 int32 start_index = 1; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 // Page down twice. | 170 // Page down twice. |
170 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 171 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
171 if (browser.get()) { | 172 if (browser.get()) { |
172 scoped_ptr<WindowProxy> window(browser->GetWindow()); | 173 scoped_ptr<WindowProxy> window(browser->GetWindow()); |
173 if (window.get()) { | 174 if (window.get()) { |
174 bool activation_timeout; | 175 bool activation_timeout; |
175 browser->BringToFrontWithTimeout(action_max_timeout_ms(), | 176 browser->BringToFrontWithTimeout(action_max_timeout_ms(), |
176 &activation_timeout); | 177 &activation_timeout); |
177 if (!activation_timeout) { | 178 if (!activation_timeout) { |
178 window->SimulateOSKeyPress(VK_NEXT, 0); | 179 window->SimulateOSKeyPress(VK_NEXT, 0); |
179 Sleep(sleep_timeout_ms()); | 180 Sleep(sleep_timeout_ms()); |
Patrick Johnson
2009/03/24 00:18:21
What is the reason we need to wait 2 seconds after
huanr
2009/03/24 04:28:03
Wait for page down to finish in VM environment whi
| |
180 window->SimulateOSKeyPress(VK_NEXT, 0); | 181 window->SimulateOSKeyPress(VK_NEXT, 0); |
181 Sleep(sleep_timeout_ms()); | 182 Sleep(sleep_timeout_ms()); |
182 } | 183 } |
183 } | 184 } |
184 } | 185 } |
185 } | 186 } |
186 } | 187 } |
187 } | 188 } |
188 | 189 |
189 if (!continuous_load) { | 190 if (!continuous_load) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 } else { | 293 } else { |
293 // Don't run if single process mode. | 294 // Don't run if single process mode. |
294 // Also don't run if running as a standalone program which is for | 295 // Also don't run if running as a standalone program which is for |
295 // distributed testing, to avoid mistakenly hitting web sites with many | 296 // distributed testing, to avoid mistakenly hitting web sites with many |
296 // instances. | 297 // instances. |
297 if (in_process_renderer() || stand_alone) | 298 if (in_process_renderer() || stand_alone) |
298 return; | 299 return; |
299 // For usage 1 | 300 // For usage 1 |
300 NavigationMetrics metrics; | 301 NavigationMetrics metrics; |
301 if (timeout_ms == INFINITE) | 302 if (timeout_ms == INFINITE) |
302 timeout_ms = 30000; | 303 timeout_ms = 2000; |
303 | 304 |
304 NavigateToURLLogResult(GURL(test_url_1), log_file, &metrics); | 305 // Paging down is unnecessary for usage 1. |
306 page_down = false; | |
Patrick Johnson
2009/03/24 00:18:21
I'm not completely happy with this, as this means
| |
307 | |
308 FilePath sample_data_dir = GetSampleDataDir(); | |
309 FilePath test_page_1 = sample_data_dir.AppendASCII("page1.html"); | |
310 FilePath test_page_2 = sample_data_dir.AppendASCII("page2.html"); | |
311 | |
312 GURL test_url_1 = net::FilePathToFileURL(test_page_1); | |
313 GURL test_url_2 = net::FilePathToFileURL(test_page_2); | |
314 | |
315 NavigateToURLLogResult(test_url_1, log_file, &metrics); | |
305 // Verify everything is fine | 316 // Verify everything is fine |
306 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); | 317 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); |
307 EXPECT_EQ(0, metrics.crash_dump_count); | 318 EXPECT_EQ(0, metrics.crash_dump_count); |
308 EXPECT_EQ(true, metrics.browser_clean_exit); | 319 EXPECT_EQ(true, metrics.browser_clean_exit); |
309 EXPECT_EQ(1, metrics.browser_launch_count); | 320 EXPECT_EQ(1, metrics.browser_launch_count); |
310 // Both starting page and test_url_1 are loaded. | 321 // Both starting page and test_url_1 are loaded. |
311 EXPECT_EQ(2, metrics.page_load_count); | 322 EXPECT_EQ(2, metrics.page_load_count); |
312 EXPECT_EQ(0, metrics.browser_crash_count); | 323 EXPECT_EQ(0, metrics.browser_crash_count); |
313 EXPECT_EQ(0, metrics.renderer_crash_count); | 324 EXPECT_EQ(0, metrics.renderer_crash_count); |
314 EXPECT_EQ(0, metrics.plugin_crash_count); | 325 EXPECT_EQ(0, metrics.plugin_crash_count); |
315 | 326 |
316 // Go to "about:crash" | 327 // Go to "about:crash" |
317 uint32 crash_timeout_ms = timeout_ms / 2; | 328 NavigateToURLLogResult(GURL(crash_url), log_file, &metrics); |
318 std::swap(timeout_ms, crash_timeout_ms); | |
319 NavigateToURLLogResult(GURL(test_url_2), log_file, &metrics); | |
320 std::swap(timeout_ms, crash_timeout_ms); | |
321 // Page load crashed and test automation timed out. | 329 // Page load crashed and test automation timed out. |
322 EXPECT_EQ(NAVIGATION_TIME_OUT, metrics.result); | 330 EXPECT_EQ(NAVIGATION_TIME_OUT, metrics.result); |
323 // Found a crash dump | 331 // Found a crash dump |
324 EXPECT_EQ(1, metrics.crash_dump_count) << kFailedNoCrashService; | 332 EXPECT_EQ(1, metrics.crash_dump_count) << kFailedNoCrashService; |
325 // Browser did not crash, and exited cleanly. | 333 // Browser did not crash, and exited cleanly. |
326 EXPECT_EQ(true, metrics.browser_clean_exit); | 334 EXPECT_EQ(true, metrics.browser_clean_exit); |
327 EXPECT_EQ(1, metrics.browser_launch_count); | 335 EXPECT_EQ(1, metrics.browser_launch_count); |
328 // Only starting page was loaded. | 336 // Only starting page was loaded. |
329 EXPECT_EQ(1, metrics.page_load_count); | 337 EXPECT_EQ(1, metrics.page_load_count); |
330 EXPECT_EQ(0, metrics.browser_crash_count); | 338 EXPECT_EQ(0, metrics.browser_crash_count); |
331 // Renderer crashed. | 339 // Renderer crashed. |
332 EXPECT_EQ(1, metrics.renderer_crash_count); | 340 EXPECT_EQ(1, metrics.renderer_crash_count); |
333 EXPECT_EQ(0, metrics.plugin_crash_count); | 341 EXPECT_EQ(0, metrics.plugin_crash_count); |
334 | 342 |
335 uint32 youtube_timeout_ms = timeout_ms * 2; | 343 NavigateToURLLogResult(test_url_2, log_file, &metrics); |
336 std::swap(timeout_ms, youtube_timeout_ms); | |
337 NavigateToURLLogResult(GURL(test_url_3), log_file, &metrics); | |
338 std::swap(timeout_ms, youtube_timeout_ms); | |
339 // The data on previous crash should be cleared and we should get | 344 // The data on previous crash should be cleared and we should get |
340 // metrics for a successful page load. | 345 // metrics for a successful page load. |
341 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); | 346 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); |
342 EXPECT_EQ(0, metrics.crash_dump_count); | 347 EXPECT_EQ(0, metrics.crash_dump_count); |
343 EXPECT_EQ(true, metrics.browser_clean_exit); | 348 EXPECT_EQ(true, metrics.browser_clean_exit); |
344 EXPECT_EQ(1, metrics.browser_launch_count); | 349 EXPECT_EQ(1, metrics.browser_launch_count); |
345 EXPECT_EQ(0, metrics.browser_crash_count); | 350 EXPECT_EQ(0, metrics.browser_crash_count); |
346 EXPECT_EQ(0, metrics.renderer_crash_count); | 351 EXPECT_EQ(0, metrics.renderer_crash_count); |
347 EXPECT_EQ(0, metrics.plugin_crash_count); | 352 EXPECT_EQ(0, metrics.plugin_crash_count); |
348 | 353 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 local_state->GetInteger(prefs::kStabilityCrashCount); | 539 local_state->GetInteger(prefs::kStabilityCrashCount); |
535 metrics->renderer_crash_count = | 540 metrics->renderer_crash_count = |
536 local_state->GetInteger(prefs::kStabilityRendererCrashCount); | 541 local_state->GetInteger(prefs::kStabilityRendererCrashCount); |
537 // TODO(huanr) | 542 // TODO(huanr) |
538 metrics->plugin_crash_count = 0; | 543 metrics->plugin_crash_count = 0; |
539 | 544 |
540 if (!metrics->browser_clean_exit) | 545 if (!metrics->browser_clean_exit) |
541 metrics->browser_crash_count++; | 546 metrics->browser_crash_count++; |
542 } | 547 } |
543 | 548 |
549 FilePath GetSampleDataDir() { | |
550 FilePath test_dir; | |
551 PathService::Get(chrome::DIR_TEST_DATA, &test_dir); | |
552 test_dir = test_dir.AppendASCII("reliability"); | |
553 test_dir = test_dir.AppendASCII("sample_pages"); | |
554 return test_dir; | |
555 } | |
556 | |
544 // The pathname of Chrome's crash dumps directory. | 557 // The pathname of Chrome's crash dumps directory. |
545 std::wstring crash_dumps_dir_path_; | 558 std::wstring crash_dumps_dir_path_; |
546 | 559 |
547 // The set of all the crash dumps we have seen. Each crash generates a | 560 // The set of all the crash dumps we have seen. Each crash generates a |
548 // .dmp and a .txt file in the crash dumps directory. We only store the | 561 // .dmp and a .txt file in the crash dumps directory. We only store the |
549 // .dmp files in this set. | 562 // .dmp files in this set. |
550 // | 563 // |
551 // The set is implemented as a std::map. The key is the file name, and | 564 // The set is implemented as a std::map. The key is the file name, and |
552 // the value is false (the file is not in the set) or true (the file is | 565 // the value is false (the file is not in the set) or true (the file is |
553 // in the set). The initial value for any key in std::map is 0 (false), | 566 // in the set). The initial value for any key in std::map is 0 (false), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 if (v8_command_line.HasSwitch(kV8LogFileSwitch)) { | 673 if (v8_command_line.HasSwitch(kV8LogFileSwitch)) { |
661 v8_log_path = v8_command_line.GetSwitchValue(kV8LogFileSwitch); | 674 v8_log_path = v8_command_line.GetSwitchValue(kV8LogFileSwitch); |
662 if (!file_util::AbsolutePath(&v8_log_path)) { | 675 if (!file_util::AbsolutePath(&v8_log_path)) { |
663 v8_log_path.clear(); | 676 v8_log_path.clear(); |
664 } | 677 } |
665 } | 678 } |
666 } | 679 } |
667 } | 680 } |
668 } | 681 } |
669 } | 682 } |
OLD | NEW |