| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 sample URLs. This is mainly | 9 // Upon invocation, it visits a hard coded list of sample URLs. This is mainly |
| 10 // used by buildbot, to verify reliability_test itself runs ok. | 10 // used by buildbot, to verify reliability_test itself runs ok. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 // --noclearprofile: do not clear profile dir before firing up each time. |
| 34 // --savedebuglog: save Chrome, V8, and test debug log for each page loaded. | 35 // --savedebuglog: save Chrome, V8, and test debug log for each page loaded. |
| 35 | 36 |
| 36 #include <fstream> | 37 #include <fstream> |
| 37 #include <iostream> | 38 #include <iostream> |
| 38 | 39 |
| 39 #include "base/command_line.h" | 40 #include "base/command_line.h" |
| 40 #include "base/file_path.h" | 41 #include "base/file_path.h" |
| 41 #include "base/file_util.h" | 42 #include "base/file_util.h" |
| 42 #include "base/file_version_info.h" | 43 #include "base/file_version_info.h" |
| 43 #include "base/keyboard_codes.h" | 44 #include "base/keyboard_codes.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 const char kListSwitch[] = "list"; | 73 const char kListSwitch[] = "list"; |
| 73 const char kStartIndexSwitch[] = "startline"; | 74 const char kStartIndexSwitch[] = "startline"; |
| 74 const char kEndIndexSwitch[] = "endline"; | 75 const char kEndIndexSwitch[] = "endline"; |
| 75 const char kIterationSwitch[] = "iterations"; | 76 const char kIterationSwitch[] = "iterations"; |
| 76 const char kContinuousLoadSwitch[] = "continuousload"; | 77 const char kContinuousLoadSwitch[] = "continuousload"; |
| 77 const char kMemoryUsageSwitch[] = "memoryusage"; | 78 const char kMemoryUsageSwitch[] = "memoryusage"; |
| 78 const char kEndURLSwitch[] = "endurl"; | 79 const char kEndURLSwitch[] = "endurl"; |
| 79 const char kLogFileSwitch[] = "logfile"; | 80 const char kLogFileSwitch[] = "logfile"; |
| 80 const char kTimeoutSwitch[] = "timeout"; | 81 const char kTimeoutSwitch[] = "timeout"; |
| 81 const char kNoPageDownSwitch[] = "nopagedown"; | 82 const char kNoPageDownSwitch[] = "nopagedown"; |
| 83 const char kNoClearProfileSwitch[] = "noclearprofile"; |
| 82 const char kSaveDebugLogSwitch[] = "savedebuglog"; | 84 const char kSaveDebugLogSwitch[] = "savedebuglog"; |
| 83 | 85 |
| 84 const char kDefaultServerUrl[] = "http://urllist.com"; | 86 const char kDefaultServerUrl[] = "http://urllist.com"; |
| 85 std::string g_server_url; | 87 std::string g_server_url; |
| 86 const char kTestPage1[] = "page1.html"; | 88 const char kTestPage1[] = "page1.html"; |
| 87 const char kTestPage2[] = "page2.html"; | 89 const char kTestPage2[] = "page2.html"; |
| 88 const char crash_url[] = "about:crash"; | 90 const char crash_url[] = "about:crash"; |
| 89 | 91 |
| 90 // These are copied from v8 definitions as we cannot include them. | 92 // These are copied from v8 definitions as we cannot include them. |
| 91 const char kV8LogFileSwitch[] = "logfile"; | 93 const char kV8LogFileSwitch[] = "logfile"; |
| 92 const char kV8LogFileDefaultName[] = "v8.log"; | 94 const char kV8LogFileDefaultName[] = "v8.log"; |
| 93 | 95 |
| 94 // String name of local chrome dll for looking up file information. | 96 // String name of local chrome dll for looking up file information. |
| 95 const wchar_t kChromeDll[] = L"chrome.dll"; | 97 const wchar_t kChromeDll[] = L"chrome.dll"; |
| 96 | 98 |
| 97 bool g_append_page_id = false; | 99 bool g_append_page_id = false; |
| 98 int32 g_start_page; | 100 int32 g_start_page; |
| 99 int32 g_end_page; | 101 int32 g_end_page; |
| 100 FilePath g_url_file_path; | 102 FilePath g_url_file_path; |
| 101 int32 g_start_index = 1; | 103 int32 g_start_index = 1; |
| 102 int32 g_end_index = kint32max; | 104 int32 g_end_index = kint32max; |
| 103 int32 g_iterations = 1; | 105 int32 g_iterations = 1; |
| 104 bool g_memory_usage = false; | 106 bool g_memory_usage = false; |
| 105 bool g_continuous_load = false; | 107 bool g_continuous_load = false; |
| 106 bool g_browser_existing = false; | 108 bool g_browser_existing = false; |
| 107 bool g_page_down = true; | 109 bool g_page_down = true; |
| 110 bool g_clear_profile = true; |
| 108 std::string g_end_url; | 111 std::string g_end_url; |
| 109 FilePath g_log_file_path; | 112 FilePath g_log_file_path; |
| 110 int g_timeout_ms = -1; | 113 int g_timeout_ms = -1; |
| 111 bool g_save_debug_log = false; | 114 bool g_save_debug_log = false; |
| 112 FilePath g_chrome_log_path; | 115 FilePath g_chrome_log_path; |
| 113 FilePath g_v8_log_path; | 116 FilePath g_v8_log_path; |
| 114 FilePath g_test_log_path; | 117 FilePath g_test_log_path; |
| 115 bool g_stand_alone = false; | 118 bool g_stand_alone = false; |
| 116 | 119 |
| 117 class PageLoadTest : public UITest { | 120 class PageLoadTest : public UITest { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 441 } |
| 439 | 442 |
| 440 file.close(); | 443 file.close(); |
| 441 } | 444 } |
| 442 | 445 |
| 443 protected: | 446 protected: |
| 444 // Call the base class's SetUp method and initialize our own class members. | 447 // Call the base class's SetUp method and initialize our own class members. |
| 445 virtual void SetUp() { | 448 virtual void SetUp() { |
| 446 UITest::SetUp(); | 449 UITest::SetUp(); |
| 447 g_browser_existing = true; | 450 g_browser_existing = true; |
| 451 clear_profile_ = g_clear_profile; |
| 448 | 452 |
| 449 // Initialize crash_dumps_dir_path_. | 453 // Initialize crash_dumps_dir_path_. |
| 450 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); | 454 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); |
| 451 file_util::FileEnumerator enumerator(crash_dumps_dir_path_, | 455 file_util::FileEnumerator enumerator(crash_dumps_dir_path_, |
| 452 false, // not recursive | 456 false, // not recursive |
| 453 file_util::FileEnumerator::FILES); | 457 file_util::FileEnumerator::FILES); |
| 454 for (FilePath path = enumerator.Next(); !path.value().empty(); | 458 for (FilePath path = enumerator.Next(); !path.value().empty(); |
| 455 path = enumerator.Next()) { | 459 path = enumerator.Next()) { |
| 456 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp"))) | 460 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp"))) |
| 457 crash_dumps_[path.BaseName()] = true; | 461 crash_dumps_[path.BaseName()] = true; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 if (parsed_command_line.HasSwitch(kTimeoutSwitch)) { | 706 if (parsed_command_line.HasSwitch(kTimeoutSwitch)) { |
| 703 ASSERT_TRUE( | 707 ASSERT_TRUE( |
| 704 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( | 708 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( |
| 705 kTimeoutSwitch)), &g_timeout_ms)); | 709 kTimeoutSwitch)), &g_timeout_ms)); |
| 706 ASSERT_GT(g_timeout_ms, 0); | 710 ASSERT_GT(g_timeout_ms, 0); |
| 707 } | 711 } |
| 708 | 712 |
| 709 if (parsed_command_line.HasSwitch(kNoPageDownSwitch)) | 713 if (parsed_command_line.HasSwitch(kNoPageDownSwitch)) |
| 710 g_page_down = false; | 714 g_page_down = false; |
| 711 | 715 |
| 716 if (parsed_command_line.HasSwitch(kNoClearProfileSwitch)) |
| 717 g_clear_profile = false; |
| 718 |
| 712 if (parsed_command_line.HasSwitch(kSaveDebugLogSwitch)) { | 719 if (parsed_command_line.HasSwitch(kSaveDebugLogSwitch)) { |
| 713 g_save_debug_log = true; | 720 g_save_debug_log = true; |
| 714 g_chrome_log_path = logging::GetLogFileName(); | 721 g_chrome_log_path = logging::GetLogFileName(); |
| 715 // We won't get v8 log unless --no-sandbox is specified. | 722 // We won't get v8 log unless --no-sandbox is specified. |
| 716 if (parsed_command_line.HasSwitch(switches::kNoSandbox)) { | 723 if (parsed_command_line.HasSwitch(switches::kNoSandbox)) { |
| 717 PathService::Get(base::DIR_CURRENT, &g_v8_log_path); | 724 PathService::Get(base::DIR_CURRENT, &g_v8_log_path); |
| 718 g_v8_log_path = g_v8_log_path.AppendASCII(kV8LogFileDefaultName); | 725 g_v8_log_path = g_v8_log_path.AppendASCII(kV8LogFileDefaultName); |
| 719 // The command line switch may override the default v8 log path. | 726 // The command line switch may override the default v8 log path. |
| 720 if (parsed_command_line.HasSwitch(switches::kJavaScriptFlags)) { | 727 if (parsed_command_line.HasSwitch(switches::kJavaScriptFlags)) { |
| 721 CommandLine v8_command_line( | 728 CommandLine v8_command_line( |
| 722 parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags)); | 729 parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags)); |
| 723 if (v8_command_line.HasSwitch(kV8LogFileSwitch)) { | 730 if (v8_command_line.HasSwitch(kV8LogFileSwitch)) { |
| 724 g_v8_log_path = FilePath::FromWStringHack( | 731 g_v8_log_path = FilePath::FromWStringHack( |
| 725 v8_command_line.GetSwitchValue(kV8LogFileSwitch)); | 732 v8_command_line.GetSwitchValue(kV8LogFileSwitch)); |
| 726 if (!file_util::AbsolutePath(&g_v8_log_path)) { | 733 if (!file_util::AbsolutePath(&g_v8_log_path)) { |
| 727 g_v8_log_path = FilePath(); | 734 g_v8_log_path = FilePath(); |
| 728 } | 735 } |
| 729 } | 736 } |
| 730 } | 737 } |
| 731 } | 738 } |
| 732 } | 739 } |
| 733 } | 740 } |
| OLD | NEW |