upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/test_script_qtable.py
diff options
context:
space:
mode:
authorevilclanker9000 <45567075+evilclanker9000@users.noreply.github.com>2026-11-23 15:24:41 +0100
committerGitHub <noreply@github.com>2026-11-23 08:24:41 -0600
commit4a1fa33b47ff34cba3cd09fd19dc69b718ba6b16 (patch)
tree0162a2eec1eb702d3a6f7fd8ed129b56a99d0d8d /tests/test_script_qtable.py
parent27a80ca819e1c794410634cc8f8a646ab6642520 (diff)
script_qtable: a missing or unreadable input is one ERROR line and exit 2 (EGEN-SCRIPTQTABLE-MISSING-INPUT, DeepSeek2) (#6232)
Squash-merged after diff review of PR #6232 - script_qtable: a missing or unreadable input is one ERROR line and exit 2 (EGEN-SCRIPTQTABLE-MISSING-INPUT, DeepSeek2)
Diffstat (limited to 'tests/test_script_qtable.py')
-rw-r--r--tests/test_script_qtable.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/test_script_qtable.py b/tests/test_script_qtable.py
index 1837be0d1..a9176d889 100644
--- a/tests/test_script_qtable.py
+++ b/tests/test_script_qtable.py
@@ -185,7 +185,40 @@ class ScriptQtableTests(unittest.TestCase):
185 self.assertEqual(p3.returncode, 2) 185 self.assertEqual(p3.returncode, 2)
186 self.assertIn("invalid hex", p3.stderr) 186 self.assertIn("invalid hex", p3.stderr)
187 187
188 def test_exact_64k_qtable_does_not_absorb_trailing_opaque_row(self): 188 def test_missing_input_is_one_error_line_and_exit_2(self):
189 # A target the tool cannot open is a diagnostic, not a short census: the other tools exit 2 here.
190 with tempfile.TemporaryDirectory() as tmp:
191 missing = os.path.join(tmp, "no_such_container.bin")
192 p = subprocess.run(
193 [sys.executable, "-I", TOOL, missing],
194 capture_output=True, text=True, encoding="utf-8", errors="replace",
195 )
196 self.assertEqual(p.returncode, 2, p.stdout + p.stderr)
197 lines = [line for line in p.stderr.splitlines() if line.strip()]
198 self.assertEqual(len(lines), 1, p.stderr)
199 self.assertEqual(lines[0], f"ERROR: {missing}: does not exist")
200 self.assertEqual(p.stdout, "")
201
202 def test_json_it_cannot_write_is_one_error_line_and_exit_2(self):
203 # The scan succeeds and then the report cannot be written; that is not a payload verdict (exit 1).
204 with tempfile.TemporaryDirectory() as tmp:
205 bin_path = os.path.join(tmp, "qtable.bin")
206 with open(bin_path, "wb") as f:
207 f.write(build_synthetic_qtable())
208 blocker = os.path.join(tmp, "blocker")
209 with open(blocker, "wb") as f:
210 f.write(b"")
211 p = subprocess.run(
212 [sys.executable, "-I", TOOL, bin_path, "--json", os.path.join(blocker, "out.json")],
213 capture_output=True, text=True, encoding="utf-8", errors="replace",
214 )
215 self.assertEqual(p.returncode, 2, p.stdout + p.stderr)
216 lines = [line for line in p.stderr.splitlines() if line.strip()]
217 self.assertEqual(len(lines), 1, p.stderr)
218 self.assertTrue(lines[0].startswith("ERROR: cannot write "), lines[0])
219 self.assertFalse(os.path.exists(os.path.join(blocker, "out.json")))
220
221
189 exact = build_synthetic_qtable(pad_to_bytes=65536) 222 exact = build_synthetic_qtable(pad_to_bytes=65536)
190 self.assertEqual(len(exact), 65536) 223 self.assertEqual(len(exact), 65536)
191 opaque = b"\x01\x02\x03\x04" * 4 224 opaque = b"\x01\x02\x03\x04" * 4