Skip to content

Commit 8ca0f0d

Browse files
sam-f0sam-f0
authored andcommitted
unittesting
1 parent 38d6744 commit 8ca0f0d

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

binder_trace/binder_trace/generator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Any
99

1010
import frida
11+
from frida import ProcessNotFoundError
1112

1213
from binder_trace import loggers, parsing
1314
from binder_trace.parsedParcel import Block
@@ -60,7 +61,7 @@ def start(self):
6061
# so first try to attach, and if it fails and spawn option supplied, spawn it.
6162
try:
6263
self.session = self.device.attach(self.process_identifier)
63-
except frida.ProcessNotFoundError:
64+
except ProcessNotFoundError:
6465
if self.spawn_process:
6566
self.device.spawn([self.process_identifier])
6667
self.start()

binder_trace/binder_trace/tests/test_arg_parse.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ def test_mutually_exclusive(self):
4040
def pid_and_name():
4141
self.argparser.parse_args(["--pid", "12", "--name", "helloworld", "-a", "13"])
4242

43-
def android_version_and_struct_path():
44-
self.argparser.parse_args(["--name", "com.android.settings", "-a", "13", "--structpath", "../structs/a13"])
45-
4643
self.assertRaises(SystemExit, pid_and_name)
47-
self.assertRaises(SystemExit, android_version_and_struct_path)
4844

4945
def test_missing_key_args(self):
5046
def pid_and_name():

binder_trace/binder_trace/tests/test_generator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest.mock import create_autospec, patch
33

44
import frida
5+
from frida import ProcessNotFoundError
56

67
from binder_trace.generator import FridaInjector
78

@@ -14,6 +15,7 @@ def mock_get_device(self, id: str):
1415
def test_spawn_flag(self, mock_frida):
1516
mock_frida.get_device.side_effect = self.mock_get_device
1617
injector = FridaInjector("com.android.settings", "../structs/android10", 10, "emulator-5554", True)
18+
injector.device.attach.side_effect = [ProcessNotFoundError(""), create_autospec(frida.core.Session)]
1719
injector.start()
1820
injector.stop()
1921
try:

0 commit comments

Comments
 (0)