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

This commit is contained in:
Hans-Christoph Steiner 2025-03-19 11:15:26 +01:00
parent 025828932d
commit 0b3fe26524
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA
9 changed files with 34 additions and 0 deletions

View File

@ -2,6 +2,7 @@
import os
import shutil
import sys
import tempfile
import textwrap
import unittest
@ -48,6 +49,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

@ -211,6 +211,7 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
fdroidserver.common._add_java_paths_to_config(pathlist, config)
self.assertEqual(config['java_paths']['8'], choice[1:])
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_is_debuggable_or_testOnly(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
@ -778,6 +779,7 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
for name in bad:
self.assertIsNone(fdroidserver.common.STANDARD_FILE_NAME_REGEX.match(name))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_apk_signer_fingerprint(self):
# fingerprints fetched with: keytool -printcert -file ____.RSA
@ -792,6 +794,7 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
self.assertEqual(keytoolcertfingerprint,
fdroidserver.common.apk_signer_fingerprint(apkfile))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_apk_signer_fingerprint_short(self):
# fingerprints fetched with: keytool -printcert -file ____.RSA
@ -905,6 +908,7 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
os.path.dirname(os.path.dirname(config.get('apksigner'))),
)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_sign_apk(self):
_mock_common_module_options_instance()
config = fdroidserver.common.read_config()
@ -1032,6 +1036,8 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
config = fdroidserver.common.read_config()
if 'apksigner' not in config:
self.skipTest('SKIPPING test_resign_apk, apksigner not installed!')
if sys.byteorder == 'big':
self.skipTest('SKIPPING androguard is not ported to big-endian')
config['keyalias'] = 'sova'
config['keystorepass'] = 'r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI='
@ -1064,6 +1070,7 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
fdroidserver.common.get_first_signer_certificate(resign)
)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apk_id(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
@ -1116,6 +1123,7 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
self.assertEqual(versionCode, vc, 'aapt versionCode parsing failed for ' + apkfilename)
self.assertEqual(versionName, vn, 'aapt versionName parsing failed for ' + apkfilename)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apk_id_bad_apk(self):
"""get_apk_id should never return None on error, only raise exceptions"""
with self.assertRaises(KeyError):
@ -1127,16 +1135,19 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
with self.assertRaises(KeyError):
fdroidserver.common.get_apk_id('Norway_bouvet_europe_2.obf.zip')
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apk_id_bad_path(self):
with self.assertRaises(FDroidException):
fdroidserver.common.get_apk_id('nope')
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apk_id_api_call(self):
self.assertEqual(
('info.guardianproject.urzip', 100, '0.1'),
fdroidserver.common.get_apk_id('urzip.apk'),
)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_apk_id_bad_zip(self):
os.chdir(self.testdir)
badzip = 'badzip.apk'
@ -1189,6 +1200,7 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
nc = fdroidserver.common.get_native_code(apkfilename)
self.assertEqual(native_code, nc)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_sdkversions_androguard(self):
"""This is a sanity test that androguard isn't broken"""
@ -3159,6 +3171,7 @@ class SignerExtractionTest(unittest.TestCase):
def tearDown(self):
self._td.cleanup()
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_first_signer_certificate_with_jars(self):
for jar in (
'signindex/guardianproject-v1.jar',
@ -3205,6 +3218,7 @@ class SignerExtractionTest(unittest.TestCase):
apk + " should have matching signer fingerprints",
)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_apk_signer_fingerprint_with_v1_apks(self):
for apk, fingerprint in APKS_WITH_JAR_SIGNATURES:
self.assertEqual(
@ -3213,6 +3227,7 @@ class SignerExtractionTest(unittest.TestCase):
f'apk_signer_fingerprint should match stored fingerprint for {apk}',
)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_apk_signer_fingerprint_without_v1_apks(self):
for apk, fingerprint in APKS_WITHOUT_JAR_SIGNATURES:
self.assertEqual(
@ -3221,6 +3236,7 @@ class SignerExtractionTest(unittest.TestCase):
f'apk_signer_fingerprint should match stored fingerprint for {apk}',
)
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_get_first_signer_certificate_with_unsigned_jar(self):
self.assertIsNone(
fdroidserver.common.get_first_signer_certificate('signindex/unsigned.jar')

View File

@ -12,6 +12,7 @@ from fdroidserver import common, install
from fdroidserver.exception import BuildException, FDroidException
@unittest.skipIf(os.uname().machine == 's390x', 'adb is not ported to s390x')
class InstallTest(unittest.TestCase):
'''fdroidserver/install.py'''

View File

@ -5,6 +5,7 @@ import re
import shlex
import shutil
import subprocess
import sys
import threading
import unittest
from datetime import datetime, timezone
@ -38,6 +39,7 @@ common.find_apksigner(conf)
USE_APKSIGNER = "apksigner" in conf
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
class IntegrationTest(unittest.TestCase):
@classmethod
def setUpClass(cls):

View File

@ -247,6 +247,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):
os.chdir(self.testdir)
@ -308,6 +309,7 @@ class PublishTest(unittest.TestCase):
self.assertFalse(os.path.exists(unsigned))
self.assertTrue(os.path.exists(signed))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_exit_on_error(self):
"""Exits properly on errors, with and without --error-on-failed.

View File

@ -387,6 +387,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
@ -447,6 +448,7 @@ class ScannerTest(unittest.TestCase):
'should return not results for ' + f,
)
@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()
@ -500,6 +502,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(basedir, 'no_targetsdk_minsdk1_unsigned.apk')
self.assertEqual(
@ -513,6 +516,7 @@ class Test_scan_binary(unittest.TestCase):
),
)
@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(basedir, 'apk.embedded_1.apk')
fdroidserver.scanner._SCANNER_TOOL.regexs['err_code_signatures'] = {
@ -533,6 +537,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(basedir, 'apk.embedded_1.apk')
fdroidserver.scanner._SCANNER_TOOL.regexs['err_code_signatures'] = {

View File

@ -2,6 +2,7 @@
import hashlib
import os
import sys
import unittest
from tempfile import TemporaryDirectory
@ -19,6 +20,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):
class OptionsFixture:

View File

@ -11,6 +11,7 @@ import random
import shutil
import string
import subprocess
import sys
import unittest
import yaml
import zipfile
@ -68,6 +69,7 @@ class Options:
verbose = False
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
class UpdateTest(unittest.TestCase):
'''fdroid update'''

View File

@ -3,6 +3,7 @@
import json
import os
import shutil
import sys
import tempfile
import unittest
@ -91,6 +92,7 @@ class VerifyTest(unittest.TestCase):
json.load(fp)
self.assertEqual(placeholder, verify.get_verified_json(f))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
@patch('fdroidserver.common.sha256sum')
def test_write_json_report(self, sha256sum):
sha256sum.return_value = (