mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/periph_cpuid: add automatic test script
This commit is contained in:
parent
5febd49c84
commit
9b02b9d042
@ -3,3 +3,24 @@ include ../Makefile.tests_common
|
||||
FEATURES_REQUIRED = periph_cpuid
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Determine the CPUID_LEN based on the current architecture or CPU used in the
|
||||
# build system.
|
||||
ifneq (,$(filter arch_esp32,$(FEATURES_USED)))
|
||||
CPUID_LEN = 7
|
||||
endif
|
||||
ifneq (,$(filter cc2538 efm32 ezr32wg nrf5%,$(CPU)))
|
||||
CPUID_LEN = 8
|
||||
endif
|
||||
ifneq (,$(filter cc26x0 lpc1768 sam%,$(CPU)))
|
||||
CPUID_LEN = 16
|
||||
endif
|
||||
ifneq (,$(filter fe310 kinetis stm32%,$(CPU)))
|
||||
CPUID_LEN = 12
|
||||
endif
|
||||
|
||||
# Use 4 as default as it is the minimum for all supported CPUs.
|
||||
CPUID_LEN ?= 4
|
||||
|
||||
# Export CPUID_LEN env variable to the Python script.
|
||||
export CPUID_LEN
|
||||
|
25
tests/periph_cpuid/tests/01-run.py
Executable file
25
tests/periph_cpuid/tests/01-run.py
Executable file
@ -0,0 +1,25 @@
|
||||
#!/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
|
||||
|
||||
|
||||
CPUID_LEN = int(os.getenv('CPUID_LEN') or 4)
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact('Test for the CPUID driver')
|
||||
child.expect_exact('This test is reading out the CPUID of the platforms CPU')
|
||||
expected = 'CPUID:' + CPUID_LEN * r' 0x[0-9a-fA-F]{2}'
|
||||
child.expect(expected)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run(testfunc))
|
Loading…
Reference in New Issue
Block a user