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

tests/sys/shell_coreclk: add test application for shell_cmd_coreclk

This commit is contained in:
Alexandre Abadie 2023-05-18 20:52:09 +02:00
parent 19ce68dd2e
commit 9b3771778f
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
3 changed files with 80 additions and 0 deletions

View File

@ -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)

View File

@ -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 <alexandre.abadie@inria.fr>
*
*/
#include <stdio.h>
#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;
}

View File

@ -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))