Skip to content

Commit

Permalink
test/test_mark: assert boot status changes actually happen
Browse files Browse the repository at this point in the history
Verify the pre- and post-conditions.

To check that 'mark-active' actually has an effect, add 'other' to mark
the 'bad' slot 'good'/active.

Signed-off-by: Enrico Joerns <[email protected]>
  • Loading branch information
ejoerns committed Nov 29, 2024
1 parent 7b9d823 commit 06f3bac
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions test/test_mark.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import json

from conftest import have_grub, no_service
from helper import run
from helper import slot_data_from_json


@no_service
Expand Down Expand Up @@ -60,23 +63,73 @@ def test_status_mark_good_non_bootslot(rauc_no_service):

@have_grub
def test_status_mark_good_dbus(rauc_dbus_service_with_system):
out, err, exitcode = run("rauc status --output-format=json-pretty")
assert exitcode == 0
status_data = json.loads(out)

assert slot_data_from_json(status_data, "rootfs.0")["boot_status"] == "good"
assert slot_data_from_json(status_data, "rootfs.1")["boot_status"] == "bad"

out, err, exitcode = run("rauc status mark-good")

assert exitcode == 0
assert "marked slot rootfs.0 as good" in out

out, err, exitcode = run("rauc status --output-format=json-pretty")
assert exitcode == 0
status_data = json.loads(out)

assert slot_data_from_json(status_data, "rootfs.0")["boot_status"] == "good"
assert slot_data_from_json(status_data, "rootfs.1")["boot_status"] == "bad"


@have_grub
def test_status_mark_bad_dbus(rauc_dbus_service_with_system):
# check pre-condition
out, err, exitcode = run("rauc status --output-format=json-pretty")
assert exitcode == 0
status_data = json.loads(out)

assert slot_data_from_json(status_data, "rootfs.0")["boot_status"] == "good"
assert slot_data_from_json(status_data, "rootfs.1")["boot_status"] == "bad"

# mark bad
out, err, exitcode = run("rauc status mark-bad")

assert exitcode == 0
assert "marked slot rootfs.0 as bad" in out

# check post-condition
out, err, exitcode = run("rauc status --output-format=json-pretty")
assert exitcode == 0
status_data = json.loads(out)

assert slot_data_from_json(status_data, "rootfs.0")["boot_status"] == "bad"
assert slot_data_from_json(status_data, "rootfs.1")["boot_status"] == "bad"


@have_grub
def test_status_mark_active_dbus(rauc_dbus_service_with_system):
out, err, exitcode = run("rauc status mark-active")
# check pre-condition
out, err, exitcode = run("rauc status --output-format=json-pretty")
assert exitcode == 0
status_data = json.loads(out)

assert slot_data_from_json(status_data, "rootfs.0")["boot_status"] == "good"
assert slot_data_from_json(status_data, "rootfs.1")["boot_status"] == "bad"
assert status_data["boot_primary"] == "rootfs.0"

# mark active other
out, err, exitcode = run("rauc status mark-active other")

assert exitcode == 0
assert "activated slot rootfs.1" in out

# check post-condition
out, err, exitcode = run("rauc status --output-format=json-pretty")
assert exitcode == 0
assert "activated slot rootfs.0" in out
status_data = json.loads(out)

assert slot_data_from_json(status_data, "rootfs.0")["boot_status"] == "good"
assert slot_data_from_json(status_data, "rootfs.1")["boot_status"] == "good"
assert status_data["boot_primary"] == "rootfs.1"

0 comments on commit 06f3bac

Please sign in to comment.