crosslane_fuzz: refuse wave/mode combinations that run nothing

`--wave 32 --modes emulate` and `--wave 64 --modes native` (without
`--w64-native`) each select no program that mode could run, so nothing ran,
`summary:` printed with no line under it, and the exit code was 0. That is the
same false pass #1452 fixed for a count below 1, reached through a flag
combination, so both become usage errors before anything is generated or the
harness is looked for.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
bobcatchris
2026-11-22 06:29:23 -06:00
parent 99f99890c5
commit 8a6820e5dc
2 changed files with 47 additions and 0 deletions

View File

@ -192,6 +192,44 @@ class Modes(unittest.TestCase):
self.assertEqual(r.returncode, 2, r.stdout + r.stderr)
self.assertIn("unknown mode 'emulat'", r.stderr)
def test_emulate_with_wave32_is_a_usage_error(self):
# emulate runs a wave64 program as two 32-lane halves, so --wave 32 selects nothing to run: it used to print
# a bare `summary:` and exit 0. The refusal comes before the missing-harness check, so no build is needed.
r = subprocess.run([sys.executable, "-I", TOOL, "--wave", "32", "--modes", "emulate", "--programs", "1",
"--exe", os.path.join(TOOLS, "no-such-build", "vk_compute_test")],
capture_output=True, text=True)
self.assertEqual(r.returncode, 2, r.stdout + r.stderr)
self.assertIn("--modes emulate needs wave64 programs", r.stderr)
self.assertNotIn("vk_compute_test not found", r.stderr)
self.assertEqual(r.stdout, "")
def test_wave64_native_without_w64_native_is_a_usage_error(self):
# A wave64 program runs natively only when --w64-native asks for the cross-half approximation; without it the
# selection was empty and the run ended after a bare `summary:` with exit 0.
r = subprocess.run([sys.executable, "-I", TOOL, "--wave", "64", "--modes", "native", "--programs", "1",
"--exe", os.path.join(TOOLS, "no-such-build", "vk_compute_test")],
capture_output=True, text=True)
self.assertEqual(r.returncode, 2, r.stdout + r.stderr)
self.assertIn("--w64-native", r.stderr)
self.assertNotIn("vk_compute_test not found", r.stderr)
self.assertEqual(r.stdout, "")
def test_wave64_native_with_w64_native_reaches_the_harness_check(self):
# Not a usage error any more: the run gets as far as looking for vk_compute_test.
r = subprocess.run([sys.executable, "-I", TOOL, "--wave", "64", "--modes", "native", "--programs", "1",
"--w64-native", "--exe", os.path.join(TOOLS, "no-such-build", "vk_compute_test")],
capture_output=True, text=True)
self.assertEqual(r.returncode, 1, r.stdout + r.stderr)
self.assertIn("vk_compute_test not found", r.stderr)
def test_wave64_and_both_still_accept_emulate(self):
for wave in ("64", "both"):
with self.subTest(wave=wave):
r = subprocess.run([sys.executable, "-I", TOOL, "--wave", wave, "--modes", "emulate", "--self-test"],
capture_output=True, text=True)
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
self.assertIn("self-test OK", r.stdout)
class Counts(unittest.TestCase):
"""--programs and --ops cannot be below 1: a run of no programs ended in a bare `summary:` with no lines and exit

View File

@ -941,6 +941,15 @@ def main():
backends = tuple(dict.fromkeys(t.strip() for t in args.oracle.split(",")))
if not backends or any(t not in ("translator", "hw") for t in backends):
ap.error("--oracle takes translator, hw or translator,hw")
if args.wave == "32" and "emulate" in args.modes:
# emulate runs a wave64 program as two 32-lane halves, so a wave32-only selection has nothing to run: the run
# used to end after a bare `summary:` with exit 0, the same false pass #1452 fixed for a count below 1.
ap.error("--modes emulate needs wave64 programs: with --wave 32 nothing runs (use --wave 64 or both)")
if args.wave == "64" and "native" in args.modes and not args.w64_native:
# A wave64 program only runs natively when --w64-native asks for the documented cross-half approximation, so
# this combination was empty in the same silent way.
ap.error("--wave 64 --modes native runs nothing without --w64-native; pass it to run the documented "
"cross-half approximation, or use --modes emulate")
if "translator" in backends and not os.path.isfile(args.exe): # before any program is generated or run
sys.exit(f"vk_compute_test not found at {args.exe} or in its RelWithDebInfo/Release folder; build it first "
"(cmake --build <build dir> --target vk_compute_test) or give its path with --exe")