Merge branch 'skip-test-for-unsupported-arch' into 'master'

Draft: skip tests that won't run on a given CPU architecture

See merge request fdroid/fdroidserver!1330
This commit is contained in:
Hans-Christoph Steiner 2024-04-11 18:14:13 +00:00
commit 6e752fd960
6 changed files with 29 additions and 9 deletions

View File

@ -68,6 +68,7 @@ class BuildTest(unittest.TestCase):
os.makedirs(os.path.join(d, 'platform-tools'), exist_ok=True)
os.makedirs(os.path.join(d, 'tools'), exist_ok=True)
@unittest.skipIf(sys.byteorder == 'big', "androguard is not ported to big-endian")
def test_get_apk_metadata(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)

View File

@ -22,6 +22,7 @@ import fdroidserver.install
class InstallTest(unittest.TestCase):
'''fdroidserver/install.py'''
@unittest.skipIf(os.uname().machine == 's390x', 'adb is not ported to s390x')
def test_devices(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)

View File

@ -261,6 +261,7 @@ class PublishTest(unittest.TestCase):
self.assertEqual(publish.config['jarsigner'], data['jarsigner'])
self.assertEqual(publish.config['keytool'], data['keytool'])
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_sign_then_implant_signature(self):
class Options:
verbose = False

View File

@ -335,6 +335,7 @@ class ScannerTest(unittest.TestCase):
self.assertFalse(os.path.exists("build.gradle"))
self.assertEqual(0, count, 'there should be this many errors')
@unittest.skipIf(os.uname().machine == 's390x', 'dexdump is not ported to s390x')
def test_get_embedded_classes(self):
config = dict()
fdroidserver.common.config = config
@ -395,9 +396,7 @@ class ScannerTest(unittest.TestCase):
'should return not results for ' + f,
)
@unittest.skipIf(
sys.hexversion < 0x03090000, 'Python < 3.9 has a limited zipfile.is_zipfile()'
)
@unittest.skipIf(os.uname().machine == 's390x', 'dexdump is not ported to s390x')
def test_get_embedded_classes_secret_apk(self):
"""Try to hide an APK+DEX in an APK and see if we can find it"""
config = dict()
@ -452,6 +451,7 @@ class Test_scan_binary(unittest.TestCase):
}
fdroidserver.scanner._SCANNER_TOOL.regexs['warn_code_signatures'] = {}
@unittest.skipIf(os.uname().machine == 's390x', 'dexdump is not ported to s390x')
def test_code_signature_match(self):
apkfile = os.path.join(self.basedir, 'no_targetsdk_minsdk1_unsigned.apk')
self.assertEqual(
@ -465,12 +465,7 @@ class Test_scan_binary(unittest.TestCase):
),
)
@unittest.skipIf(
sys.version_info < (3, 9),
"Our implementation for traversing zip files will silently fail to work"
"on older python versions, also see: "
"https://gitlab.com/fdroid/fdroidserver/-/merge_requests/1110#note_932026766",
)
@unittest.skipIf(os.uname().machine == 's390x', 'dexdump is not ported to s390x')
def test_bottom_level_embedded_apk_code_signature(self):
apkfile = os.path.join(self.basedir, 'apk.embedded_1.apk')
fdroidserver.scanner._SCANNER_TOOL.regexs['err_code_signatures'] = {
@ -491,6 +486,7 @@ class Test_scan_binary(unittest.TestCase):
),
)
@unittest.skipIf(os.uname().machine == 's390x', 'dexdump is not ported to s390x')
def test_top_level_signature_embedded_apk_present(self):
apkfile = os.path.join(self.basedir, 'apk.embedded_1.apk')
fdroidserver.scanner._SCANNER_TOOL.regexs['err_code_signatures'] = {

View File

@ -29,6 +29,7 @@ class SignaturesTest(unittest.TestCase):
config['verbose'] = True
common.config = config
@unittest.skipIf(sys.byteorder == 'big', "androguard is not ported to big-endian")
def test_main(self):
# option fixture class:

View File

@ -261,6 +261,7 @@ class UpdateTest(unittest.TestCase):
fdroidserver.update.insert_localized_app_metadata(apps)
self.assertEqual('42', apps[app.id]['localized']['en-US']['whatsNew'])
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_name_title_scraping(self):
"""metadata file --> fdroiddata localized files --> fastlane/triple-t in app source --> APK"""
shutil.copytree(self.basedir, self.testdir, dirs_exist_ok=True)
@ -350,6 +351,7 @@ class UpdateTest(unittest.TestCase):
self.assertIsNone(app.get('Name'))
self.assertEqual(testvalue, app['localized']['en-US']['name'])
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_insert_missing_app_names_from_apks_from_repo(self):
os.chdir(self.testdir)
shutil.copytree(self.basedir, self.testdir, dirs_exist_ok=True)
@ -560,6 +562,7 @@ class UpdateTest(unittest.TestCase):
self.assertEqual(sig, 'e0ecb5fc2d63088e4a07ae410a127722',
"python sig should be: " + str(sig))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_getsig(self):
# config needed to use jarsigner and keytool
config = dict()
@ -603,6 +606,7 @@ class UpdateTest(unittest.TestCase):
self.assertEqual(good_fingerprint, sig,
"python sig was: " + str(sig))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def testScanApksAndObbs(self):
os.chdir(self.testdir)
shutil.copytree(os.path.join(self.basedir, 'repo'), 'repo')
@ -657,6 +661,7 @@ class UpdateTest(unittest.TestCase):
self.assertIsNone(apk.get('obbMainFile'))
self.assertIsNone(apk.get('obbPatchFile'))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_apkcache_json(self):
"""test the migration from pickle to json"""
os.chdir(self.testdir)
@ -719,6 +724,7 @@ class UpdateTest(unittest.TestCase):
info['hash'],
)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_read_added_date_from_all_apks(self):
os.chdir(self.testdir)
shutil.copytree(os.path.join(self.basedir, 'repo'), 'repo')
@ -732,6 +738,7 @@ class UpdateTest(unittest.TestCase):
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks)
fdroidserver.update.read_added_date_from_all_apks(apps, apks)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_apply_info_from_latest_apk(self):
os.chdir(self.testdir)
shutil.copytree(os.path.join(self.basedir, 'repo'), 'repo')
@ -746,6 +753,7 @@ class UpdateTest(unittest.TestCase):
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks)
fdroidserver.update.apply_info_from_latest_apk(apps, apks)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_scan_apk(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
@ -816,6 +824,7 @@ class UpdateTest(unittest.TestCase):
self.assertEqual(apk_info.get('versionName'), '1.0')
self.assertEqual(apk_info['icons_src'], {})
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_scan_apk_no_min_target(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
@ -854,6 +863,7 @@ class UpdateTest(unittest.TestCase):
self.assertDictEqual(apk_info, expected)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_scan_apk_no_sig(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
@ -936,6 +946,7 @@ class UpdateTest(unittest.TestCase):
shutil.copy(os.path.join(self.basedir, os.path.basename(apkfile)), apkfile)
fdroidserver.update.scan_apk(apkfile)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_process_apk(self):
def _build_yaml_representer(dumper, data):
'''Creates a YAML representation of a Build instance'''
@ -1007,6 +1018,7 @@ class UpdateTest(unittest.TestCase):
del from_yaml['ipfsCIDv1'] # handle when ipfs_cid is not installed
self.assertEqual(apk, from_yaml)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_process_apk_signed_by_disabled_algorithms(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
@ -1121,6 +1133,7 @@ class UpdateTest(unittest.TestCase):
self.assertIsNone(apk)
self.assertFalse(cachechanged)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apks_without_allowed_signatures(self):
"""Test when no AllowedAPKSigningKeys is specified"""
os.chdir(self.testdir)
@ -1142,6 +1155,7 @@ class UpdateTest(unittest.TestCase):
r = fdroidserver.update.get_apks_without_allowed_signatures(app, apk)
self.assertIsNone(r)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apks_without_allowed_signatures_allowed(self):
"""Test when the APK matches the specified AllowedAPKSigningKeys"""
os.chdir(self.testdir)
@ -1167,6 +1181,7 @@ class UpdateTest(unittest.TestCase):
r = fdroidserver.update.get_apks_without_allowed_signatures(app, apk)
self.assertIsNone(r)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apks_without_allowed_signatures_blocked(self):
"""Test when the APK does not match any specified AllowedAPKSigningKeys"""
os.chdir(self.testdir)
@ -1192,6 +1207,7 @@ class UpdateTest(unittest.TestCase):
r = fdroidserver.update.get_apks_without_allowed_signatures(app, apk)
self.assertEqual(apkfile, r)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_update_with_AllowedAPKSigningKeys(self):
"""Test that APKs without allowed signatures get deleted."""
os.chdir(self.testdir)
@ -1237,6 +1253,7 @@ class UpdateTest(unittest.TestCase):
fdroidserver.update.main()
self.assertFalse(os.path.exists(testapk))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_translate_per_build_anti_features(self):
os.chdir(self.testdir)
shutil.copytree(os.path.join(self.basedir, 'repo'), 'repo')
@ -1266,6 +1283,7 @@ class UpdateTest(unittest.TestCase):
foundtest = True
self.assertTrue(foundtest)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_create_metadata_from_template(self):
os.chdir(self.testdir)
os.mkdir('repo')
@ -1677,6 +1695,7 @@ class UpdateTest(unittest.TestCase):
self.assertEqual(fdroidserver.update.config['jarsigner'], data['jarsigner'])
self.assertEqual(fdroidserver.update.config['keytool'], data['keytool'])
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_scan_metadata_androguard(self):
def _create_apkmetadata_object(apkName):
@ -1741,6 +1760,7 @@ class UpdateTest(unittest.TestCase):
self.maxDiff = None
self.assertEqual(apkaapt, apkandroguard)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_exclude_disabled_apks(self):
os.chdir(self.testdir)
os.mkdir('repo')