From 55cd7d51b20df763c93664005730b044f54753dd Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 28 May 2026 13:15:18 +0200 Subject: [PATCH 1/6] bisect_hang.py: print timing information for each file --- tools/bisect/bisect_hang.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/bisect/bisect_hang.py b/tools/bisect/bisect_hang.py index ad0497396c9..b07991066e6 100644 --- a/tools/bisect/bisect_hang.py +++ b/tools/bisect/bisect_hang.py @@ -12,9 +12,9 @@ def run(cppcheck_path, options, elapsed_time=None): cmd = options.split() cmd.insert(0, cppcheck_path) print('running {}'.format(cppcheck_path)) - with subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) as p: + with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) as p: try: - p.communicate(timeout=timeout) + stdout, _ = p.communicate(timeout=timeout) if p.returncode != 0: print('error') return None @@ -22,8 +22,11 @@ def run(cppcheck_path, options, elapsed_time=None): except subprocess.TimeoutExpired: print('timeout') p.kill() - p.communicate() + stdout, _ = p.communicate() return False + finally: + stdout = stdout.decode(encoding='utf-8', errors='ignore').replace('\r\n', '\n') + print(stdout) return True @@ -33,6 +36,10 @@ def run(cppcheck_path, options, elapsed_time=None): options = sys.argv[2] if '--error-exitcode=0' not in options: options += ' --error-exitcode=0' +if '--showtime=file' not in options: + options += ' --showtime=file-total' +if '-q' not in options: + options += ' -q' if len(sys.argv) >= 4: elapsed_time = float(sys.argv[3]) else: From 57f87795f0583e85dd0e0574192a1221e5c36fd1 Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 28 May 2026 13:18:19 +0200 Subject: [PATCH 2/6] bisect_hang.py: print the timeout we are running with --- tools/bisect/bisect_hang.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bisect/bisect_hang.py b/tools/bisect/bisect_hang.py index b07991066e6..5a2783eab28 100644 --- a/tools/bisect/bisect_hang.py +++ b/tools/bisect/bisect_hang.py @@ -11,7 +11,7 @@ def run(cppcheck_path, options, elapsed_time=None): timeout = elapsed_time * 2 cmd = options.split() cmd.insert(0, cppcheck_path) - print('running {}'.format(cppcheck_path)) + print('running (timeout: {}) {}'.format(timeout, cppcheck_path)) with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) as p: try: stdout, _ = p.communicate(timeout=timeout) From 511bb2879ef00c680252c81cbbb88fae77b71388 Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 28 May 2026 13:20:11 +0200 Subject: [PATCH 3/6] bisect_hang.py: print the run time factor --- tools/bisect/bisect_hang.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/bisect/bisect_hang.py b/tools/bisect/bisect_hang.py index 5a2783eab28..0b7cb43e6c1 100644 --- a/tools/bisect/bisect_hang.py +++ b/tools/bisect/bisect_hang.py @@ -82,5 +82,7 @@ def run(cppcheck_path, options, elapsed_time=None): sys.exit(EC_BAD if not invert else EC_GOOD) # timeout occurred print('run_time: {}'.format(run_time)) +run_time_factor = run_time / elapsed_time +print('run_time_factor: {}'.format(run_time_factor)) sys.exit(EC_GOOD if not invert else EC_BAD) # no timeout From 542debb965156f79e3981eea8790d14fb96f385c Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 28 May 2026 13:24:10 +0200 Subject: [PATCH 4/6] bisect_hang.py: round down the elapsed time --- tools/bisect/bisect_hang.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bisect/bisect_hang.py b/tools/bisect/bisect_hang.py index 0b7cb43e6c1..4f9de9c05de 100644 --- a/tools/bisect/bisect_hang.py +++ b/tools/bisect/bisect_hang.py @@ -63,7 +63,7 @@ def run(cppcheck_path, options, elapsed_time=None): elapsed_time = time.perf_counter() - t print('elapsed_time: {}'.format(elapsed_time)) # TODO: write to stdout and redirect all all printing to stderr - sys.exit(round(elapsed_time + .5)) # return the time + sys.exit(max(round(elapsed_time - .5), 1)) # return the time t = time.perf_counter() run_res = run(cppcheck_path, options, elapsed_time) @@ -73,7 +73,7 @@ def run(cppcheck_path, options, elapsed_time=None): # TODO: handle error result print('elapsed_time: {}'.format(run_time)) # TODO: write to stdout and redirect all printing to stderr - sys.exit(round(run_time + .5)) # return the time + sys.exit(max(round(run_time - .5), 1)) # return the time if run_res is None: sys.exit(EC_SKIP) # error occurred From b88eb3019aa653e95855aa1c3797ce02f5b11b51 Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 28 May 2026 13:25:05 +0200 Subject: [PATCH 5/6] bisect_hang.py: introduced a maximum run time factor (default: 1.3) --- tools/bisect/bisect_hang.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/bisect/bisect_hang.py b/tools/bisect/bisect_hang.py index 4f9de9c05de..a9f7ca831c0 100644 --- a/tools/bisect/bisect_hang.py +++ b/tools/bisect/bisect_hang.py @@ -4,6 +4,8 @@ from bisect_common import * +MAX_RT_FACTOR = 1.3 + # TODO: detect missing file def run(cppcheck_path, options, elapsed_time=None): timeout = None @@ -85,4 +87,7 @@ def run(cppcheck_path, options, elapsed_time=None): run_time_factor = run_time / elapsed_time print('run_time_factor: {}'.format(run_time_factor)) +if run_time_factor >= MAX_RT_FACTOR: + sys.exit(EC_BAD if not invert else EC_GOOD) # factor exceeded + sys.exit(EC_GOOD if not invert else EC_BAD) # no timeout From 6074ec724f92a178433e1f91c03fcb892fc05ddc Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 28 May 2026 13:28:24 +0200 Subject: [PATCH 6/6] bisect_hang.py: print the difference in run time [skip ci] --- tools/bisect/bisect_hang.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/bisect/bisect_hang.py b/tools/bisect/bisect_hang.py index a9f7ca831c0..71e8d8313fc 100644 --- a/tools/bisect/bisect_hang.py +++ b/tools/bisect/bisect_hang.py @@ -86,6 +86,8 @@ def run(cppcheck_path, options, elapsed_time=None): print('run_time: {}'.format(run_time)) run_time_factor = run_time / elapsed_time print('run_time_factor: {}'.format(run_time_factor)) +run_time_diff = run_time - elapsed_time +print('run_time_diff: {}'.format(run_time_diff)) if run_time_factor >= MAX_RT_FACTOR: sys.exit(EC_BAD if not invert else EC_GOOD) # factor exceeded