From a02f941cecd6f4d1d662d7efe8fbd52cc46e216f Mon Sep 17 00:00:00 2001 From: Sebastian Bachmann Date: Wed, 23 Oct 2019 09:48:37 +0200 Subject: [PATCH] other way of testing scripts --- .travis.yml | 11 ----------- tests/test_entry_points.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4c7fd67..87361991 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,17 +21,6 @@ install: # command to run tests script: - nosetests --with-coverage --with-timer --timer-top-n 50 --logging-level CRITICAL - # FIXME Testing the scripts - crude ;) there should be a better way... - - for f in $(find ./ -! -path \*signing\* -name \*.apk); do - echo "testing $f"; - androsign "$f" > /dev/null || true; - androaxml -i "$f" > /dev/null || true; - androaxml -i "$f" -o /dev/null || true; - androarsc -i "$f" > /dev/null || true; - androarsc -i "$f" -o /dev/null || true; - androarsc -i "$f" -t string> /dev/null || true; - androarsc -i "$f" -t string -o /dev/null || true; - done - python setup.py build_sphinx after_success: diff --git a/tests/test_entry_points.py b/tests/test_entry_points.py index 4fe736d1..fa565707 100644 --- a/tests/test_entry_points.py +++ b/tests/test_entry_points.py @@ -13,6 +13,13 @@ from click.testing import CliRunner # internal modules from androguard.cli import entry_points +def get_test_apks(): + """Get a list of APKs for testing scripts""" + for root, _, files in os.walk(resource_filename('androguard', '..')): + for f in files: + if f.endswith('.apk') and 'signing' not in root: + yield os.path.join(root, f) + class EntryPointsTest(unittest.TestCase): def test_entry_point_help(self): @@ -266,3 +273,30 @@ class EntryPointsTest(unittest.TestCase): ['analyze', '--help']) assert result.exit_code == 0 + def test_androsign(self): + runner = CliRunner() + for apk in get_test_apks(): + print("testing for {}".format(apk)) + arguments = ['sign', apk] + result = runner.invoke(entry_points.entry_point, arguments) + assert result.exit_code == 0 + + def test_androaxml(self): + runner = CliRunner() + for apk in get_test_apks(): + print("testing for {}".format(apk)) + arguments = ['axml', apk] + result = runner.invoke(entry_points.entry_point, arguments) + assert result.exit_code == 0 + + def test_androarsc(self): + runner = CliRunner() + for apk in get_test_apks(): + print("testing for {}".format(apk)) + arguments = ['arsc', apk] + result = runner.invoke(entry_points.entry_point, arguments) + assert result.exit_code == 0 + + arguments = ['arsc', "-t", "string", apk] + result = runner.invoke(entry_points.entry_point, arguments) + assert result.exit_code == 0