Skip to content

Commit

Permalink
fixup! rauc status tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ejoerns committed Nov 3, 2023
1 parent a899787 commit d147d48
Showing 1 changed file with 27 additions and 73 deletions.
100 changes: 27 additions & 73 deletions test/test_rauc_status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import json

from helper import run

Expand Down Expand Up @@ -61,28 +62,6 @@ def test_rauc_status_no_service_output_nvalid():
assert exitcode == 1
assert "Unknown output format: 'invalid'" in err

# start_rauc_dbus_service ()
# {
# rauc "$@" service&
# RAUC_DBUS_SERVICE_PID=$!
#
# # The timeout is measured in nanoseconds
# TIMEOUT=$(( 5 * 1000 * 1000 * 1000 ))
# END=$(( $(date +%s%N) + ${TIMEOUT} ))
#
# # Wait for RAUC's background service to appear on the bus or the timeout
# # period to elapse
# while true; do
# dbus-send --${DBUS_STARTER_BUS_TYPE} --dest=de.pengutronix.rauc --reply-timeout=1000 --print-reply --type=method_call org.freedesktop.DBus.Peer.Ping > /dev/null 2>&1 && break
# test $(date +%s%N) -ge ${END} && break
# done
# }
# stop_rauc_dbus_service ()
# {
# kill ${RAUC_DBUS_SERVICE_PID}
# wait ${RAUC_DBUS_SERVICE_PID}
# }

import time
import subprocess

Expand Down Expand Up @@ -137,54 +116,29 @@ def test_rauc_status_shell(rauc_service, rauc_dbus_service):
assert exitcode == 0
assert out.startswith("RAUC_SYSTEM_COMPATIBLE='Test Config'")

"""
test_expect_success SERVICE "rauc --override-boot-slot=system0 status: via D-Bus" "
start_rauc_dbus_service \
--conf=${SHARNESS_TEST_DIRECTORY}/test.conf \
--override-boot-slot=system0 &&
test_when_finished stop_rauc_dbus_service &&
rauc status
"
test_expect_success SERVICE "rauc status (detailed) readable: via D-Bus" "
start_rauc_dbus_service \
--conf=${SHARNESS_TEST_DIRECTORY}/test.conf \
--override-boot-slot=system0 &&
test_when_finished stop_rauc_dbus_service &&
rauc status --detailed --output-format=readable
"
test_expect_success SERVICE "rauc status (detailed) shell: via D-Bus" "
start_rauc_dbus_service \
--conf=${SHARNESS_TEST_DIRECTORY}/test.conf \
--override-boot-slot=system0 &&
test_when_finished stop_rauc_dbus_service &&
rauc status --detailed --output-format=shell \
| sh
"
test_expect_success SERVICE,JSON "rauc status (detailed) json: via D-Bus" "
start_rauc_dbus_service \
--conf=${SHARNESS_TEST_DIRECTORY}/test.conf \
--override-boot-slot=system0 &&
test_when_finished stop_rauc_dbus_service &&
rauc status --detailed --output-format=json
"
test_expect_success SERVICE,JSON "rauc status (detailed) json-pretty: via D-Bus" "
start_rauc_dbus_service \
--conf=${SHARNESS_TEST_DIRECTORY}/test.conf \
--override-boot-slot=system0 &&
test_when_finished stop_rauc_dbus_service &&
rauc status --detailed --output-format=json-pretty
"
test_expect_success SERVICE "rauc status invalid: via D-Bus" "
start_rauc_dbus_service \
--conf=${SHARNESS_TEST_DIRECTORY}/test.conf \
--override-boot-slot=system0 &&
test_when_finished stop_rauc_dbus_service &&
test_must_fail rauc status --output-format=invalid
"
"""

def test_rauc_status_json(rauc_service, rauc_dbus_service):

# Test callling 'rauc status'
out, err, exitcode = run("rauc status --detailed --output-format=json")

assert exitcode == 0
assert json.loads(out)


def test_rauc_status_json_pretty(rauc_service, rauc_dbus_service):

# Test callling 'rauc status'
out, err, exitcode = run("rauc status --detailed --output-format=json-pretty")

assert exitcode == 0
assert json.loads(out)


def test_rauc_status_invalid(rauc_service, rauc_dbus_service):

# Test callling 'rauc status'
out, err, exitcode = run("rauc status --detailed --output-format=invalid")

assert exitcode == 1
assert "Unknown output format" in err

0 comments on commit d147d48

Please sign in to comment.