From f4fed3d99e36e90c9dfccc566116629fc628d51d Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 6 Aug 2023 20:43:32 +0200 Subject: [PATCH] test/test_crossdirect: remove Remove test_crossdirect_rust, the only test in test_crossdirect.py. The behavior that was tested here with all the "mv /usr/bin/rustc" commands was specific to version 4 and isn't valid anymore since version 5 (pmaports MR 4234). The previous behavior was that crossdirect always tried to run rustc from /native, and if it failed, it would fall back to using qemu. The new behavior is that it runs rustc from /native only when it expects it to succeed, and runs rustc via qemu otherwise, without attempting /native first. As the logic to decide whether to use native rustc or not is now done beforehand, it does not do the fallback to qemu if native fails. Note that the test hasn't been failing because we switch to the v23.06 channel and therefore use the older crossdirect version. Reviewed-by: Luca Weiss Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230806184729.4891-6-ollieparanoid@postmarketos.org%3E --- test/test_crossdirect.py | 81 ---------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 test/test_crossdirect.py diff --git a/test/test_crossdirect.py b/test/test_crossdirect.py deleted file mode 100644 index 5212a3a1..00000000 --- a/test/test_crossdirect.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2023 Oliver Smith -# SPDX-License-Identifier: GPL-3.0-or-later -import pytest -import sys - -import pmb_test # noqa -import pmb.chroot.apk_static -import pmb.config.pmaports -import pmb.parse.apkindex -import pmb.helpers.logging -import pmb.helpers.run -import pmb.parse.bootimg - - -@pytest.fixture -def args(request): - import pmb.parse - sys.argv = ["pmbootstrap.py", "chroot"] - args = pmb.parse.arguments() - args.log = args.work + "/log_testsuite.txt" - pmb.helpers.logging.init(args) - request.addfinalizer(pmb.helpers.logging.logfd.close) - return args - - -def pmbootstrap_run(args, parameters, check=True): - """Execute pmbootstrap.py with a test pmbootstrap.conf.""" - return pmb.helpers.run.user(args, ["./pmbootstrap.py"] + parameters, - working_dir=pmb.config.pmb_src, - check=check) - - -def test_crossdirect_rust(args): - """ Set up buildroot_armv7 chroot for building, but remove /usr/bin/rustc. - Build hello-world-rust for armv7, to verify that it uses - /native/usr/bin/rustc instead of /usr/bin/rustc. The package has a - check() function, which makes sure that the built program is actually - working. """ - pmbootstrap_run(args, ["-y", "zap"]) - - # Remember previously selected device - cfg = pmb.config.load(args) - old_device = cfg['pmbootstrap']['device'] - - try: - # First, switch to device that is known to exist on all channels, - # such as qemu-amd64. Currently selected device may not exist in - # stable branch! - cfg['pmbootstrap']['device'] = 'qemu-amd64' - pmb.config.save(args, cfg) - - # Switch to "v20.05" channel, as a stable release of alpine is more - # likely to have the same rustc version across various architectures. - # If armv7/x86_64 have a different rustc version, this test will fail: - # 'found crate `std` compiled by an incompatible version of rustc' - pmb.config.pmaports.switch_to_channel_branch(args, "v23.06") - - pmbootstrap_run(args, ["build_init", "-barmv7"]) - pmbootstrap_run(args, ["chroot", "--add=rust", "-barmv7", "--", - "mv", "/usr/bin/rustc", "/usr/bin/rustc_"]) - pmbootstrap_run(args, ["build", "hello-world-rust", "--arch=armv7", - "--force"]) - # Make /native/usr/bin/rustc unusable too, to make the build fail - pmbootstrap_run(args, ["chroot", "--", "rm", "/usr/bin/rustc"]) - assert pmbootstrap_run(args, ["build", "hello-world-rust", - "--arch=armv7", "--force"], - check=False) == 1 - - # Make /usr/bin/rustc usable again, to test fallback with qemu - pmbootstrap_run(args, ["chroot", "-barmv7", "--", - "mv", "/usr/bin/rustc_", "/usr/bin/rustc"]) - pmbootstrap_run(args, ["build", "hello-world-rust", "--arch=armv7", - "--force"]) - finally: - # Clean up - pmb.config.pmaports.switch_to_channel_branch(args, "edge") - pmbootstrap_run(args, ["-y", "zap"]) - - # Restore previously selected device - cfg['pmbootstrap']['device'] = old_device - pmb.config.save(args, cfg)