From 9b3771778fc25a0c8233c489a24e86fcdbd3eece Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 18 May 2023 20:52:09 +0200 Subject: [PATCH] tests/sys/shell_coreclk: add test application for shell_cmd_coreclk --- tests/sys/shell_coreclk/Makefile | 12 ++++++++ tests/sys/shell_coreclk/main.c | 30 +++++++++++++++++++ tests/sys/shell_coreclk/tests/01-run.py | 38 +++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 tests/sys/shell_coreclk/Makefile create mode 100644 tests/sys/shell_coreclk/main.c create mode 100755 tests/sys/shell_coreclk/tests/01-run.py diff --git a/tests/sys/shell_coreclk/Makefile b/tests/sys/shell_coreclk/Makefile new file mode 100644 index 0000000000..6e26e314be --- /dev/null +++ b/tests/sys/shell_coreclk/Makefile @@ -0,0 +1,12 @@ +include ../Makefile.sys_common + +USEMODULE += shell +USEMODULE += shell_cmd_coreclk + +# Use a terminal that does not introduce extra characters into the stream. +RIOT_TERMINAL ?= socat + +include $(RIOTBASE)/Makefile.include + +# the test script skips tests if socat is not used +$(call target-export-variables,$(RIOT_TERMINAL),RIOT_TERMINAL) diff --git a/tests/sys/shell_coreclk/main.c b/tests/sys/shell_coreclk/main.c new file mode 100644 index 0000000000..1303bb5920 --- /dev/null +++ b/tests/sys/shell_coreclk/main.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 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. + */ + +/** + * @file + * @brief Test for the coreclk shell command + * + * @author Alexandre Abadie + * + */ + +#include + +#include "shell.h" + +int main(void) +{ + /* define buffer to be used by the shell */ + char line_buf[SHELL_DEFAULT_BUFSIZE]; + + /* start shell */ + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + + return 0; +} diff --git a/tests/sys/shell_coreclk/tests/01-run.py b/tests/sys/shell_coreclk/tests/01-run.py new file mode 100755 index 0000000000..e8cbc3a645 --- /dev/null +++ b/tests/sys/shell_coreclk/tests/01-run.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2023 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 + +EXPECTED_HELP = ( + 'Command Description', + '---------------------------------------', + 'coreclk Print the CPU frequency', +) +BOARD = os.environ['BOARD'] + + +def testfunc(child): + # avoid sending an extra empty line on native. + if BOARD == 'native': + child.crlf = '\n' + + # check the help + child.sendline('help') + for line in EXPECTED_HELP: + child.expect_exact(line) + + # coreclk + child.sendline('coreclk') + child.expect(r"core clock: \d+ Hz") + + +if __name__ == "__main__": + sys.exit(run(testfunc))