aboutsummaryrefslogtreecommitdiffstats
path: root/tests/rpc_smoke.py
diff options
context:
space:
mode:
authorblasty <blasty@local>2026-07-10 15:14:49 +0200
committerblasty <blasty@local>2026-07-10 15:14:49 +0200
commit85c717ac6aa7e6a2559c1ffb8e4e4f344419a667 (patch)
treeb9201affa090401627923a181be6a87c07417a5e /tests/rpc_smoke.py
parentrpc: unix-socket puppeteering server (raw keys + introspection + screen) (diff)
downloadida-tui-85c717ac6aa7e6a2559c1ffb8e4e4f344419a667.tar.gz
ida-tui-85c717ac6aa7e6a2559c1ffb8e4e4f344419a667.tar.xz
ida-tui-85c717ac6aa7e6a2559c1ffb8e4e4f344419a667.zip
rpc: semantic verbs (typed-with-delay ops + fast movement)
Layer high-level verbs over the raw injection: goto/open, rename, comment, retype, follow, back, toggle_view, hex, xrefs, symbols, structs, close, plus fast move/cursor. Editing/goto verbs type through the real prompts with a per-char delay (default 35ms) so viewers see it typed; movement uses bare keypresses with a pump-only settle to stay snappy. Each verb settles on an op-specific predicate where one exists (goto lands on the target, follow grows the nav stack, toggle flips _active, modals open), so the returned state is never stale. rpc_smoke now drives the semantic path end-to-end (rename round-trip via the prompt-fill seam), 11 green.
Diffstat (limited to 'tests/rpc_smoke.py')
-rw-r--r--tests/rpc_smoke.py45
1 files changed, 43 insertions, 2 deletions
diff --git a/tests/rpc_smoke.py b/tests/rpc_smoke.py
index 92fc801..d456552 100644
--- a/tests/rpc_smoke.py
+++ b/tests/rpc_smoke.py
@@ -64,10 +64,14 @@ async def run(db):
resp = await c.call("ping")
check("ping returns proto", resp.get("result", {}).get("proto") == 1, str(resp))
- resp = await c.call("functions", limit=5)
+ resp = await c.call("functions", limit=400)
funcs = resp.get("result", [])
check("functions lists entries", isinstance(funcs, list) and len(funcs) > 0,
str(resp)[:120])
+ # a normally-named function (its name appears verbatim in its own decomp,
+ # unlike e.g. '.init_proc' which IDA renders as 'init_proc')
+ target = next((f for f in funcs if f["name"] == "main"),
+ next((f for f in funcs if f["name"].startswith("sub_")), funcs[0]))
resp = await c.call("state")
st = resp.get("result", {})
@@ -75,7 +79,6 @@ async def run(db):
str(st)[:120])
# drive it like a user: goto a function by name via raw keys
- target = next((f for f in funcs if f["name"] == "main"), funcs[0])
keys = ["g"] + list(target["name"]) + ["enter"]
resp = await c.call("keys", keys=keys)
st = resp.get("result", {})
@@ -103,6 +106,44 @@ async def run(db):
check("text primitive types into the focused input", val == "sub_", f"val={val!r}")
await c.call("keys", keys=["escape"])
+ # --- semantic verbs ------------------------------------------------ #
+ resp = await c.call("goto", target=target["name"], delay_ms=0)
+ check("semantic goto lands on the function",
+ resp.get("result", {}).get("function", {}).get("name") == target["name"],
+ str(resp.get("result", {}).get("function")))
+
+ before = app._active
+ resp = await c.call("toggle_view")
+ check("toggle_view flips the active pane",
+ resp.get("result", {}).get("active") != before, f"still {before}")
+ await c.call("toggle_view") # flip back to a known state
+
+ # fast movement: cursor should advance a few lines
+ line0 = (await c.call("state"))["result"]["cursor"].get("line")
+ resp = await c.call("move", dir="down", n=4)
+ line1 = resp["result"]["cursor"].get("line")
+ check("move(down,4) advances the cursor",
+ isinstance(line0, int) and isinstance(line1, int) and line1 > line0,
+ f"{line0} -> {line1}")
+
+ # rename round-trip through the prompt-fill path (place cursor on the
+ # function's own name via view(), rename, verify, revert via the API)
+ v = (await c.call("view", lines=1))["result"]
+ line0_text = v["lines"][0]["text"] if v.get("lines") else ""
+ col = line0_text.find(target["name"])
+ if col >= 0:
+ await c.call("cursor", line=0, col=col + 1)
+ newname = f"rpc_{os.getpid()}"
+ await c.call("rename", name=newname, delay_ms=0)
+ got = app._func_index.by_addr(target["ea"])
+ check("semantic rename updates the function name",
+ got is not None and got.name == newname,
+ got.name if got else None)
+ app.program.client.call(
+ "rename", batch={"func": {"addr": hex(target["ea"]), "name": target["name"]}})
+ else:
+ check("found the function name to rename", False, repr(line0_text[:60]))
+
w.close()
print(f"\n{PASS} passed, {FAIL} failed")
return 1 if FAIL else 0