Skip to content

Commit

Permalink
REMOVEME
Browse files Browse the repository at this point in the history
for compile tests
  • Loading branch information
gschorcht committed Dec 19, 2021
1 parent 48f59a1 commit 446053c
Show file tree
Hide file tree
Showing 14 changed files with 876 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .murdock
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ get_supported_boards() {
for board in $boards
do
echo $board
done | $(_greplist $BOARDS)
done | $(_greplist $BOARDS) | $(_greplist esp8266-esp-12x)
}

get_supported_toolchains() {
Expand Down
24 changes: 24 additions & 0 deletions tests/shell_ztimer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
DEVELHELP=0
include ../Makefile.tests_common

USEMODULE += app_metadata
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps

USEMODULE += ztimer_msec

# for z1, socat doesn't work (unknown reason)
ifeq (z1, $(BOARD))
RIOT_TERMINAL ?= pyterm
endif

# Use a terminal that does not introduce extra characters into the stream.
RIOT_TERMINAL ?= socat

APP_SHELL_FMT ?= NONE

include $(RIOTBASE)/Makefile.include

# the test script skips tests if socat is not used
$(call target-export-variables,$(RIOT_TERMINAL),RIOT_TERMINAL)
8 changes: 8 additions & 0 deletions tests/shell_ztimer/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-leonardo \
arduino-nano \
arduino-uno \
atmega328p \
atmega328p-xplained-mini \
#
14 changes: 14 additions & 0 deletions tests/shell_ztimer/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This application shows how to use own or the system shell commands. In order to use
the system shell commands:

1. Additionally to the module: shell, shell_commands,
the module for the corresponding system command is to include, e.g.
module ps for the ps command (cf. the Makefile in the application root
directory).
2. Start the shell like this:
2.1 reserve buffer:
char line_buf[SHELL_DEFAULT_BUFSIZE];
2.1a run shell only with system commands:
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
2.1b run shell with provided commands in addition to system commands:
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
6 changes: 6 additions & 0 deletions tests/shell_ztimer/app.config.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_MODULE_APP_METADATA=y
CONFIG_MODULE_SHELL=y
CONFIG_MODULE_SHELL_COMMANDS=y
CONFIG_MODULE_PS=y

CONFIG_MODULE_ZTIMER_MSEC=y
150 changes: 150 additions & 0 deletions tests/shell_ztimer/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* Copyright (C) 2013 Kaspar Schleiser <kaspar@schleiser.de>
* Copyright (C) 2013 Freie Universität Berlin
*
* 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 shows how to set up own and use the system shell commands.
* By typing help in the serial console, all the supported commands
* are listed.
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
*
*/

#include <stdio.h>
#include <string.h>

#include "shell_commands.h"
#include "shell.h"

#if MODULE_STDIO_RTT
#include "xtimer.h"
#endif

#if MODULE_SHELL_HOOKS
void shell_post_readline_hook(void)
{
puts("shell_post_readline_hook");
}

void shell_pre_command_hook(int argc, char **argv)
{
(void)argc;
(void)argv;
puts("shell_pre_command_hook");
}

void shell_post_command_hook(int ret, int argc, char **argv)
{
(void)ret;
(void)argc;
(void)argv;
puts("shell_post_command_hook");
}
#endif

static int print_teststart(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("[TEST_START]\n");

return 0;
}

static int print_testend(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("[TEST_END]\n");

return 0;
}

static int print_echo(int argc, char **argv)
{
for (int i = 0; i < argc; ++i) {
printf("\"%s\"", argv[i]);
}
puts("");

return 0;
}

static int print_shell_bufsize(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("%d\n", SHELL_DEFAULT_BUFSIZE);

return 0;
}

static int print_empty(int argc, char **argv)
{
(void)argc;
(void)argv;
return 0;
}

static const shell_command_t shell_commands[] = {
{ "bufsize", "Get the shell's buffer size", print_shell_bufsize },
{ "start_test", "starts a test", print_teststart },
{ "end_test", "ends a test", print_testend },
{ "echo", "prints the input command", print_echo },
{ "empty", "print nothing on command", print_empty },
{ NULL, NULL, NULL }
};

static int _xfa_test1(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("[XFA TEST 1 OK]\n");

return 0;
}

static int _xfa_test2(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("[XFA TEST 2 OK]\n");

return 0;
}

/* Add above commands to the shell commands XFA using helper macro.
* Intentionally reversed order to test linker script based alphanumeric
* ordering. */
SHELL_COMMAND(xfa_test2, "xfa test command 2", _xfa_test2);
SHELL_COMMAND(xfa_test1, "xfa test command 1", _xfa_test1);

int main(void)
{
printf("test_shell.\n");

/* define buffer to be used by the shell */
char line_buf[SHELL_DEFAULT_BUFSIZE];

/* define own shell commands */
shell_run_once(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);

puts("shell exited");

/* Restart the shell after the previous one exits, so that we can test
* Ctrl-D exit */
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);

/* or use only system shell commands */
/* shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); */

return 0;
}
Loading

0 comments on commit 446053c

Please sign in to comment.