From 2f0187e07604086ee147945063221655fdb5c759 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Tue, 12 Nov 2019 10:42:23 +0100 Subject: [PATCH 1/3] tests/periph_cpuid: print CPUID_LEN --- tests/periph_cpuid/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/periph_cpuid/main.c b/tests/periph_cpuid/main.c index e6ad447714..b0d7806d54 100644 --- a/tests/periph_cpuid/main.c +++ b/tests/periph_cpuid/main.c @@ -32,6 +32,8 @@ int main(void) puts("Test for the CPUID driver"); puts("This test is reading out the CPUID of the platforms CPU\n"); + printf("CPUID_LEN: %u\n", CPUID_LEN); + /* read the CPUID */ cpuid_get(id); From a33857bf29706e28d33eb995a7b89e0c0823e4e6 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Tue, 12 Nov 2019 10:45:12 +0100 Subject: [PATCH 2/3] tests/periph_cpuid: read CPUID_LEN from app instead of environment --- tests/periph_cpuid/Makefile | 21 --------------------- tests/periph_cpuid/tests/01-run.py | 8 +++----- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/tests/periph_cpuid/Makefile b/tests/periph_cpuid/Makefile index 268f07cd86..dadc77f857 100644 --- a/tests/periph_cpuid/Makefile +++ b/tests/periph_cpuid/Makefile @@ -3,24 +3,3 @@ 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 diff --git a/tests/periph_cpuid/tests/01-run.py b/tests/periph_cpuid/tests/01-run.py index 3deb058bf8..becd6c775f 100755 --- a/tests/periph_cpuid/tests/01-run.py +++ b/tests/periph_cpuid/tests/01-run.py @@ -6,18 +6,16 @@ # 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(r'CPUID_LEN: (\d+)') + cpuid_len = int(child.match.group(1)) + expected = 'CPUID:' + cpuid_len * r' 0x[0-9a-fA-F]{2}' child.expect(expected) From 06f26146d0782ae5dc1546439d2672f1ac5db72d Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Tue, 12 Nov 2019 10:47:47 +0100 Subject: [PATCH 3/3] tests/periph_cpuid: check if correct number of bytes was printed --- tests/periph_cpuid/tests/01-run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/periph_cpuid/tests/01-run.py b/tests/periph_cpuid/tests/01-run.py index becd6c775f..fd3dbcc57a 100755 --- a/tests/periph_cpuid/tests/01-run.py +++ b/tests/periph_cpuid/tests/01-run.py @@ -15,8 +15,8 @@ def testfunc(child): child.expect_exact('This test is reading out the CPUID of the platforms CPU') child.expect(r'CPUID_LEN: (\d+)') cpuid_len = int(child.match.group(1)) - expected = 'CPUID:' + cpuid_len * r' 0x[0-9a-fA-F]{2}' - child.expect(expected) + child.expect(r'CPUID:( 0x[0-9a-fA-F]{2})+\s*$') + assert child.match.group(0).count(' 0x') == cpuid_len if __name__ == "__main__":