Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 23 | 23 |
| 24 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
| 25 #include <errno.h> | 25 #include <errno.h> |
| 26 #include <fcntl.h> | 26 #include <fcntl.h> |
| 27 #include <string.h> | 27 #include <string.h> |
| 28 #include <sys/resource.h> | 28 #include <sys/resource.h> |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #ifndef NDEBUG | 31 #ifndef NDEBUG |
| 32 #define TEST_ITERATIONS "2" | 32 #define TEST_ITERATIONS 2 |
| 33 #define DATABASE_TEST_ITERATIONS 2 | |
| 33 #else | 34 #else |
| 34 #define TEST_ITERATIONS "10" | 35 #define TEST_ITERATIONS 10 |
| 36 // For some unknown reason, the DB perf tests are much much slower on the | |
| 37 // Vista perf bot, so we have to cut down the number of iterations to 5 | |
| 38 // to make sure each test finishes in less than 10 minutes. | |
| 39 #define DATABASE_TEST_ITERATIONS 5 | |
|
darin (slow to review)
2010/03/22 06:56:49
won't this increase variance? or is the variance
darin (slow to review)
2010/03/22 22:21:01
It would be good to at least file a bug about the
| |
| 35 #endif | 40 #endif |
| 36 | 41 |
| 37 // URL at which data files may be found for HTTP tests. The document root of | 42 // URL at which data files may be found for HTTP tests. The document root of |
| 38 // this URL's server should point to data/page_cycler/. | 43 // this URL's server should point to data/page_cycler/. |
| 39 static const char kBaseUrl[] = "http://localhost:8000/"; | 44 static const char kBaseUrl[] = "http://localhost:8000/"; |
| 40 | 45 |
| 41 namespace { | 46 namespace { |
| 42 | 47 |
| 43 #if defined(OS_MACOSX) | 48 #if defined(OS_MACOSX) |
| 44 // TODO(tvl/stuart): remove all this fd limit setting on the Mac when/if we | 49 // TODO(tvl/stuart): remove all this fd limit setting on the Mac when/if we |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 test_path = test_path.Append(FILE_PATH_LITERAL("data")); | 190 test_path = test_path.Append(FILE_PATH_LITERAL("data")); |
| 186 test_path = test_path.Append(FILE_PATH_LITERAL("page_cycler")); | 191 test_path = test_path.Append(FILE_PATH_LITERAL("page_cycler")); |
| 187 test_path = test_path.AppendASCII(name); | 192 test_path = test_path.AppendASCII(name); |
| 188 return test_path; | 193 return test_path; |
| 189 } | 194 } |
| 190 | 195 |
| 191 virtual bool HasErrors(const std::string /*timings*/) { | 196 virtual bool HasErrors(const std::string /*timings*/) { |
| 192 return false; | 197 return false; |
| 193 } | 198 } |
| 194 | 199 |
| 200 virtual int GetTestIterations() { | |
| 201 return TEST_ITERATIONS; | |
| 202 } | |
| 203 | |
| 195 // For HTTP tests, the name must be safe for use in a URL without escaping. | 204 // For HTTP tests, the name must be safe for use in a URL without escaping. |
| 196 void RunPageCycler(const char* name, std::wstring* pages, | 205 void RunPageCycler(const char* name, std::wstring* pages, |
| 197 std::string* timings, bool use_http) { | 206 std::string* timings, bool use_http) { |
| 198 FilePath test_path = GetDataPath(name); | 207 FilePath test_path = GetDataPath(name); |
| 199 ASSERT_TRUE(file_util::DirectoryExists(test_path)) | 208 ASSERT_TRUE(file_util::DirectoryExists(test_path)) |
| 200 << "Missing test directory " << test_path.value(); | 209 << "Missing test directory " << test_path.value(); |
| 201 | 210 |
| 202 #if defined(OS_MACOSX) | 211 #if defined(OS_MACOSX) |
| 203 PopulateUBC(test_path); | 212 PopulateUBC(test_path); |
| 204 #endif | 213 #endif |
| 205 | 214 |
| 206 GURL test_url; | 215 GURL test_url; |
| 207 if (use_http) { | 216 if (use_http) { |
| 208 test_url = GURL(std::string(kBaseUrl) + name + "/start.html"); | 217 test_url = GURL(std::string(kBaseUrl) + name + "/start.html"); |
| 209 } else { | 218 } else { |
| 210 test_path = test_path.Append(FILE_PATH_LITERAL("start.html")); | 219 test_path = test_path.Append(FILE_PATH_LITERAL("start.html")); |
| 211 test_url = net::FilePathToFileURL(test_path); | 220 test_url = net::FilePathToFileURL(test_path); |
| 212 } | 221 } |
| 213 | 222 |
| 214 // run N iterations | 223 // run N iterations |
| 215 GURL::Replacements replacements; | 224 GURL::Replacements replacements; |
| 216 const char query_string[] = "iterations=" TEST_ITERATIONS "&auto=1"; | 225 const std::string query_string = |
| 226 "iterations=" + IntToString(GetTestIterations()) + "&auto=1"; | |
| 217 replacements.SetQuery( | 227 replacements.SetQuery( |
| 218 query_string, | 228 query_string.c_str(), |
| 219 url_parse::Component(0, arraysize(query_string) - 1)); | 229 url_parse::Component(0, query_string.length())); |
| 220 test_url = test_url.ReplaceComponents(replacements); | 230 test_url = test_url.ReplaceComponents(replacements); |
| 221 | 231 |
| 222 scoped_refptr<TabProxy> tab(GetActiveTab()); | 232 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 223 ASSERT_TRUE(tab.get()); | 233 ASSERT_TRUE(tab.get()); |
| 224 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url)); | 234 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url)); |
| 225 | 235 |
| 226 // Wait for the test to finish. | 236 // Wait for the test to finish. |
| 227 ASSERT_TRUE(WaitUntilCookieValue(tab.get(), test_url, "__pc_done", | 237 ASSERT_TRUE(WaitUntilCookieValue(tab.get(), test_url, "__pc_done", |
| 228 3000, UITest::test_timeout_ms(), "1")); | 238 3000, UITest::test_timeout_ms(), "1")); |
| 229 | 239 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 print_times_only_ = true; | 395 print_times_only_ = true; |
| 386 } | 396 } |
| 387 | 397 |
| 388 virtual FilePath GetDataPath(const char* name) { | 398 virtual FilePath GetDataPath(const char* name) { |
| 389 return GetDatabaseDataPath(name); | 399 return GetDatabaseDataPath(name); |
| 390 } | 400 } |
| 391 | 401 |
| 392 virtual bool HasErrors(const std::string timings) { | 402 virtual bool HasErrors(const std::string timings) { |
| 393 return HasDatabaseErrors(timings); | 403 return HasDatabaseErrors(timings); |
| 394 } | 404 } |
| 405 | |
| 406 virtual int GetTestIterations() { | |
| 407 return DATABASE_TEST_ITERATIONS; | |
| 408 } | |
| 395 }; | 409 }; |
| 396 | 410 |
| 397 class PageCyclerDatabaseReferenceTest : public PageCyclerReferenceTest { | 411 class PageCyclerDatabaseReferenceTest : public PageCyclerReferenceTest { |
| 398 public: | 412 public: |
| 399 PageCyclerDatabaseReferenceTest() { | 413 PageCyclerDatabaseReferenceTest() { |
| 400 print_times_only_ = true; | 414 print_times_only_ = true; |
| 401 } | 415 } |
| 402 | 416 |
| 403 virtual FilePath GetDataPath(const char* name) { | 417 virtual FilePath GetDataPath(const char* name) { |
| 404 return GetDatabaseDataPath(name); | 418 return GetDatabaseDataPath(name); |
| 405 } | 419 } |
| 406 | 420 |
| 407 virtual bool HasErrors(const std::string timings) { | 421 virtual bool HasErrors(const std::string timings) { |
| 408 return HasDatabaseErrors(timings); | 422 return HasDatabaseErrors(timings); |
| 409 } | 423 } |
| 424 | |
| 425 virtual int GetTestIterations() { | |
| 426 return DATABASE_TEST_ITERATIONS; | |
| 427 } | |
| 410 }; | 428 }; |
| 411 | 429 |
| 412 // This macro simplifies setting up regular and reference build tests. | 430 // This macro simplifies setting up regular and reference build tests. |
| 413 #define PAGE_CYCLER_TESTS(test, name, use_http) \ | 431 #define PAGE_CYCLER_TESTS(test, name, use_http) \ |
| 414 TEST_F(PageCyclerTest, name) { \ | 432 TEST_F(PageCyclerTest, name) { \ |
| 415 RunTest("times", test, use_http); \ | 433 RunTest("times", test, use_http); \ |
| 416 } \ | 434 } \ |
| 417 TEST_F(PageCyclerReferenceTest, name) { \ | 435 TEST_F(PageCyclerReferenceTest, name) { \ |
| 418 RunTest("times", test, use_http); \ | 436 RunTest("times", test, use_http); \ |
| 419 } | 437 } |
| 420 | 438 |
| 421 // This macro simplifies setting up regular and reference build tests | 439 // This macro simplifies setting up regular and reference build tests |
| 422 // for HTML5 database tests. | 440 // for HTML5 database tests. |
| 423 // TODO(dumi): re-enable the DB perf tests once we figure out why | |
| 424 // they're so slow on the release perf bots | |
| 425 #define PAGE_CYCLER_DATABASE_TESTS(test, name) \ | 441 #define PAGE_CYCLER_DATABASE_TESTS(test, name) \ |
| 426 TEST_F(PageCyclerDatabaseTest, DISABLED_Database##name##File) { \ | 442 TEST_F(PageCyclerDatabaseTest, Database##name##File) { \ |
| 427 RunTest(test, test, false); \ | 443 RunTest(test, test, false); \ |
| 428 } \ | 444 } \ |
| 429 TEST_F(PageCyclerDatabaseReferenceTest, DISABLED_Database##name##File) { \ | 445 TEST_F(PageCyclerDatabaseReferenceTest, Database##name##File) { \ |
| 430 RunTest(test, test, false); \ | 446 RunTest(test, test, false); \ |
| 431 } | 447 } |
| 432 | 448 |
| 433 // These are shorthand for File vs. Http tests. | 449 // These are shorthand for File vs. Http tests. |
| 434 #define PAGE_CYCLER_FILE_TESTS(test, name) \ | 450 #define PAGE_CYCLER_FILE_TESTS(test, name) \ |
| 435 PAGE_CYCLER_TESTS(test, name, false) | 451 PAGE_CYCLER_TESTS(test, name, false) |
| 436 #define PAGE_CYCLER_HTTP_TESTS(test, name) \ | 452 #define PAGE_CYCLER_HTTP_TESTS(test, name) \ |
| 437 PAGE_CYCLER_TESTS(test, name, true) | 453 PAGE_CYCLER_TESTS(test, name, true) |
| 438 | 454 |
| 439 // This macro lets us define tests with 1 and 10 extensions with 1 content | 455 // This macro lets us define tests with 1 and 10 extensions with 1 content |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 PAGE_CYCLER_DATABASE_TESTS("insert-transactions", | 490 PAGE_CYCLER_DATABASE_TESTS("insert-transactions", |
| 475 InsertTransactions); | 491 InsertTransactions); |
| 476 PAGE_CYCLER_DATABASE_TESTS("update-transactions", | 492 PAGE_CYCLER_DATABASE_TESTS("update-transactions", |
| 477 UpdateTransactions); | 493 UpdateTransactions); |
| 478 PAGE_CYCLER_DATABASE_TESTS("delete-transactions", | 494 PAGE_CYCLER_DATABASE_TESTS("delete-transactions", |
| 479 DeleteTransactions); | 495 DeleteTransactions); |
| 480 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions", | 496 PAGE_CYCLER_DATABASE_TESTS("pseudo-random-transactions", |
| 481 PseudoRandomTransactions); | 497 PseudoRandomTransactions); |
| 482 | 498 |
| 483 } // namespace | 499 } // namespace |
| OLD | NEW |