1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/riotboot: add basic automatic test in python

Co-authored-by: Federico Pellegrin <fede@evolware.org>
This commit is contained in:
Francisco Acosta 2018-12-05 01:12:14 +01:00 committed by Kaspar Schleiser
parent f1c57b21ec
commit 66911d6ce1
2 changed files with 45 additions and 1 deletions

View File

@ -14,5 +14,8 @@ This test should foremost give you an overview how to use riotboot:
riotboot and the RIOT image with headers included. This should boot
as a normal application.
In this test two modules `riot_hdr` and `slot_util` are used to showcase
In this test two modules `riotboot_hdr` and `riotboot_slot` are used to showcase
the access to riotboot shared functions.
- `make test` can be executed to run the automatic Python test that checks
basic functionalities of riotboot

41
tests/riotboot/tests/01-run.py Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env python3
# Copyright (C) 2018 Federico Pellegrin <fede@evolware.org>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import sys
from testrunner import run
def testfunc(child):
# Ask for current slot, should be 0 (riotboot slot)
child.sendline("curslotnr")
child.expect_exact("Current slot=0")
child.expect('>')
# Ask for current slot header info and checks for basic output integrity
child.sendline("curslothdr")
# Magic number is "RIOT" (always in little endian)
child.expect_exact("Image magic_number: 0x544f4952")
# Other info is hardware/app dependant so we just check basic compliance
child.expect("Image Version: 0x[0-9a-fA-F]{8}")
child.expect("Image start address: 0x[0-9a-fA-F]{8}")
child.expect("Header chksum: 0x[0-9a-fA-F]{8}")
child.expect('>')
# Ask for address of slot 0
child.sendline("getslotaddr 0")
child.expect("Slot 0 address=0x[0-9a-fA-F]{8}")
child.expect('>')
# Ask for data of all slots
child.sendline("dumpaddrs")
child.expect("slot 0: metadata: 0x[0-9a-fA-F]{1,8} image: 0x[0-9a-fA-F]{8}")
child.expect('>')
if __name__ == "__main__":
sys.exit(run(testfunc))