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

Merge pull request #10812 from aabadie/pr/tests/periph_rtc_test

tests/periph_rtc: add automatic python test script
This commit is contained in:
Leandro Lanzieri 2019-01-18 15:02:23 +01:00 committed by GitHub
commit 4c4087cef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,50 @@
#!/usr/bin/env python3
# Copyright (C) 2019 Inria
#
# 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 os
import sys
from testrunner import run
BOARD = os.getenv('BOARD', 'native')
DATE_PATTERN = r'\d{4}\-\d{2}\-\d{2} \d{2}\:\d{2}\:\d{2}'
def testfunc(child):
child.expect(r'This test will display \'Alarm\!\' every 2 seconds '
r'for (\d{1}) times')
alarm_count = int(child.match.group(1))
child.expect(r' Setting clock to ({})'.format(DATE_PATTERN))
clock_set = child.match.group(1)
if BOARD == 'native':
child.expect(r'.*rtc_set_time: not implemented')
child.expect(r'Clock value is now ({})'.format(DATE_PATTERN))
clock_value = child.match.group(1)
if BOARD != 'native':
# Set clock is not implemented for native board so no need to compare
# clock values
assert clock_set == clock_value
child.expect(r' Setting alarm to ({})'.format(DATE_PATTERN))
alarm_set = child.match.group(1)
if BOARD == 'native':
child.expect(r'.*rtc_set_alarm: not implemented')
child.expect(r' Alarm is set to ({})'.format(DATE_PATTERN))
alarm_value = child.match.group(1)
if BOARD != 'native':
# Set alarm is not implemented for native board so no need to compare
# alarm values
assert alarm_set == alarm_value
if BOARD != 'native':
for _ in range(alarm_count):
child.expect_exact('Alarm!')
if __name__ == "__main__":
sys.exit(run(testfunc))