diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 03:00:37 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 03:00:37 +0000 |
commit | ddc719ac4cc477cfaaffbfac1031da20deb743e7 (patch) | |
tree | 7c0ad3a2480b5738c3a0bdf54b452ff4d939b7c5 /chrome/test/memory_test | |
parent | 2361809186c4d5b1a2033c417042cfc202af2aef (diff) | |
download | chromium_src-ddc719ac4cc477cfaaffbfac1031da20deb743e7.zip chromium_src-ddc719ac4cc477cfaaffbfac1031da20deb743e7.tar.gz chromium_src-ddc719ac4cc477cfaaffbfac1031da20deb743e7.tar.bz2 |
A few changes to make the memory test a little better.
* Add a delay to workaround bug 2953 for the moment.
* If a user-data-dir is specified, don't try to copy files.
* Add some logging on various failures.
Review URL: http://codereview.chromium.org/14416
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/memory_test')
-rw-r--r-- | chrome/test/memory_test/memory_test.cc | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc index fc68ede..48deae0 100644 --- a/chrome/test/memory_test/memory_test.cc +++ b/chrome/test/memory_test/memory_test.cc @@ -27,7 +27,7 @@ static const wchar_t kTempDirName[] = L"memory_test_profile"; class MemoryTest : public UITest { public: - MemoryTest() { + MemoryTest() : cleanup_temp_dir_on_exit_(false) { show_window_ = true; // For now, turn off plugins because they crash like crazy. @@ -52,15 +52,15 @@ class MemoryTest : public UITest { file_util::AppendToPath(&profile_dir, L"data"); file_util::AppendToPath(&profile_dir, L"memory_test"); file_util::AppendToPath(&profile_dir, L"general_mix"); - } - if (!SetupTempDirectory(profile_dir)) { - // There isn't really a way to fail gracefully here. - // Neither this constuctor nor the SetUp() method return - // status to the caller. So, just fall through using the - // default profile and log this. The failure will be - // obvious. - LOG(ERROR) << "Error preparing temp directory for test"; + if (!SetupTempDirectory(profile_dir)) { + // There isn't really a way to fail gracefully here. + // Neither this constuctor nor the SetUp() method return + // status to the caller. So, just fall through using the + // default profile and log this. The failure will be + // obvious. + LOG(ERROR) << "Error preparing temp directory for test"; + } } CommandLine::AppendSwitchWithValue(&launch_arguments_, @@ -70,7 +70,7 @@ class MemoryTest : public UITest { ~MemoryTest() { // Cleanup our temporary directory. - if (user_data_dir_.length() > 0) + if (cleanup_temp_dir_on_exit_) file_util::Delete(user_data_dir_, true); } @@ -248,6 +248,11 @@ class MemoryTest : public UITest { &timed_out); if (timed_out) printf("warning: %s timed out!\n", urls[counter].c_str()); + + // TODO(mbelshe): Bug 2953 + // The automation crashes periodically if we cycle too quickly. + // To make these tests more reliable, slowing them down a bit. + Sleep(100); } size_t stop_size = GetSystemCommitCharge(); @@ -371,23 +376,32 @@ class MemoryTest : public UITest { // src_dir is set to the source directory // Output: // On success, modifies user_data_dir_ to be a new profile directory + // and sets cleanup_temp_dir_on_exit_ to true. bool SetupTempDirectory(std::wstring src_dir) { + LOG(INFO) << "Setting up temp directory in " << src_dir.c_str(); // We create a copy of the test dir and use it so that each // run of this test starts with the same data. Running this // test has the side effect that it will change the profile. std::wstring temp_dir; - if (!file_util::CreateNewTempDirectory(kTempDirName, &temp_dir)) + if (!file_util::CreateNewTempDirectory(kTempDirName, &temp_dir)) { + LOG(ERROR) << "Could not create temp directory:" << kTempDirName; return false; + } src_dir.append(L"\\*"); - if (!file_util::CopyDirectory(src_dir, temp_dir, true)) + if (!file_util::CopyDirectory(src_dir, temp_dir, true)) { + LOG(ERROR) << "Could not copy temp directory"; return false; + } user_data_dir_ = temp_dir; + cleanup_temp_dir_on_exit_ = true; + LOG(INFO) << "Finished temp directory setup."; return true; } + bool cleanup_temp_dir_on_exit_; std::wstring user_data_dir_; }; |