X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-test.git;a=blobdiff_plain;f=decoder%2Fpdtest;h=58b6eee19244353226938a35cf1c7cc27d24328e;hp=25dfd83cb4a8bb85724b3b44cc92c4dd0f13c2da;hb=1a5417590cebb5f168079993778b608a131088a3;hpb=cf646afd93e5752fb2f662c7c13df11dd8ab9d73 diff --git a/decoder/pdtest b/decoder/pdtest index 25dfd83..58b6eee 100755 --- a/decoder/pdtest +++ b/decoder/pdtest @@ -55,17 +55,17 @@ def ERR(msg): def usage(msg=None): if msg: print(msg.strip() + '\n') - print("""Usage: testpd [-dvarslR] [test, ...] + print("""Usage: testpd [-dvalsrfcR] [ ...] -d Turn on debugging -v Verbose -a All tests - -l List all tests + -l List test(s) -s Show test(s) -r Run test(s) -f Fix failed test(s) -c Report decoder code coverage -R Save test reports to - Protocol decoder name ("i2c") and optionally test name ("i2c/icc")""") + Protocol decoder name ("i2c") and optionally test name ("i2c/rtc")""") sys.exit() @@ -327,7 +327,7 @@ def run_tests(tests, fix=False): opargs[-1] += ":%s" % op['class'] name += "/%s" % op['class'] if VERBOSE: - dots = '.' * (60 - len(name) - 2) + dots = '.' * (77 - len(name) - 2) INFO("%s %s " % (name, dots), end='') results.append({ 'testcase': name, @@ -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,12 @@ 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 + ret = 0 + errs, diffs = get_run_tests_error_diff_counts(results) + if errs: + ret = 1 + elif diffs: + ret = 2 elif opt_show: show_tests(testlist) elif opt_list: