Gold support in PDFium
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
diff --git a/testing/tools/common.py b/testing/tools/common.py
index 1e1d257..a0cc946 100755
--- a/testing/tools/common.py
+++ b/testing/tools/common.py
@@ -25,6 +25,24 @@
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):