| 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 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/eintr_wrapper.h" | 7 #include "base/eintr_wrapper.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 144 } |
| 145 HANDLE_EINTR(close(fd)); | 145 HANDLE_EINTR(close(fd)); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 LOG(INFO) << "UBC should be loaded with " << loaded << " files."; | 149 LOG(INFO) << "UBC should be loaded with " << loaded << " files."; |
| 150 } | 150 } |
| 151 #endif // defined(OS_MACOSX) | 151 #endif // defined(OS_MACOSX) |
| 152 | 152 |
| 153 class PageCyclerTest : public UITest { | 153 class PageCyclerTest : public UITest { |
| 154 protected: |
| 155 bool print_times_only_; |
| 154 #if defined(OS_MACOSX) | 156 #if defined(OS_MACOSX) |
| 155 protected: | |
| 156 rlim_t fd_limit_; | 157 rlim_t fd_limit_; |
| 157 #endif | 158 #endif |
| 158 public: | 159 public: |
| 159 PageCyclerTest() { | 160 PageCyclerTest() |
| 161 : print_times_only_(false) { |
| 160 show_window_ = true; | 162 show_window_ = true; |
| 161 | 163 |
| 164 |
| 162 // Expose garbage collection for the page cycler tests. | 165 // Expose garbage collection for the page cycler tests. |
| 163 launch_arguments_.AppendSwitchWithValue(switches::kJavaScriptFlags, | 166 launch_arguments_.AppendSwitchWithValue(switches::kJavaScriptFlags, |
| 164 L"--expose_gc"); | 167 L"--expose_gc"); |
| 165 #if defined(OS_MACOSX) | 168 #if defined(OS_MACOSX) |
| 166 static rlim_t initial_fd_limit = GetFileDescriptorLimit(); | 169 static rlim_t initial_fd_limit = GetFileDescriptorLimit(); |
| 167 fd_limit_ = initial_fd_limit; | 170 fd_limit_ = initial_fd_limit; |
| 168 #endif | 171 #endif |
| 169 } | 172 } |
| 170 | 173 |
| 171 void SetUp() { | 174 void SetUp() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 ASSERT_FALSE(pages->empty()); | 233 ASSERT_FALSE(pages->empty()); |
| 231 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_timings", &cookie)); | 234 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_timings", &cookie)); |
| 232 timings->assign(cookie); | 235 timings->assign(cookie); |
| 233 ASSERT_FALSE(timings->empty()); | 236 ASSERT_FALSE(timings->empty()); |
| 234 } | 237 } |
| 235 | 238 |
| 236 // When use_http is true, the test name passed here will be used directly in | 239 // When use_http is true, the test name passed here will be used directly in |
| 237 // the path to the test data, so it must be safe for use in a URL without | 240 // the path to the test data, so it must be safe for use in a URL without |
| 238 // escaping. (No pound (#), question mark (?), semicolon (;), non-ASCII, or | 241 // escaping. (No pound (#), question mark (?), semicolon (;), non-ASCII, or |
| 239 // other funny stuff.) | 242 // other funny stuff.) |
| 240 void RunTestWithSuffix(const char* name, bool use_http, const char* suffix) { | 243 void RunTestWithSuffix(const char* graph, const char* name, bool use_http, |
| 244 const char* suffix) { |
| 241 std::wstring pages; | 245 std::wstring pages; |
| 242 std::string timings; | 246 std::string timings; |
| 243 size_t start_size = base::GetSystemCommitCharge(); | 247 size_t start_size = base::GetSystemCommitCharge(); |
| 244 RunPageCycler(name, &pages, &timings, use_http); | 248 RunPageCycler(name, &pages, &timings, use_http); |
| 245 if (timings.empty() || HasErrors(timings)) | 249 if (timings.empty() || HasErrors(timings)) |
| 246 return; | 250 return; |
| 247 size_t stop_size = base::GetSystemCommitCharge(); | 251 size_t stop_size = base::GetSystemCommitCharge(); |
| 248 | 252 |
| 249 PrintMemoryUsageInfo(suffix); | 253 if (!print_times_only_) { |
| 250 PrintIOPerfInfo(suffix); | 254 PrintMemoryUsageInfo(suffix); |
| 251 PrintSystemCommitCharge(suffix, stop_size - start_size, | 255 PrintIOPerfInfo(suffix); |
| 252 false /* not important */); | 256 PrintSystemCommitCharge(suffix, stop_size - start_size, |
| 257 false /* not important */); |
| 258 } |
| 253 | 259 |
| 254 std::string trace_name = "t" + std::string(suffix); | 260 std::string trace_name = "t" + std::string(suffix); |
| 255 wprintf(L"\nPages: [%ls]\n", pages.c_str()); | 261 wprintf(L"\nPages: [%ls]\n", pages.c_str()); |
| 256 PrintResultList("times", "", trace_name, timings, "ms", | 262 PrintResultList(graph, "", trace_name, timings, "ms", |
| 257 true /* important */); | 263 true /* important */); |
| 258 } | 264 } |
| 259 | 265 |
| 260 void RunTest(const char* name, bool use_http) { | 266 void RunTest(const char* graph, const char* name, bool use_http) { |
| 261 RunTestWithSuffix(name, use_http, ""); | 267 RunTestWithSuffix(graph, name, use_http, ""); |
| 262 } | 268 } |
| 263 }; | 269 }; |
| 264 | 270 |
| 265 class PageCyclerReferenceTest : public PageCyclerTest { | 271 class PageCyclerReferenceTest : public PageCyclerTest { |
| 266 public: | 272 public: |
| 267 // override the browser directory that is used by UITest::SetUp to cause it | 273 // override the browser directory that is used by UITest::SetUp to cause it |
| 268 // to use the reference build instead. | 274 // to use the reference build instead. |
| 269 void SetUp() { | 275 void SetUp() { |
| 270 #if defined(OS_MACOSX) | 276 #if defined(OS_MACOSX) |
| 271 fd_limit_ = 1024; | 277 fd_limit_ = 1024; |
| 272 #endif | 278 #endif |
| 273 | 279 |
| 274 FilePath dir; | 280 FilePath dir; |
| 275 PathService::Get(chrome::DIR_TEST_TOOLS, &dir); | 281 PathService::Get(chrome::DIR_TEST_TOOLS, &dir); |
| 276 dir = dir.AppendASCII("reference_build"); | 282 dir = dir.AppendASCII("reference_build"); |
| 277 #if defined(OS_WIN) | 283 #if defined(OS_WIN) |
| 278 dir = dir.AppendASCII("chrome"); | 284 dir = dir.AppendASCII("chrome"); |
| 279 #elif defined(OS_LINUX) | 285 #elif defined(OS_LINUX) |
| 280 dir = dir.AppendASCII("chrome_linux"); | 286 dir = dir.AppendASCII("chrome_linux"); |
| 281 #elif defined(OS_MACOSX) | 287 #elif defined(OS_MACOSX) |
| 282 dir = dir.AppendASCII("chrome_mac"); | 288 dir = dir.AppendASCII("chrome_mac"); |
| 283 #endif | 289 #endif |
| 284 browser_directory_ = dir; | 290 browser_directory_ = dir; |
| 285 PageCyclerTest::SetUp(); | 291 PageCyclerTest::SetUp(); |
| 286 } | 292 } |
| 287 | 293 |
| 288 void RunTest(const char* name, bool use_http) { | 294 void RunTest(const char* graph, const char* name, bool use_http) { |
| 289 std::wstring pages; | 295 std::wstring pages; |
| 290 std::string timings; | 296 std::string timings; |
| 291 size_t start_size = base::GetSystemCommitCharge(); | 297 size_t start_size = base::GetSystemCommitCharge(); |
| 292 RunPageCycler(name, &pages, &timings, use_http); | 298 RunPageCycler(name, &pages, &timings, use_http); |
| 293 if (timings.empty()) | 299 if (timings.empty()) |
| 294 return; | 300 return; |
| 295 size_t stop_size = base::GetSystemCommitCharge(); | 301 size_t stop_size = base::GetSystemCommitCharge(); |
| 296 | 302 |
| 297 PrintMemoryUsageInfo("_ref"); | 303 if (!print_times_only_) { |
| 298 PrintIOPerfInfo("_ref"); | 304 PrintMemoryUsageInfo("_ref"); |
| 299 PrintSystemCommitCharge("_ref", stop_size - start_size, | 305 PrintIOPerfInfo("_ref"); |
| 300 false /* not important */); | 306 PrintSystemCommitCharge("_ref", stop_size - start_size, |
| 307 false /* not important */); |
| 308 } |
| 301 | 309 |
| 302 PrintResultList("times", "", "t_ref", timings, "ms", | 310 PrintResultList(graph, "", "t_ref", timings, "ms", |
| 303 true /* important */); | 311 true /* important */); |
| 304 } | 312 } |
| 305 }; | 313 }; |
| 306 | 314 |
| 307 class PageCyclerExtensionTest : public PageCyclerTest { | 315 class PageCyclerExtensionTest : public PageCyclerTest { |
| 308 public: | 316 public: |
| 309 void SetUp() {} | 317 void SetUp() {} |
| 310 void RunTest(const char* extension_profile, const char* output_suffix, | 318 void RunTest(const char* graph, const char* extension_profile, |
| 311 const char* name, bool use_http) { | 319 const char* output_suffix, const char* name, bool use_http) { |
| 312 // Set up the extension profile directory. | 320 // Set up the extension profile directory. |
| 313 ASSERT_TRUE(extension_profile != NULL); | 321 ASSERT_TRUE(extension_profile != NULL); |
| 314 FilePath data_dir; | 322 FilePath data_dir; |
| 315 PathService::Get(chrome::DIR_TEST_DATA, &data_dir); | 323 PathService::Get(chrome::DIR_TEST_DATA, &data_dir); |
| 316 data_dir = data_dir.AppendASCII("extensions").AppendASCII("profiles"). | 324 data_dir = data_dir.AppendASCII("extensions").AppendASCII("profiles"). |
| 317 AppendASCII(extension_profile); | 325 AppendASCII(extension_profile); |
| 318 ASSERT_TRUE(file_util::DirectoryExists(data_dir)); | 326 ASSERT_TRUE(file_util::DirectoryExists(data_dir)); |
| 319 set_template_user_data(data_dir); | 327 set_template_user_data(data_dir); |
| 320 | 328 |
| 321 // Now run the test. | 329 // Now run the test. |
| 322 PageCyclerTest::SetUp(); | 330 PageCyclerTest::SetUp(); |
| 323 PageCyclerTest::RunTestWithSuffix(name, use_http, output_suffix); | 331 PageCyclerTest::RunTestWithSuffix(graph, name, use_http, output_suffix); |
| 324 } | 332 } |
| 325 }; | 333 }; |
| 326 | 334 |
| 327 static FilePath GetDatabaseDataPath(const char* name) { | 335 static FilePath GetDatabaseDataPath(const char* name) { |
| 328 FilePath test_path; | 336 FilePath test_path; |
| 329 PathService::Get(base::DIR_SOURCE_ROOT, &test_path); | 337 PathService::Get(base::DIR_SOURCE_ROOT, &test_path); |
| 330 test_path = test_path.Append(FILE_PATH_LITERAL("tools")); | 338 test_path = test_path.Append(FILE_PATH_LITERAL("tools")); |
| 331 test_path = test_path.Append(FILE_PATH_LITERAL("page_cycler")); | 339 test_path = test_path.Append(FILE_PATH_LITERAL("page_cycler")); |
| 332 test_path = test_path.Append(FILE_PATH_LITERAL("database")); | 340 test_path = test_path.Append(FILE_PATH_LITERAL("database")); |
| 333 test_path = test_path.AppendASCII(name); | 341 test_path = test_path.AppendASCII(name); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 374 } |
| 367 | 375 |
| 368 pos = new_pos + 1; | 376 pos = new_pos + 1; |
| 369 } while (pos < timings.length()); | 377 } while (pos < timings.length()); |
| 370 | 378 |
| 371 return false; | 379 return false; |
| 372 } | 380 } |
| 373 | 381 |
| 374 class PageCyclerDatabaseTest : public PageCyclerTest { | 382 class PageCyclerDatabaseTest : public PageCyclerTest { |
| 375 public: | 383 public: |
| 384 PageCyclerDatabaseTest() { |
| 385 print_times_only_ = true; |
| 386 } |
| 387 |
| 376 virtual FilePath GetDataPath(const char* name) { | 388 virtual FilePath GetDataPath(const char* name) { |
| 377 return GetDatabaseDataPath(name); | 389 return GetDatabaseDataPath(name); |
| 378 } | 390 } |
| 379 | 391 |
| 380 virtual bool HasErrors(const std::string timings) { | 392 virtual bool HasErrors(const std::string timings) { |
| 381 return HasDatabaseErrors(timings); | 393 return HasDatabaseErrors(timings); |
| 382 } | 394 } |
| 383 }; | 395 }; |
| 384 | 396 |
| 385 class PageCyclerDatabaseReferenceTest : public PageCyclerReferenceTest { | 397 class PageCyclerDatabaseReferenceTest : public PageCyclerReferenceTest { |
| 386 public: | 398 public: |
| 399 PageCyclerDatabaseReferenceTest() { |
| 400 print_times_only_ = true; |
| 401 } |
| 402 |
| 387 virtual FilePath GetDataPath(const char* name) { | 403 virtual FilePath GetDataPath(const char* name) { |
| 388 return GetDatabaseDataPath(name); | 404 return GetDatabaseDataPath(name); |
| 389 } | 405 } |
| 390 | 406 |
| 391 virtual bool HasErrors(const std::string timings) { | 407 virtual bool HasErrors(const std::string timings) { |
| 392 return HasDatabaseErrors(timings); | 408 return HasDatabaseErrors(timings); |
| 393 } | 409 } |
| 394 }; | 410 }; |
| 395 | 411 |
| 396 // This macro simplifies setting up regular and reference build tests. | 412 // This macro simplifies setting up regular and reference build tests. |
| 397 #define PAGE_CYCLER_TESTS(test, name, use_http) \ | 413 #define PAGE_CYCLER_TESTS(test, name, use_http) \ |
| 398 TEST_F(PageCyclerTest, name) { \ | 414 TEST_F(PageCyclerTest, name) { \ |
| 399 RunTest(test, use_http); \ | 415 RunTest("times", test, use_http); \ |
| 400 } \ | 416 } \ |
| 401 TEST_F(PageCyclerReferenceTest, name) { \ | 417 TEST_F(PageCyclerReferenceTest, name) { \ |
| 402 RunTest(test, use_http); \ | 418 RunTest("times", test, use_http); \ |
| 403 } | 419 } |
| 404 | 420 |
| 405 // This macro simplifies setting up regular and reference build tests | 421 // This macro simplifies setting up regular and reference build tests |
| 406 // for HTML5 database tests. | 422 // for HTML5 database tests. |
| 407 #define PAGE_CYCLER_DATABASE_TESTS(test, name) \ | 423 #define PAGE_CYCLER_DATABASE_TESTS(test, name) \ |
| 408 TEST_F(PageCyclerDatabaseTest, name) { \ | 424 TEST_F(PageCyclerDatabaseTest, Database##name##File) { \ |
| 409 RunTest(test, false); \ | 425 RunTest(test, test, false); \ |
| 410 } \ | 426 } \ |
| 411 TEST_F(PageCyclerDatabaseReferenceTest, name) { \ | 427 TEST_F(PageCyclerDatabaseReferenceTest, Database##name##File) { \ |
| 412 RunTest(test, false); \ | 428 RunTest(test, test, false); \ |
| 413 } | 429 } |
| 414 | 430 |
| 415 // These are shorthand for File vs. Http tests. | 431 // These are shorthand for File vs. Http tests. |
| 416 #define PAGE_CYCLER_FILE_TESTS(test, name)\ | 432 #define PAGE_CYCLER_FILE_TESTS(test, name) \ |
| 417 PAGE_CYCLER_TESTS(test, name, false) | 433 PAGE_CYCLER_TESTS(test, name, false) |
| 418 #define PAGE_CYCLER_HTTP_TESTS(test, name)\ | 434 #define PAGE_CYCLER_HTTP_TESTS(test, name) \ |
| 419 PAGE_CYCLER_TESTS(test, name, true) | 435 PAGE_CYCLER_TESTS(test, name, true) |
| 420 | 436 |
| 421 // This macro lets us define tests with 1 and 10 extensions with 1 content | 437 // This macro lets us define tests with 1 and 10 extensions with 1 content |
| 422 // script each. The name for the 10-extension case is changed so as not | 438 // script each. The name for the 10-extension case is changed so as not |
| 423 // to run by default on the buildbots. | 439 // to run by default on the buildbots. |
| 424 #define PAGE_CYCLER_EXTENSIONS_FILE_TESTS(test, name) \ | 440 #define PAGE_CYCLER_EXTENSIONS_FILE_TESTS(test, name) \ |
| 425 TEST_F(PageCyclerExtensionTest, name) { \ | 441 TEST_F(PageCyclerExtensionTest, name) { \ |
| 426 RunTest("content_scripts1", "_extcs1", test, false); \ | 442 RunTest("times", "content_scripts1", "_extcs1", test, false); \ |
| 427 } \ | 443 } \ |
| 428 TEST_F(PageCyclerExtensionTest, name##10) { \ | 444 TEST_F(PageCyclerExtensionTest, name##10) { \ |
| 429 RunTest("content_scripts10", "_extcs10", test, false); \ | 445 RunTest("times", "content_scripts10", "_extcs10", test, false); \ |
| 430 } | 446 } |
| 431 | 447 |
| 432 // file-URL tests | 448 // file-URL tests |
| 433 PAGE_CYCLER_FILE_TESTS("moz", MozFile); | 449 PAGE_CYCLER_FILE_TESTS("moz", MozFile); |
| 434 PAGE_CYCLER_EXTENSIONS_FILE_TESTS("moz", MozFile); | 450 PAGE_CYCLER_EXTENSIONS_FILE_TESTS("moz", MozFile); |
| 435 PAGE_CYCLER_FILE_TESTS("intl1", Intl1File); | 451 PAGE_CYCLER_FILE_TESTS("intl1", Intl1File); |
| 436 PAGE_CYCLER_FILE_TESTS("intl2", Intl2File); | 452 PAGE_CYCLER_FILE_TESTS("intl2", Intl2File); |
| 437 PAGE_CYCLER_FILE_TESTS("dom", DomFile); | 453 PAGE_CYCLER_FILE_TESTS("dom", DomFile); |
| 438 PAGE_CYCLER_FILE_TESTS("dhtml", DhtmlFile); | 454 PAGE_CYCLER_FILE_TESTS("dhtml", DhtmlFile); |
| 439 PAGE_CYCLER_FILE_TESTS("morejs", MorejsFile); | 455 PAGE_CYCLER_FILE_TESTS("morejs", MorejsFile); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 456 PAGE_CYCLER_DATABASE_TESTS("insert-transactions", | 472 PAGE_CYCLER_DATABASE_TESTS("insert-transactions", |
| 457 InsertTransactions); | 473 InsertTransactions); |
| 458 PAGE_CYCLER_DATABASE_TESTS("update-transactions", | 474 PAGE_CYCLER_DATABASE_TESTS("update-transactions", |
| 459 UpdateTransactions); | 475 UpdateTransactions); |
| 460 PAGE_CYCLER_DATABASE_TESTS("delete-transactions", | 476 PAGE_CYCLER_DATABASE_TESTS("delete-transactions", |
| 461 DeleteTransactions); | 477 DeleteTransactions); |
| 462 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions", | 478 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions", |
| 463 PseudoRandomTransactions); | 479 PseudoRandomTransactions); |
| 464 | 480 |
| 465 } // namespace | 481 } // namespace |
| OLD | NEW |