enforce E501 in test/ (MR 2058)
This commit is contained in:
parent
f3b3fe906b
commit
27746db188
|
@ -57,11 +57,13 @@ def test_read_signature_info(args):
|
||||||
path = glob.glob(pmb.config.apk_keys_path + "/*.pub")[0]
|
path = glob.glob(pmb.config.apk_keys_path + "/*.pub")[0]
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
path_archive = "sbin/apk.static.SIGN.RSA." + name
|
path_archive = "sbin/apk.static.SIGN.RSA." + name
|
||||||
pmb.chroot.user(args, ["mv", tmp_path + "/sbin/apk.static.SIGN.RSA.invalid.pub",
|
pmb.chroot.user(args, ["mv",
|
||||||
tmp_path + "/" + path_archive])
|
f"{tmp_path}/sbin/apk.static.SIGN.RSA.invalid.pub",
|
||||||
|
f"{tmp_path}/{path_archive}"])
|
||||||
pmb.chroot.user(args, ["tar", "-czf", tmp_path + "/realistic_name_sig.apk",
|
pmb.chroot.user(args, ["tar", "-czf", tmp_path + "/realistic_name_sig.apk",
|
||||||
path_archive], working_dir=tmp_path)
|
path_archive], working_dir=tmp_path)
|
||||||
with tarfile.open(tmp_path_outside + "/realistic_name_sig.apk", "r:gz") as tar:
|
with tarfile.open(f"{tmp_path_outside}/realistic_name_sig.apk", "r:gz")\
|
||||||
|
as tar:
|
||||||
sigfilename, sigkey_path = pmb.chroot.apk_static.read_signature_info(
|
sigfilename, sigkey_path = pmb.chroot.apk_static.read_signature_info(
|
||||||
tar)
|
tar)
|
||||||
assert sigfilename == path_archive
|
assert sigfilename == path_archive
|
||||||
|
@ -85,8 +87,8 @@ def test_signature_verification(args, tmpdir):
|
||||||
os.remove(args.work + "/apk.static")
|
os.remove(args.work + "/apk.static")
|
||||||
|
|
||||||
version = pmb.parse.apkindex.package(args, "apk-tools-static")["version"]
|
version = pmb.parse.apkindex.package(args, "apk-tools-static")["version"]
|
||||||
apk_path = pmb.chroot.apk_static.download(args,
|
apk_path = pmb.chroot.apk_static.download(
|
||||||
"apk-tools-static-" + version + ".apk")
|
args, f"apk-tools-static-{version}.apk")
|
||||||
|
|
||||||
# Extract to temporary folder
|
# Extract to temporary folder
|
||||||
with tarfile.open(apk_path, "r:gz") as tar:
|
with tarfile.open(apk_path, "r:gz") as tar:
|
||||||
|
|
|
@ -37,7 +37,8 @@ def args(tmpdir, request):
|
||||||
# Copy the linux-lg-mako aport (we currently copy patches from there)
|
# Copy the linux-lg-mako aport (we currently copy patches from there)
|
||||||
pmb.helpers.run.user(args, ["mkdir", "-p", tmpdir + "/device/testing"])
|
pmb.helpers.run.user(args, ["mkdir", "-p", tmpdir + "/device/testing"])
|
||||||
path_mako = args._aports_real + "/device/testing/linux-lg-mako"
|
path_mako = args._aports_real + "/device/testing/linux-lg-mako"
|
||||||
pmb.helpers.run.user(args, ["cp", "-r", path_mako, tmpdir + "/device/testing"])
|
pmb.helpers.run.user(args, ["cp", "-r", path_mako,
|
||||||
|
f"{tmpdir}/device/testing"])
|
||||||
|
|
||||||
# Copy pmaports.cfg
|
# Copy pmaports.cfg
|
||||||
shutil.copy(f"{pmb_test.const.testdata}/pmaports.cfg", args.aports)
|
shutil.copy(f"{pmb_test.const.testdata}/pmaports.cfg", args.aports)
|
||||||
|
@ -46,7 +47,8 @@ def args(tmpdir, request):
|
||||||
|
|
||||||
def generate(args, monkeypatch, answers):
|
def generate(args, monkeypatch, answers):
|
||||||
"""
|
"""
|
||||||
Generate the device-new-device and linux-new-device aports (with a patched pmb.helpers.cli()).
|
Generate the device-new-device and linux-new-device aports (with a patched
|
||||||
|
pmb.helpers.cli()).
|
||||||
|
|
||||||
:returns: (deviceinfo, apkbuild, apkbuild_linux) - the parsed dictionaries
|
:returns: (deviceinfo, apkbuild, apkbuild_linux) - the parsed dictionaries
|
||||||
of the created files, as returned by pmb.parse.apkbuild() and
|
of the created files, as returned by pmb.parse.apkbuild() and
|
||||||
|
@ -69,12 +71,13 @@ def generate(args, monkeypatch, answers):
|
||||||
pmb.aportgen.generate(args, "linux-testsuite-testdevice")
|
pmb.aportgen.generate(args, "linux-testsuite-testdevice")
|
||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
|
||||||
apkbuild_path = (args.aports + "/device/testing/device-testsuite-testdevice/"
|
apkbuild_path = (f"{args.aports}/device/testing/"
|
||||||
"APKBUILD")
|
"device-testsuite-testdevice/APKBUILD")
|
||||||
apkbuild_path_linux = (args.aports + "/device/testing/"
|
apkbuild_path_linux = (args.aports + "/device/testing/"
|
||||||
"linux-testsuite-testdevice/APKBUILD")
|
"linux-testsuite-testdevice/APKBUILD")
|
||||||
|
|
||||||
# The build fails if the email is not a valid email, so remove them just for tests
|
# The build fails if the email is not a valid email, so remove them just
|
||||||
|
# for tests
|
||||||
remove_contributor_maintainer_lines(args, apkbuild_path)
|
remove_contributor_maintainer_lines(args, apkbuild_path)
|
||||||
remove_contributor_maintainer_lines(args, apkbuild_path_linux)
|
remove_contributor_maintainer_lines(args, apkbuild_path_linux)
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ def args(request, tmpdir):
|
||||||
apkindex_path = str(tmpdir) + "/APKINDEX.tar.gz"
|
apkindex_path = str(tmpdir) + "/APKINDEX.tar.gz"
|
||||||
open(apkindex_path, "a").close()
|
open(apkindex_path, "a").close()
|
||||||
lastmod = os.path.getmtime(apkindex_path)
|
lastmod = os.path.getmtime(apkindex_path)
|
||||||
args.cache["apkindex"][apkindex_path] = {"lastmod": lastmod, "multiple": {}}
|
args.cache["apkindex"][apkindex_path] = {"lastmod": lastmod,
|
||||||
|
"multiple": {}}
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +36,8 @@ def cache_apkindex(args, version):
|
||||||
"""
|
"""
|
||||||
apkindex_path = list(args.cache["apkindex"].keys())[0]
|
apkindex_path = list(args.cache["apkindex"].keys())[0]
|
||||||
|
|
||||||
providers = args.cache["apkindex"][apkindex_path]["multiple"]["hello-world"]
|
providers = args.cache[
|
||||||
|
"apkindex"][apkindex_path]["multiple"]["hello-world"]
|
||||||
providers["hello-world"]["version"] = version
|
providers["hello-world"]["version"] = version
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,8 @@ def test_init_buildenv(args, monkeypatch):
|
||||||
|
|
||||||
# Shortcut and fake apkbuild
|
# Shortcut and fake apkbuild
|
||||||
func = pmb.build._package.init_buildenv
|
func = pmb.build._package.init_buildenv
|
||||||
apkbuild = {"pkgname": "test", "depends": ["a"], "makedepends": ["b"], "options": []}
|
apkbuild = {"pkgname": "test", "depends": ["a"], "makedepends": ["b"],
|
||||||
|
"options": []}
|
||||||
|
|
||||||
# Build is necessary (various code paths)
|
# Build is necessary (various code paths)
|
||||||
assert func(args, apkbuild, "armhf", strict=True) is True
|
assert func(args, apkbuild, "armhf", strict=True) is True
|
||||||
|
|
|
@ -8,7 +8,8 @@ import pmb.config
|
||||||
|
|
||||||
def test_chroot_interactive_shell():
|
def test_chroot_interactive_shell():
|
||||||
"""
|
"""
|
||||||
Open a shell with 'pmbootstrap chroot' and pass 'echo hello_world\n' as stdin.
|
Open a shell with 'pmbootstrap chroot' and pass 'echo hello_world\n' as
|
||||||
|
stdin.
|
||||||
"""
|
"""
|
||||||
os.chdir(pmb.config.pmb_src)
|
os.chdir(pmb.config.pmb_src)
|
||||||
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot", "sh"],
|
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot", "sh"],
|
||||||
|
@ -24,7 +25,8 @@ def test_chroot_interactive_shell_user():
|
||||||
"""
|
"""
|
||||||
os.chdir(pmb.config.pmb_src)
|
os.chdir(pmb.config.pmb_src)
|
||||||
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot",
|
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot",
|
||||||
"--user", "sh"], timeout=300, input="id -un",
|
"--user", "sh"], timeout=300,
|
||||||
|
input="id -un",
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
assert ret == "pmos\n"
|
assert ret == "pmos\n"
|
||||||
|
@ -32,15 +34,18 @@ def test_chroot_interactive_shell_user():
|
||||||
|
|
||||||
def test_chroot_arguments():
|
def test_chroot_arguments():
|
||||||
"""
|
"""
|
||||||
Open a shell with 'pmbootstrap chroot' for every architecture, pass 'uname -m\n'
|
Open a shell with 'pmbootstrap chroot' for every architecture, pass
|
||||||
as stdin and check the output
|
'uname -m\n' as stdin and check the output
|
||||||
"""
|
"""
|
||||||
os.chdir(pmb.config.pmb_src)
|
os.chdir(pmb.config.pmb_src)
|
||||||
|
|
||||||
for arch in ["armhf", "aarch64", "x86_64"]:
|
for arch in ["armhf", "aarch64", "x86_64"]:
|
||||||
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot", "-b", arch,
|
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot",
|
||||||
"sh"], timeout=300, input="uname -m\n",
|
"-b", arch, "sh"],
|
||||||
universal_newlines=True, stderr=subprocess.STDOUT)
|
timeout=300,
|
||||||
|
input="uname -m\n",
|
||||||
|
universal_newlines=True,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
if arch == "armhf":
|
if arch == "armhf":
|
||||||
assert ret == "armv7l\n"
|
assert ret == "armv7l\n"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -23,8 +23,8 @@ def args(tmpdir, request):
|
||||||
|
|
||||||
|
|
||||||
def change_config(monkeypatch, path_config, key, value):
|
def change_config(monkeypatch, path_config, key, value):
|
||||||
args = args_patched(monkeypatch, ["pmbootstrap.py", "-c", path_config, "config",
|
args = args_patched(monkeypatch, ["pmbootstrap.py", "-c", path_config,
|
||||||
key, value])
|
"config", key, value])
|
||||||
pmb.helpers.frontend.config(args)
|
pmb.helpers.frontend.config(args)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ def args(request):
|
||||||
|
|
||||||
def pmbootstrap(args, tmpdir, parameters, zero_exit=True):
|
def pmbootstrap(args, tmpdir, parameters, zero_exit=True):
|
||||||
"""
|
"""
|
||||||
Helper function for running pmbootstrap inside the fake work folder (created
|
Helper function for running pmbootstrap inside the fake work folder
|
||||||
by setup() below) with the binary repo disabled and with the testdata
|
(created by setup() below) with the binary repo disabled and with the
|
||||||
configured as aports.
|
testdata configured as aports.
|
||||||
|
|
||||||
:param parameters: what to pass to pmbootstrap, e.g. ["build", "testlib"]
|
:param parameters: what to pass to pmbootstrap, e.g. ["build", "testlib"]
|
||||||
:param zero_exit: expect pmbootstrap to exit with 0 (no error)
|
:param zero_exit: expect pmbootstrap to exit with 0 (no error)
|
||||||
|
@ -64,8 +64,8 @@ def setup_work(args, tmpdir):
|
||||||
well, so it can be modified during testing.
|
well, so it can be modified during testing.
|
||||||
"""
|
"""
|
||||||
# Clean the chroots, and initialize the build chroot in the native chroot.
|
# Clean the chroots, and initialize the build chroot in the native chroot.
|
||||||
# We do this before creating the fake work folder, because then all packages
|
# We do this before creating the fake work folder, because then all
|
||||||
# are still present.
|
# packages are still present.
|
||||||
os.chdir(pmb.config.pmb_src)
|
os.chdir(pmb.config.pmb_src)
|
||||||
pmb.helpers.run.user(args, ["./pmbootstrap.py", "-y", "zap"])
|
pmb.helpers.run.user(args, ["./pmbootstrap.py", "-y", "zap"])
|
||||||
pmb.helpers.run.user(args, ["./pmbootstrap.py", "build_init"])
|
pmb.helpers.run.user(args, ["./pmbootstrap.py", "build_init"])
|
||||||
|
@ -85,8 +85,9 @@ def setup_work(args, tmpdir):
|
||||||
f"{tmpdir}/_aports/device/testing"])
|
f"{tmpdir}/_aports/device/testing"])
|
||||||
for pkgname in ["testlib", "testapp", "testsubpkg"]:
|
for pkgname in ["testlib", "testapp", "testsubpkg"]:
|
||||||
pmb.helpers.run.user(args, ["cp", "-r",
|
pmb.helpers.run.user(args, ["cp", "-r",
|
||||||
"test/testdata/pkgrel_bump/aports/" + pkgname,
|
"test/testdata/pkgrel_bump/aports/"
|
||||||
tmpdir + "/_aports/main/" + pkgname])
|
f"{pkgname}",
|
||||||
|
f"{tmpdir}/_aports/main/{pkgname}"])
|
||||||
|
|
||||||
# Copy pmaports.cfg
|
# Copy pmaports.cfg
|
||||||
pmb.helpers.run.user(args, ["cp", args.aports + "/pmaports.cfg", tmpdir +
|
pmb.helpers.run.user(args, ["cp", args.aports + "/pmaports.cfg", tmpdir +
|
||||||
|
|
|
@ -120,15 +120,15 @@ def is_running(args, programs, timeout=300, sleep_before_retry=1):
|
||||||
"""
|
"""
|
||||||
Simple check that looks for program names in the output of "ps ax".
|
Simple check that looks for program names in the output of "ps ax".
|
||||||
This is error-prone, only use it with programs that have a unique name.
|
This is error-prone, only use it with programs that have a unique name.
|
||||||
With defaults timeout and sleep_before_retry values, it will try keep trying
|
With defaults timeout and sleep_before_retry values, it will try keep
|
||||||
for 5 minutes, but not more than once per second.
|
trying for 5 minutes, but not more than once per second.
|
||||||
|
|
||||||
:param programs: list of programs to check for, e.g. ["xfce4-desktop"]
|
:param programs: list of programs to check for, e.g. ["xfce4-desktop"]
|
||||||
:param timeout: approximate time in seconds until timeout
|
:param timeout: approximate time in seconds until timeout
|
||||||
:param sleep_before_retry: time in seconds to sleep before trying again
|
:param sleep_before_retry: time in seconds to sleep before trying again
|
||||||
"""
|
"""
|
||||||
print("Looking for programs to appear in the VM (timeout: " + str(timeout) +
|
print(f"Looking for programs to appear in the VM (timeout: {timeout}): " +
|
||||||
"): " + ", ".join(programs))
|
", ".join(programs))
|
||||||
ssh_works = False
|
ssh_works = False
|
||||||
|
|
||||||
end = time.monotonic() + timeout
|
end = time.monotonic() + timeout
|
||||||
|
@ -170,7 +170,8 @@ def test_none(args, tmpdir, qemu):
|
||||||
# Check that at least SSH works (no special process running)
|
# Check that at least SSH works (no special process running)
|
||||||
assert is_running(args, [])
|
assert is_running(args, [])
|
||||||
|
|
||||||
# self-test of is_running() - invalid-process should not be detected as running
|
# self-test of is_running() - invalid-process should not be detected as
|
||||||
|
# running
|
||||||
assert is_running(args, ["invalid-process"], 1) is False
|
assert is_running(args, ["invalid-process"], 1) is False
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,7 +182,7 @@ def test_xfce4(args, tmpdir, qemu):
|
||||||
|
|
||||||
|
|
||||||
def test_plasma_mobile(args, tmpdir, qemu):
|
def test_plasma_mobile(args, tmpdir, qemu):
|
||||||
# NOTE: Once we have plasma mobile running properly without GL, we can check
|
# NOTE: Once we have plasma mobile running properly without GL, we can
|
||||||
# for more processes
|
# check for more processes
|
||||||
qemu.run(args, tmpdir, "plasma-mobile")
|
qemu.run(args, tmpdir, "plasma-mobile")
|
||||||
assert is_running(args, ["polkitd"])
|
assert is_running(args, ["polkitd"])
|
||||||
|
|
Loading…
Reference in New Issue