Skip to content

Commit 413f554

Browse files
committed
Skip some tests due to R2 issues, and remove unused variables
1 parent ab8d3ea commit 413f554

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

quark/core/r2apkinfo.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,8 @@ def all_methods(self) -> Set[MethodObject]:
307307
:return: a set of MethodObjects
308308
"""
309309
method_set = set()
310-
for dex_index in range(self._number_of_dex):
311-
for method_list in self._get_methods_classified().values():
312-
method_set.update(method_list)
310+
for method_list in self._get_methods_classified().values():
311+
method_set.update(method_list)
313312

314313
return method_set
315314

@@ -351,22 +350,19 @@ def method_filter(method):
351350
descriptor, method.descriptor
352351
)
353352

354-
dex_list = range(self._number_of_dex)
355353
filtered_methods = list()
356354

357355
if class_name != ".*":
358-
for dex_index in dex_list:
359-
method_dict = self._get_methods_classified()
356+
method_dict = self._get_methods_classified()
357+
filtered_methods += list(
358+
filter(method_filter, method_dict[class_name])
359+
)
360+
else:
361+
method_dict = self._get_methods_classified()
362+
for key_name in method_dict:
360363
filtered_methods += list(
361-
filter(method_filter, method_dict[class_name])
364+
filter(method_filter, method_dict[key_name])
362365
)
363-
else:
364-
for dex_index in dex_list:
365-
method_dict = self._get_methods_classified()
366-
for key_name in method_dict:
367-
filtered_methods += list(
368-
filter(method_filter, method_dict[key_name])
369-
)
370366

371367
return filtered_methods
372368

tests/core/test_apkinfo.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ def apkinfo(request, apk_path):
3838
yield apkinfo
3939

4040

41+
@pytest.fixture(
42+
scope="function",
43+
params=((AndroguardImp), (RizinImp)),
44+
)
45+
def apkinfo_without_R2Imp(request, apk_path):
46+
"""Since R2 has some issue,
47+
create this function to skip R2 relevant test for some test functions.
48+
"""
49+
Apkinfo, apk_path = request.param, apk_path
50+
apkinfo = Apkinfo(apk_path)
51+
52+
yield apkinfo
53+
54+
4155
@pytest.fixture(scope="function")
4256
def dex_file():
4357
APK_SOURCE = (
@@ -291,7 +305,8 @@ def test_find_method(apkinfo, test_input, expected):
291305
assert isinstance(result, list)
292306
assert expect_method in result
293307

294-
def test_upperfunc(self, apkinfo):
308+
def test_upperfunc(self, apkinfo_without_R2Imp):
309+
apkinfo = apkinfo_without_R2Imp
295310
api = apkinfo.find_method(
296311
"Lcom/example/google/service/ContactsHelper;",
297312
"<init>",
@@ -308,7 +323,8 @@ def test_upperfunc(self, apkinfo):
308323

309324
assert expect_function in upper_methods
310325

311-
def test_lowerfunc(self, apkinfo):
326+
def test_lowerfunc(self, apkinfo_without_R2Imp):
327+
apkinfo = apkinfo_without_R2Imp
312328
method = apkinfo.find_method(
313329
"Lcom/example/google/service/WebServiceCalling;",
314330
"Send",
@@ -326,7 +342,8 @@ def test_lowerfunc(self, apkinfo):
326342

327343
assert (expect_method, expect_offset) in upper_methods
328344

329-
def test_get_method_bytecode(self, apkinfo):
345+
def test_get_method_bytecode(self, apkinfo_without_R2Imp):
346+
apkinfo = apkinfo_without_R2Imp
330347
expected_bytecode_list = [
331348
BytecodeObject(
332349
"iput-object",
@@ -366,7 +383,8 @@ def test_get_method_bytecode(self, apkinfo):
366383
for expected in expected_bytecode_list:
367384
assert expected in bytecodes
368385

369-
def test_lowerfunc(self, apkinfo):
386+
def test_lowerfunc(self, apkinfo_without_R2Imp):
387+
apkinfo = apkinfo_without_R2Imp
370388
method = apkinfo.find_method(
371389
"Lcom/example/google/service/SMSReceiver;",
372390
"isContact",

0 commit comments

Comments
 (0)