Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/suit_update/test: use 'suit seq_no' to get version #17973

Merged
merged 3 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/pythonlibs/riotctrl_shell/sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def version(self, timeout=-1, async_=False):

class SUITSequenceNoParser(ShellInteractionParser):
def __init__(self):
self.c_seq_no = re.compile(r"seq_no: (?P<seq_no>\d+)$")
self.c_seq_no = re.compile(r"seq_no: (?P<seq_no>0x[0-9a-fA-F:]+)$")

def parse(self, cmd_output):
for line in cmd_output.splitlines():
m = self.c_seq_no.search(line)
if m is not None:
return int(m.group("seq_no"))
return int(m.group("seq_no"), 16)
return None


Expand Down
4 changes: 2 additions & 2 deletions dist/pythonlibs/riotctrl_shell/tests/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def test_suit_fetch():
def test_suit_sequence_no():
rc = init_ctrl(
output="""
seq_no: 123456789
seq_no: 0x12345678
"""
)
si = riotctrl_shell.sys.SUIT(rc)
res = si.suit_sequence_no()
parser = riotctrl_shell.sys.SUITSequenceNoParser()
# mock just returns last input
assert parser.parse(res) == 123456789
assert parser.parse(res) == 0x12345678
19 changes: 9 additions & 10 deletions examples/suit_update/tests-with-config/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,28 @@ def get_reachable_addr(child):
return "[{}]".format(client_addr)


def app_version(child):
def seq_no(child):
utils.test_utils_interactive_sync_shell(child, 5, 1)
# get version of currently running image
# "Image Version: 0x00000000"
child.sendline('riotboot-hdr')
child.expect(r"Image Version: (?P<app_ver>0x[0-9a-fA-F:]+)\r\n")
app_ver = int(child.match.group("app_ver"), 16)
# "seq_no: 0x00000000"
child.sendline('suit seq_no')
child.expect(r"seq_no: (?P<seq_no>0x[0-9a-fA-F:]+)\r\n")
app_ver = int(child.match.group("seq_no"), 16)
return app_ver


def running_slot(child):
utils.test_utils_interactive_sync_shell(child, 5, 1)
# get version of currently running image
# "Image Version: 0x00000000"

child.sendline('current-slot')
child.expect(r"Running from slot (\d+)\r\n")
slot = int(child.match.group(1))
return slot


def _test_invalid_version(child, client, app_ver):
publish(TMPDIR.name, COAP_HOST, app_ver - 1)
notify(COAP_HOST, client, app_ver - 1)
publish(TMPDIR.name, COAP_HOST, app_ver)
notify(COAP_HOST, client, app_ver)
child.expect_exact("suit_coap: trigger received")
child.expect_exact("suit: verifying manifest signature")
child.expect_exact("seq_nr <= running image")
Expand Down Expand Up @@ -191,7 +190,7 @@ def _test_suit_command_is_there(child):

def testfunc(child):
# Get current app_ver
current_app_ver = app_version(child)
current_app_ver = seq_no(child)
# Verify client is reachable and get address
client = get_reachable_addr(child)

Expand Down
2 changes: 1 addition & 1 deletion sys/shell/commands/sc_suit.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int _suit_handler(int argc, char **argv)
else if (strcmp(argv[1], "seq_no") == 0) {
uint32_t seq_no = 0;
suit_storage_get_highest_seq_no(&seq_no);
printf("seq_no: %" PRIu32 "\n", seq_no);
printf("seq_no: 0x%08" PRIx32 "\n", seq_no);
}
else {
_print_usage(argv);
Expand Down