diff options
author | Bert Vermeulen <bert@biot.com> | 2013-12-12 13:29:37 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2013-12-12 13:29:37 +0100 |
commit | d7d693b51692aa7aae90f3ca8caf5a8e9c581ed9 (patch) | |
tree | d7503d59a1d99fc6f74b420c7f3b70abd137776e /tests/pdtest | |
parent | 98457aa731ec0e7fe5a1be9f83181354253dc566 (diff) | |
download | libsigrokdecode-d7d693b51692aa7aae90f3ca8caf5a8e9c581ed9.tar.gz libsigrokdecode-d7d693b51692aa7aae90f3ca8caf5a8e9c581ed9.zip |
pdtest/runtc: Add support for binary output types.
Diffstat (limited to 'tests/pdtest')
-rwxr-xr-x | tests/pdtest | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/pdtest b/tests/pdtest index 608cd8a..2a90f2c 100755 --- a/tests/pdtest +++ b/tests/pdtest @@ -6,6 +6,8 @@ from getopt import getopt from tempfile import mkstemp from subprocess import Popen, PIPE from difflib import Differ +from hashlib import md5 +from shutil import copy DEBUG = 0 VERBOSE = False @@ -203,7 +205,7 @@ def get_tests(testnames): return tests -def diff_files(f1, f2): +def diff_textfiles(f1, f2): t1 = open(f1).readlines() t2 = open(f2).readlines() diff = [] @@ -215,6 +217,19 @@ def diff_files(f1, f2): return diff +def compare_binfiles(f1, f2): + h1 = md5() + h1.update(open(f1, 'rb').read()) + h2 = md5() + h2.update(open(f2, 'rb').read()) + if h1.digest() == h2.digest(): + result = None + else: + result = ["Binary output does not match."] + + return result + + def run_tests(tests, fix=False): errors = 0 results = [] @@ -265,6 +280,8 @@ def run_tests(tests, fix=False): diff = diff_error = None if op['type'] == 'annotation': diff = diff_textfiles(match, outfile) + elif op['type'] == 'binary': + diff = compare_binfiles(match, outfile) else: diff = ["Unsupported output type '%s'." % op['type']] except Exception as e: |