Skip to content

Commit

Permalink
test: add test for A/B/C install
Browse files Browse the repository at this point in the history
Signed-off-by: Enrico Joerns <[email protected]>
  • Loading branch information
ejoerns committed Nov 29, 2024
1 parent 890160e commit 58ed4e8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
26 changes: 26 additions & 0 deletions test/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 58ed4e8

Please sign in to comment.