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

View file

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

View file

@ -247,6 +247,7 @@ class PublishTest(unittest.TestCase):
self.assertEqual(publish.config['jarsigner'], data['jarsigner']) self.assertEqual(publish.config['jarsigner'], data['jarsigner'])
self.assertEqual(publish.config['keytool'], data['keytool']) 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): def test_sign_then_implant_signature(self):
os.chdir(self.testdir) os.chdir(self.testdir)
@ -308,6 +309,7 @@ class PublishTest(unittest.TestCase):
self.assertFalse(os.path.exists(unsigned)) self.assertFalse(os.path.exists(unsigned))
self.assertTrue(os.path.exists(signed)) self.assertTrue(os.path.exists(signed))
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
def test_exit_on_error(self): def test_exit_on_error(self):
"""Exits properly on errors, with and without --error-on-failed. """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.assertFalse(os.path.exists("build.gradle"))
self.assertEqual(0, count, 'there should be this many errors') 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): def test_get_embedded_classes(self):
config = dict() config = dict()
fdroidserver.common.config = config fdroidserver.common.config = config
@ -447,6 +448,7 @@ class ScannerTest(unittest.TestCase):
'should return not results for ' + f, '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): def test_get_embedded_classes_secret_apk(self):
"""Try to hide an APK+DEX in an APK and see if we can find it""" """Try to hide an APK+DEX in an APK and see if we can find it"""
config = dict() config = dict()
@ -500,6 +502,7 @@ class Test_scan_binary(unittest.TestCase):
} }
fdroidserver.scanner._SCANNER_TOOL.regexs['warn_code_signatures'] = {} 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): def test_code_signature_match(self):
apkfile = os.path.join(basedir, 'no_targetsdk_minsdk1_unsigned.apk') apkfile = os.path.join(basedir, 'no_targetsdk_minsdk1_unsigned.apk')
self.assertEqual( 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): def test_bottom_level_embedded_apk_code_signature(self):
apkfile = os.path.join(basedir, 'apk.embedded_1.apk') apkfile = os.path.join(basedir, 'apk.embedded_1.apk')
fdroidserver.scanner._SCANNER_TOOL.regexs['err_code_signatures'] = { 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): def test_top_level_signature_embedded_apk_present(self):
apkfile = os.path.join(basedir, 'apk.embedded_1.apk') apkfile = os.path.join(basedir, 'apk.embedded_1.apk')
fdroidserver.scanner._SCANNER_TOOL.regexs['err_code_signatures'] = { fdroidserver.scanner._SCANNER_TOOL.regexs['err_code_signatures'] = {

View file

@ -2,6 +2,7 @@
import hashlib import hashlib
import os import os
import sys
import unittest import unittest
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
@ -19,6 +20,7 @@ class SignaturesTest(unittest.TestCase):
config['verbose'] = True config['verbose'] = True
common.config = config common.config = config
@unittest.skipIf(sys.byteorder == 'big', "androguard is not ported to big-endian")
def test_main(self): def test_main(self):
class OptionsFixture: class OptionsFixture:

View file

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

View file

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