Verify VAD allocation limits and decoder overshoot contracts
This commit is contained in:
1 parent
7a6ab9fc6a
commit
f827df11c6
2 files changed
+32
No files matched your search
@@ -48,6 +48,32 @@ class NativeContract(unittest.TestCase):
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertEqual(result.stdout, b"")
|
||||
|
||||
def test_missing_model_is_failure_without_report(self):
|
||||
with tempfile.TemporaryDirectory(prefix="searchi-vad-missing-") as scratch:
|
||||
pcm = Path(scratch) / "silence.f32"
|
||||
pcm.write_bytes(b"\0" * 64000)
|
||||
result = subprocess.run([str(self.worker), str(Path(scratch) / "missing.bin"), str(pcm)],
|
||||
capture_output=True, timeout=5)
|
||||
self.assertEqual(result.returncode, 3)
|
||||
self.assertEqual(result.stdout, b"")
|
||||
|
||||
def test_oversized_pcm_rejected_before_model_loading(self):
|
||||
with tempfile.TemporaryDirectory(prefix="searchi-vad-large-") as scratch:
|
||||
pcm = Path(scratch) / "oversized.f32"
|
||||
with pcm.open("wb") as stream:
|
||||
stream.truncate(16000 * 600 * 4 + 4)
|
||||
result = subprocess.run([str(self.worker), "missing.bin", str(pcm)],
|
||||
capture_output=True, timeout=5)
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertEqual(result.stdout, b"")
|
||||
|
||||
def test_finite_decoder_overshoot_is_preserved(self):
|
||||
# A DC input is not speech evidence. This checks only the input contract:
|
||||
# valid floating-point decoder output must not be clipped or rejected.
|
||||
result = self.run_pcm(struct.pack("<f", 1.01) * 16000)
|
||||
self.assertEqual(result.returncode, 0, result.stderr.decode("utf-8", errors="replace"))
|
||||
self.assertEqual(json.loads(result.stdout)["samples"], 16000)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user