1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

Merge pull request #11448 from cladmi/pr/tests/periph_hwrng

tests/periph_hwrng: add automated python test
This commit is contained in:
Francisco 2019-04-30 08:43:00 -07:00 committed by GitHub
commit c073e56b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -4,4 +4,6 @@ FEATURES_REQUIRED = periph_hwrng
USEMODULE += xtimer
TEST_ON_CI_WHITELIST += all
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,37 @@
#!/usr/bin/env python3
# Copyright (C) 2019 Freie Universität Berlin
#
# 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.
"""periph_hwrng test
Automatic checking of the periph_hwrng firmware.
It checks the output is valid but not the number themselves.
"""
import sys
from testrunner import run
def testfunc(child):
"""Test generating several numbers
It prints hardware generated random bytes buffer from increasing size.
The generated random numbers are not checked.
"""
child.expect_exact('HWRNG peripheral driver test')
child.expect(r'This test will print from 1 to (\d+)'
' random bytes about every second')
iterations = int(child.match.group(1))
for num in range(1, iterations + 1):
child.expect_exact('generating %u random byte(s)' % num)
generated = 'Got:' + num * (r' 0x[0-9a-fA-F]{2}')
child.expect(generated)
if __name__ == "__main__":
sys.exit(run(testfunc))