other way of testing scripts

This commit is contained in:
Sebastian Bachmann 2019-10-23 09:48:37 +02:00
parent 9893331ef7
commit a02f941cec
2 changed files with 34 additions and 11 deletions

View File

@ -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:

View File

@ -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