From: Gerhard Sittig Date: Wed, 25 Jan 2017 19:57:39 +0000 (+0100) Subject: pdtest: Exit non-zero for errors as well as PD output differences X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a1c10c43350cfbed4ac09d75b07158aac0944c46;p=sigrok-test.git pdtest: Exit non-zero for errors as well as PD output differences 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. --- diff --git a/decoder/pdtest b/decoder/pdtest index 897e3ef..591ad1d 100755 --- a/decoder/pdtest +++ b/decoder/pdtest @@ -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: