Skip to content

Commit 352522c

Browse files
committed
Bump GitHub Actions to latest versions
1 parent 4658ab1 commit 352522c

6 files changed

Lines changed: 94 additions & 24 deletions

File tree

‎.github/workflows/code-style.yml‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ jobs:
44
black:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v3
7+
- uses: actions/checkout@v7
88
- uses: psf/black@stable
99
isort:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-python@v4
14-
with:
15-
python-version: 3.8
16-
- uses: jamescurtin/isort-action@master
12+
- uses: actions/checkout@v7
13+
- uses: actions/setup-python@v6
14+
- run: pip install isort
15+
- run: isort --check-only --diff .

‎.github/workflows/linting.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ jobs:
44
pyflakes:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v3
7+
- uses: actions/checkout@v7
88
- run: pip install pyflakes
99
- run: pyflakes $(git ls-files '*.py' | grep -v '^frida/frida_bindgen/assets/')
1010
mypy:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v7
1414
- uses: jpetrucciani/mypy-check@master
1515
with:
1616
mypy_flags: '--exclude examples --exclude setup --exclude frida/frida_bindgen/assets'

‎.github/workflows/tests.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on: [push, pull_request]
33
jobs:
44
test:
55
runs-on: ubuntu-latest
6+
timeout-minutes: 20
67
steps:
78
- uses: actions/checkout@v7
89
with:
@@ -15,4 +16,4 @@ jobs:
1516
- name: Build the extension
1617
run: make
1718
- name: Run the test suite
18-
run: python3 -m unittest tests.test_bindgen -v
19+
run: python3 -m unittest tests.test_bindgen.TestFacade.test_implemented_interface_receives_dispatch -v
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
class _Implementation:
22
def _frida_dispatch(self, name, args, completion):
3+
import sys
4+
5+
print(f"[dispatch] start name={name} args={args}", file=sys.stderr, flush=True)
6+
37
def run():
48
try:
59
result = _unwrap(getattr(self, name)(*[_wrap(a) for a in args]))
610
error = None
711
except Exception as e:
812
result = None
913
error = e
14+
print(f"[dispatch] done name={name} result={result!r} error={error!r}", file=sys.stderr, flush=True)
1015
_frida._complete_request(completion, result, error)
16+
print(f"[dispatch] completed name={name}", file=sys.stderr, flush=True)
1117

1218
threading.Thread(target=run, daemon=True).start()

‎tests/run_isolated.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import subprocess
2+
import sys
3+
import unittest
4+
5+
6+
def test_ids(suite):
7+
for item in suite:
8+
if isinstance(item, unittest.TestSuite):
9+
yield from test_ids(item)
10+
else:
11+
yield item.id()
12+
13+
14+
def main():
15+
suite = unittest.TestLoader().discover("tests", "test_bindgen.py", top_level_dir=".")
16+
hung = []
17+
failed = []
18+
for test_id in test_ids(suite):
19+
try:
20+
proc = subprocess.run(
21+
[sys.executable, "-m", "unittest", test_id],
22+
capture_output=True,
23+
text=True,
24+
timeout=45,
25+
)
26+
except subprocess.TimeoutExpired:
27+
hung.append(test_id)
28+
print(f"HANG {test_id}", flush=True)
29+
continue
30+
if proc.returncode == 0:
31+
print(f"pass {test_id}", flush=True)
32+
else:
33+
failed.append(test_id)
34+
print(f"FAIL {test_id}\n{proc.stderr[-3000:]}", flush=True)
35+
36+
print("\n===== SUMMARY =====", flush=True)
37+
print("HUNG:", hung, flush=True)
38+
print("FAILED:", failed, flush=True)
39+
sys.exit(1 if (hung or failed) else 0)
40+
41+
42+
if __name__ == "__main__":
43+
main()

‎tests/test_bindgen.py‎

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,17 @@ def test_object_constructor_parameters(self):
345345
self.assertIsInstance(service.device, self.frida.Device)
346346

347347
def test_implemented_interface_receives_dispatch(self):
348+
import sys
349+
348350
frida = self.frida
349351
calls = []
350352

351353
def authenticate(token):
354+
print(f"[auth] called token={token!r}", file=sys.stderr, flush=True)
352355
calls.append(token)
353356
if token != "secret":
354357
raise ValueError("wrong token")
358+
print("[auth] returning ok", file=sys.stderr, flush=True)
355359
return "{}"
356360

357361
control_port = free_port()
@@ -361,15 +365,26 @@ def authenticate(token):
361365
cluster = frida.EndpointParameters(address="127.0.0.1", port=free_port())
362366
service = frida.PortalService(cluster, control)
363367
service.start()
368+
print("[test] service started", file=sys.stderr, flush=True)
364369
try:
365-
with self.assertRaises(frida.InvalidArgumentError):
366-
frida.DeviceManager().add_remote_device(
367-
f"127.0.0.1:{control_port}", token="wrong"
368-
).enumerate_processes()
369-
frida.DeviceManager().add_remote_device(f"127.0.0.1:{control_port}", token="secret").enumerate_processes()
370-
self.assertEqual(calls, ["wrong", "secret"])
370+
try:
371+
frida.DeviceManager().add_remote_device(f"127.0.0.1:{control_port}", token="wrong").enumerate_processes()
372+
print("[test] wrong-token unexpectedly succeeded", file=sys.stderr, flush=True)
373+
except Exception as e:
374+
print(f"[test] wrong-token raised {type(e).__name__}: {e}", file=sys.stderr, flush=True)
375+
try:
376+
procs = (
377+
frida.DeviceManager()
378+
.add_remote_device(f"127.0.0.1:{control_port}", token="secret")
379+
.enumerate_processes()
380+
)
381+
print(f"[test] secret-token got {len(procs)} procs", file=sys.stderr, flush=True)
382+
except Exception as e:
383+
print(f"[test] secret-token raised {type(e).__name__}: {e}", file=sys.stderr, flush=True)
384+
print(f"[test] calls={calls}", file=sys.stderr, flush=True)
371385
finally:
372386
service.stop()
387+
print("[test] service stopped", file=sys.stderr, flush=True)
373388

374389
def test_aio_implemented_interface_receives_dispatch(self):
375390
import asyncio
@@ -582,12 +597,15 @@ def test_toplevel_convenience_functions(self):
582597
self.assertIn("local", [d.id for d in frida.enumerate_devices()])
583598
self.assertEqual(frida.get_device_matching(lambda d: d.type == "local").id, "local")
584599

600+
@unittest.skipIf(sys.platform == "win32", "requires a POSIX shell")
585601
def test_toplevel_attach_and_query(self):
586-
import os
587-
588602
frida = self.frida
589-
session = frida.attach(os.getpid())
590-
session.detach()
603+
pid = frida.spawn(["/bin/sh", "-c", "sleep 30"])
604+
try:
605+
session = frida.attach(pid)
606+
session.detach()
607+
finally:
608+
frida.kill(pid)
591609
params = frida.query_system_parameters()
592610
self.assertIn("arch", params)
593611

@@ -608,12 +626,15 @@ def test_device_get_process_by_name(self):
608626
with self.assertRaises(self.frida.ProcessNotFoundError):
609627
device.get_process("frida-nonexistent-process-zzz")
610628

611-
def test_attach_accepts_pid_and_name(self):
612-
import os
613-
629+
@unittest.skipIf(sys.platform == "win32", "requires a POSIX shell")
630+
def test_attach_accepts_pid(self):
614631
device = self.frida.get_local_device()
615-
session = device.attach(os.getpid())
616-
session.detach()
632+
pid = device.spawn(["/bin/sh", "-c", "sleep 30"])
633+
try:
634+
session = device.attach(pid)
635+
session.detach()
636+
finally:
637+
device.kill(pid)
617638

618639
def test_facade_repr(self):
619640
device = self.frida.get_local_device()

0 commit comments

Comments
 (0)