diff options
author | ojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-17 00:51:40 +0000 |
---|---|---|
committer | ojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-17 00:51:40 +0000 |
commit | b531284945332066027a35bf95de1acb54efd8c6 (patch) | |
tree | bcf074a790f9bb298eb06b3ef7bee6c8f96bf5b6 /webkit | |
parent | a862471b184f63a6f39c854e3abe4c26fb1edd1c (diff) | |
download | chromium_src-b531284945332066027a35bf95de1acb54efd8c6.zip chromium_src-b531284945332066027a35bf95de1acb54efd8c6.tar.gz chromium_src-b531284945332066027a35bf95de1acb54efd8c6.tar.bz2 |
Only dump image results if the hashes don't match.
We spend a lot of time doing PNG encoding now for passing tests.
There's more work to be done for the --run-singly case still.
This seems to save another ~2minutes on Windows Release.
Review URL: http://codereview.chromium.org/79035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13911 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/layout_tests/layout_package/test_shell_thread.py | 10 | ||||
-rwxr-xr-x | webkit/tools/layout_tests/run_webkit_tests.py | 16 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_shell.cc | 30 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.h | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 15 |
5 files changed, 56 insertions, 20 deletions
diff --git a/webkit/tools/layout_tests/layout_package/test_shell_thread.py b/webkit/tools/layout_tests/layout_package/test_shell_thread.py index 008cdee..bcd9e96 100644 --- a/webkit/tools/layout_tests/layout_package/test_shell_thread.py +++ b/webkit/tools/layout_tests/layout_package/test_shell_thread.py @@ -357,10 +357,12 @@ class TestShellThread(threading.Thread): A list of TestFailure objects describing the error. """ self._EnsureTestShellIsRunning() - # Args to test_shell is a space-separated list of "uri timeout" or just a - # uri to use the default timeout specified in run_webkit_tests. - self._test_shell_proc.stdin.write(("%s %s\n" % - (test_info.uri, test_info.timeout))) + # Args to test_shell is a space-separated list of "uri timeout pixel_hash" + # The timeout and pixel_hash are optional. The timeout is used if this + # test has a custom timeout. The pixel_hash is used to avoid doing an image + # dump if the checksums match. + self._test_shell_proc.stdin.write(("%s %s %s\n" % + (test_info.uri, test_info.timeout, test_info.image_hash))) # If the test shell is dead, the above may cause an IOError as we # try to write onto the broken pipe. If this is the first test for diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py index 9ef0e2b..300139d 100755 --- a/webkit/tools/layout_tests/run_webkit_tests.py +++ b/webkit/tools/layout_tests/run_webkit_tests.py @@ -20,6 +20,7 @@ directory. Entire lines starting with '//' (comments) will be ignored. For details of the files' contents and purposes, see test_lists/README. """ +import errno import glob import logging import math @@ -50,15 +51,25 @@ from test_types import simplified_text_diff class TestInfo: """Groups information about a test for easy passing of data.""" - def __init__(self, filename, timeout): + def __init__(self, filename, timeout, platform): """Generates the URI and stores the filename and timeout for this test. Args: filename: Full path to the test. timeout: Timeout for running the test in TestShell. + platform: The platform whose test expected results to grab. """ self.filename = filename self.uri = path_utils.FilenameToUri(filename) self.timeout = timeout + expected_hash_file = path_utils.ExpectedFilename(filename, + '.checksum', + platform) + try: + self.image_hash = open(expected_hash_file, "r").read() + except IOError, e: + if errno.ENOENT != e.errno: + raise + self.image_hash = None class TestRunner: @@ -364,7 +375,8 @@ class TestRunner: else: timeout = self._options.time_out_ms - tests_by_dir[directory].append(TestInfo(test_file, timeout)) + tests_by_dir[directory].append(TestInfo(test_file, timeout, + self._options.platform)) # Sort by the number of tests in the dir so that the ones with the most # tests get run first in order to maximize parallelization. Number of tests diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index b072d21..ea141528 100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -228,7 +228,8 @@ void TestShell::Dump(TestShell* shell) { // command line (for the dump pixels argument), and the MD5 sum to // stdout. dumped_anything = true; - std::string md5sum = DumpImage(webFrame, params->pixel_file_name); + std::string md5sum = DumpImage(webFrame, params->pixel_file_name, + params->pixel_hash); printf("#MD5:%s\n", md5sum.c_str()); } if (dumped_anything) @@ -239,7 +240,7 @@ void TestShell::Dump(TestShell* shell) { // static std::string TestShell::DumpImage(WebFrame* web_frame, - const std::wstring& file_name) { + const std::wstring& file_name, const std::string& pixel_hash) { scoped_ptr<skia::BitmapPlatformDevice> device; if (!web_frame->CaptureImage(&device, true)) return std::string(); @@ -264,14 +265,6 @@ std::string TestShell::DumpImage(WebFrame* web_frame, #elif defined(OS_MACOSX) bool discard_transparency = false; #endif - PNGEncoder::Encode( - reinterpret_cast<const unsigned char*>(src_bmp.getPixels()), - color_format, src_bmp.width(), src_bmp.height(), - static_cast<int>(src_bmp.rowBytes()), discard_transparency, &png); - - // Write to disk. - file_util::WriteFile(file_name, reinterpret_cast<const char *>(&png[0]), - png.size()); // Compute MD5 sum. MD5Context ctx; @@ -280,7 +273,22 @@ std::string TestShell::DumpImage(WebFrame* web_frame, MD5Digest digest; MD5Final(&digest, &ctx); - return MD5DigestToBase16(digest); + std::string md5hash = MD5DigestToBase16(digest); + + // Only encode and dump the png if the hashes don't match. Encoding the image + // is really expensive. + if (md5hash.compare(0, pixel_hash.length(), pixel_hash) != 0) { + PNGEncoder::Encode( + reinterpret_cast<const unsigned char*>(src_bmp.getPixels()), + color_format, src_bmp.width(), src_bmp.height(), + static_cast<int>(src_bmp.rowBytes()), discard_transparency, &png); + + // Write to disk. + file_util::WriteFile(file_name, reinterpret_cast<const char *>(&png[0]), + png.size()); + } + + return md5hash; } // static diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 11c8daf..c5806c3 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -64,6 +64,8 @@ public: // Filename we dump pixels to (when pixel testing is enabled). std::wstring pixel_file_name; + // The md5 hash of the bitmap dump (when pixel testing is enabled). + std::string pixel_hash; // URL of the test. std::string test_url; }; @@ -201,7 +203,8 @@ public: // Writes the image captured from the given web frame to the given file. // The returned string is the ASCII-ized MD5 sum of the image. static std::string DumpImage(WebFrame* web_frame, - const std::wstring& file_name); + const std::wstring& file_name, + const std::string& pixel_hash); static void ResetWebPreferences(); diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index a0ce4a9..2e21b1b 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -263,6 +263,10 @@ int main(int argc, char* argv[]) { // Watch stdin for URLs. char filenameBuffer[kPathBufSize]; while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) { + // When running layout tests we pass new line separated + // tests to TestShell. Each line is a space separated list + // of filename, timeout and expected pixel hash. The timeout + // and the pixel hash are optional. char* newLine = strchr(filenameBuffer, '\n'); if (newLine) *newLine = '\0'; @@ -271,10 +275,15 @@ int main(int argc, char* argv[]) { params.test_url = strtok(filenameBuffer, " "); - char* timeout = strtok(NULL, " "); int old_timeout_ms = TestShell::GetLayoutTestTimeout(); - if (timeout) + + char* timeout = strtok(NULL, " "); + if (timeout) { TestShell::SetFileTestTimeout(atoi(timeout)); + char* pixel_hash = strtok(NULL, " "); + if (pixel_hash) + params.pixel_hash = pixel_hash; + } if (!TestShell::RunFileTest(params)) break; @@ -282,6 +291,8 @@ int main(int argc, char* argv[]) { TestShell::SetFileTestTimeout(old_timeout_ms); } } else { + // TODO(ojan): Provide a way for run-singly tests to pass + // in a hash and then set params.pixel_hash here. params.test_url = WideToUTF8(uri).c_str(); TestShell::RunFileTest(params); } |