summaryrefslogtreecommitdiffstats
path: root/debug/risc-v-gsp-rm-vm/tests/test_bridge.py
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-02 11:44:31 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-02 11:44:31 -0400
commit1c99bfbeffff04529f6f669601fdf835a73778da (patch)
tree5867bab46e5848541df36c703f6fd8d6d0256e54 /debug/risc-v-gsp-rm-vm/tests/test_bridge.py
parent2fd653044127a665e4677a2cdfb58120d7b3e16b (diff)
downloadopen-iov-1c99bfbeffff04529f6f669601fdf835a73778da.tar.gz
open-iov-1c99bfbeffff04529f6f669601fdf835a73778da.zip
rename (cosmetic): green-eye -> risc-v-gsp-rm-debugger in user-facing names, docs, CLI, launcher and CI workflow; internal greeneye package/module identifiers unchanged (includes in-flight greeneye module edits present in the tree)
Diffstat (limited to 'debug/risc-v-gsp-rm-vm/tests/test_bridge.py')
-rw-r--r--debug/risc-v-gsp-rm-vm/tests/test_bridge.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/debug/risc-v-gsp-rm-vm/tests/test_bridge.py b/debug/risc-v-gsp-rm-vm/tests/test_bridge.py
index 7eeb46c..966399a 100644
--- a/debug/risc-v-gsp-rm-vm/tests/test_bridge.py
+++ b/debug/risc-v-gsp-rm-vm/tests/test_bridge.py
@@ -5,6 +5,7 @@ import json
import os
import shutil
import socket
+import time
import unittest
import greeneye as ge
@@ -23,6 +24,36 @@ class GhidraCommandTests(unittest.TestCase):
self.assertIn("MarkGreenEyeHits.java /tmp/hits.tsv", cmd)
+class BridgeLifecycleTests(unittest.TestCase):
+ """No target needed: start/stop/close are transport-level."""
+
+ def test_refuses_non_loopback_bind(self):
+ bridge = GhidraBridge(object(), host="0.0.0.0", port=0)
+ with self.assertRaises(ValueError):
+ bridge.start()
+
+ def test_close_command_takes_down_the_listener(self):
+ bridge = GhidraBridge(object(), port=0)
+ port = bridge.start()
+ with socket.create_connection(("127.0.0.1", port), timeout=10) as sock:
+ stream = sock.makefile("rwb")
+ stream.write((json.dumps({"id": 1, "cmd": "close", "args": {}}) + "\n").encode())
+ stream.flush()
+ response = json.loads(stream.readline())
+ self.assertTrue(response["ok"])
+ self.assertTrue(response["close"])
+ deadline = time.monotonic() + 5.0
+ while True:
+ try:
+ with socket.create_connection(("127.0.0.1", port), timeout=0.5):
+ pass
+ except OSError:
+ break
+ if time.monotonic() > deadline:
+ self.fail("listener still accepting connections after <close>")
+ time.sleep(0.05)
+
+
def qemu_available() -> bool:
return bool(os.environ.get("GREENEYE_QEMU") or shutil.which("qemu-system-riscv64"))