From 58ed4e8818dce0a2c7e05120f61041346d3dc343 Mon Sep 17 00:00:00 2001 From: Enrico Joerns Date: Thu, 19 Sep 2024 16:38:31 +0200 Subject: [PATCH] test: add test for A/B/C install Signed-off-by: Enrico Joerns --- test/conftest.py | 25 +++++++++++++++++++++++++ test/test_install.py | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/test/conftest.py b/test/conftest.py index 6ad28b5d1..773c731bd 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -419,6 +419,31 @@ def rauc_dbus_service_with_system_external(tmp_path, dbus_session_bus, create_sy yield from rauc_dbus_service_helper(tmp_path, dbus_session_bus, create_system_files, system.output, "_external_") +@pytest.fixture +def rauc_dbus_service_with_system_abc(tmp_path, dbus_session_bus, create_system_files, system): + system.prepare_minimal_config() + # add third slot group + system.config["slot.rootfs.2"] = { + "device": "images/rootfs-2", + "type": "raw", + "bootname": "C", + } + system.config["slot.appfs.2"] = { + "device": "images/appfs-2", + "type": "raw", + "parent": "rootfs.2", + } + system.write_config() + # create target devices for third slot group + open(tmp_path / "images/rootfs-2", mode="w").close() + open(tmp_path / "images/appfs-2", mode="w").close() + # prepare grub env for 3 slots + run( + f'grub-editenv {tmp_path}/grubenv.test set ORDER="A B C" A_TRY="0" B_TRY="0" C_TRY="0" A_OK="1" B_OK="1" C_OK="1"' + ) + yield from rauc_dbus_service_helper(tmp_path, dbus_session_bus, create_system_files, system.output, "A") + + @pytest.fixture def rauc_dbus_service_with_system_adaptive(tmp_path, dbus_session_bus, create_system_files): yield from rauc_dbus_service_helper(tmp_path, dbus_session_bus, create_system_files, "adaptive-test.conf", "A") diff --git a/test/test_install.py b/test/test_install.py index acce940cc..94e14e756 100644 --- a/test/test_install.py +++ b/test/test_install.py @@ -160,6 +160,32 @@ def test_install_rauc_external(rauc_dbus_service_with_system_external, tmp_path) assert os.path.getsize(tmp_path / "images/rootfs-0") > 0 +def test_install_abc(rauc_dbus_service_with_system_abc, tmp_path): + assert os.path.exists(tmp_path / "images/rootfs-1") + assert not os.path.getsize(tmp_path / "images/rootfs-1") > 0 + assert os.path.exists(tmp_path / "images/rootfs-2") + assert not os.path.getsize(tmp_path / "images/rootfs-2") > 0 + + # copy to tmp path for safe ownership check + shutil.copyfile("good-verity-bundle.raucb", tmp_path / "good-verity-bundle.raucb") + + # First installation should update rootfs-1 (implementation-defined) + out, err, exitcode = run(f"rauc install {tmp_path}/good-verity-bundle.raucb") + + assert exitcode == 0 + assert os.path.getsize(tmp_path / "images/rootfs-0") == 0 + assert os.path.getsize(tmp_path / "images/rootfs-1") > 0 + assert os.path.getsize(tmp_path / "images/rootfs-2") == 0 + + # Second installation should update rootfs-2 (implementation-defined) + out, err, exitcode = run(f"rauc install {tmp_path}/good-verity-bundle.raucb") + + assert exitcode == 0 + assert os.path.getsize(tmp_path / "images/rootfs-0") == 0 + assert os.path.getsize(tmp_path / "images/rootfs-1") > 0 + assert os.path.getsize(tmp_path / "images/rootfs-2") > 0 + + @no_service def test_install_no_service(tmp_path, create_system_files, system): assert os.path.exists(tmp_path / "images/rootfs-1")