]> sigrok.org Git - sigrok-test.git/commitdiff
pdtest: Exit non-zero for errors as well as PD output differences
authorGerhard Sittig <redacted>
Wed, 25 Jan 2017 19:57:39 +0000 (20:57 +0100)
committerGerhard Sittig <redacted>
Wed, 25 Jan 2017 21:06:38 +0000 (22:06 +0100)
Make the pdtest(1) executable return a non-zero exit code for errors
during test execution (as before) as well as for differences in the
decoder output (that's the change). Return either the number of errors
seen, or the number of tests which saw different output. Only return
zero in the absence of errors and differences.

decoder/pdtest

index 897e3ef4f2d200e2c91f7ee0639db147fda58cf3..591ad1d5106a6b86544042816dfa99c9791749ed 100755 (executable)
@@ -436,6 +436,17 @@ def run_tests(tests, fix=False):
 
     return results, errors
 
+def get_run_tests_error_diff_counts(results):
+    """Get error and diff counters from run_tests() results."""
+    errs = 0
+    diffs = 0
+    for result in results:
+        if 'error' in result:
+            errs += 1
+        if 'diff' in result:
+            diffs += 1
+    return errs, diffs
+
 
 def gen_report(result):
     out = []
@@ -560,7 +571,8 @@ try:
             ERR("Could not find sigrok-dumps repository at %s" % dumps_dir)
             sys.exit(1)
         results, errors = run_tests(testlist, fix=opt_fix)
-        ret = errors
+        errs, diffs = get_run_tests_error_diff_counts(results)
+        ret = errs or diffs or 0
     elif opt_show:
         show_tests(testlist)
     elif opt_list: