diff options
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): |