buffer_bounds_probe: reject non-numeric waves as a bad argument

This commit is contained in:
whoalin1
2026-11-26 07:41:09 +02:00
committed by Man Alin
parent ef32995848
commit ccb3726df8
2 changed files with 11 additions and 1 deletions

View File

@ -29,6 +29,13 @@ class BufferBoundsProbeTests(unittest.TestCase):
capture_output=True, text=True, check=False)
self.assertEqual(proc.returncode, 2, proc.stderr or proc.stdout)
def test_waves_that_are_not_numbers(self):
proc = subprocess.run([sys.executable, "-I", PROBE, "--waves", "32,abc"],
capture_output=True, text=True, check=False)
self.assertEqual(proc.returncode, 2, proc.stderr or proc.stdout)
self.assertIn("--waves must be a non-empty list", proc.stderr)
self.assertNotIn("Traceback", proc.stderr)
def test_json_folder_is_refused_before_the_gpu_run(self):
with tempfile.TemporaryDirectory() as folder:
proc = subprocess.run([sys.executable, "-I", PROBE, "--json", folder],

View File

@ -199,7 +199,10 @@ def main():
if args.self_test:
self_test()
return 0
waves = [int(w) for w in args.waves.split(",") if w.strip()]
try:
waves = [int(w) for w in args.waves.split(",") if w.strip()]
except ValueError: # a non-number is a bad argument (exit 2), not a traceback
waves = []
if not waves or any(w not in (32, 64) for w in waves):
print("--waves must be a non-empty list of 32 and/or 64", file=sys.stderr)
return 2