mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 09:08:38 +00:00
buffer_bounds_probe: reject non-numeric waves as a bad argument
This commit is contained in:
@ -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],
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user