diff options
author | stephana <stephana@google.com> | 2017-01-02 06:19:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2017-01-02 06:19:41 -0800 |
commit | fa05e97fc4d796bd12e21c32634d9614f8edf607 (patch) | |
tree | 51ce6dd564bf9129bac591813da6ccfc8dc9edb3 /testing/tools/common.py | |
parent | aea77059d309820dbcea9ec3e583fa673960a0b9 (diff) | |
download | pdfium-fa05e97fc4d796bd12e21c32634d9614f8edf607.tar.xz |
Gold support in PDFiumchromium/2970
Extends the PDFium tests to collect images and meta data to be uploaded
to Gold. This feature is triggered by adding the --gold_* flags.
It extends pdfium_test to output the MD5 hash of the underlying pixel
buffer for each page it renders.
That output is then processed by test_runner.py to generate the
gold meta data.
This behavior is modeled after the 'dm' tool in skia. See
https://skia.googlesource.com/skia/+/master/dm/DM.cpp#1090
This should not cause any change in the current behavior of the tests,
it will be trigger once we update the buildbot recipe.
BUG=skia:5973
Review-Url: https://codereview.chromium.org/2578893004
Diffstat (limited to 'testing/tools/common.py')
-rwxr-xr-x | testing/tools/common.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/tools/common.py b/testing/tools/common.py index 1e1d257f48..a0cc946f1a 100755 --- a/testing/tools/common.py +++ b/testing/tools/common.py @@ -25,6 +25,24 @@ def RunCommand(cmd): except subprocess.CalledProcessError as e: return e +# RunCommandExtractHashedFiles returns a tuple: (raised_exception, hashed_files) +# It runs the given command. If it fails it will return an exception and None. +# If it succeeds it will return None and the list of processed files extracted +# from the output of the command. It expects lines in this format: +# MD5:<path_to_image_file>:<md5_hash_in_hex> +# The returned hashed_files is a list of (file_path, MD5-hash) pairs. +def RunCommandExtractHashedFiles(cmd): + try: + output = subprocess.check_output(cmd, universal_newlines=True) + ret = [] + for line in output.split('\n'): + line = line.strip() + if line.startswith("MD5:"): + ret.append([x.strip() for x in line.lstrip("MD5:").rsplit(":", 1)]) + return None, ret + except subprocess.CalledProcessError as e: + return e, None + # Adjust Dr. Memory wrapper to have separate log directory for each test # for better error reporting. def DrMemoryWrapper(wrapper, pdf_name): |