Skip to content

Commit

Permalink
Fix controller-system-buttons test
Browse files Browse the repository at this point in the history
  • Loading branch information
yfyf committed Nov 28, 2024
1 parent 4c1eb5e commit bc613f8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions testing/integration/controller-system-buttons.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ pkgs.testers.runNixOSTest {
# produces the reboot/shutdown log messages used in `wait_for_console_text`
playos.wait_for_unit("systemd-logind.service")
# Executes curl without waiting for it to complete or return an exit status.
# This avoids issues with test-driver choking on non-decodable output.
def curl_POST_ignore_output(url):
playos.execute(f"curl -X POST {url} >&2", check_output = False)
playos.start(allow_reboot=True)
wait_for_http()
# ===== Reboot works
with subtest("Reboot works"):
playos.succeed("curl -X POST http://localhost:3333/system/reboot >&2")
curl_POST_ignore_output("http://localhost:3333/system/reboot")
playos.wait_for_console_text("systemd.*The system will reboot now!")
manual_restart()
Expand All @@ -84,7 +88,7 @@ pkgs.testers.runNixOSTest {
--property ActiveState \
playos-wipe-persistent-data.service | grep 'ActiveState=inactive'
""")
playos.succeed("curl -X POST http://localhost:3333/system/factory-reset >&2")
curl_POST_ignore_output("http://localhost:3333/system/factory-reset")
playos.wait_for_console_text("systemd.*Starting playos-wipe-persistent-data.service.")
playos.wait_for_console_text("systemd.*The system will reboot now!")
Expand All @@ -93,15 +97,15 @@ pkgs.testers.runNixOSTest {
# ===== Switch slot works
with subtest("Switch slot works"):
playos.succeed("curl -X POST http://localhost:3333/system/switch/system.b >&2")
curl_POST_ignore_output("http://localhost:3333/system/switch/system.b")
playos.wait_for_console_text("rauc mark: activated slot system.b")
playos.wait_for_console_text("systemd.*The system will reboot now!")
manual_restart()
# ===== Shutdown works
with subtest("Shutdown works"):
playos.succeed("curl -X POST http://localhost:3333/system/shutdown >&2")
curl_POST_ignore_output("http://localhost:3333/system/shutdown")
playos.wait_for_console_text("systemd.*System is powering down.")
playos.crash() # avoids "Broken pipe" test failure
'';
Expand Down

0 comments on commit bc613f8

Please sign in to comment.