Skip to content

Commit 3dcefbb

Browse files
jukkarnashif
authored andcommitted
samples: net: echo-server: Generate coverage report
Add "sample quit" shell command which can be used to stop the sample application and allows the generation of coverage report. Fixes #21099 Signed-off-by: Jukka Rissanen <[email protected]>
1 parent e83b079 commit 3dcefbb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

samples/net/sockets/echo_server/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ CONFIG_NET_MAX_CONTEXTS=10
3434

3535
# Network shell
3636
CONFIG_NET_SHELL=y
37+
CONFIG_SHELL=y
3738

3839
# Network application options and configuration
3940
CONFIG_NET_CONFIG_SETTINGS=y

samples/net/sockets/echo_server/src/echo-server.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ LOG_MODULE_REGISTER(net_echo_server_sample, LOG_LEVEL_DBG);
1313
#include <zephyr.h>
1414
#include <linker/sections.h>
1515
#include <errno.h>
16+
#include <shell/shell.h>
1617

1718
#include <net/net_core.h>
1819
#include <net/tls_credentials.h>
@@ -82,6 +83,24 @@ static void init_app(void)
8283
init_vlan();
8384
}
8485

86+
static int cmd_sample_quit(const struct shell *shell,
87+
size_t argc, char *argv[])
88+
{
89+
quit();
90+
91+
return 0;
92+
}
93+
94+
SHELL_STATIC_SUBCMD_SET_CREATE(sample_commands,
95+
SHELL_CMD(quit, NULL,
96+
"Quit the sample application\n",
97+
cmd_sample_quit),
98+
SHELL_SUBCMD_SET_END
99+
);
100+
101+
SHELL_CMD_REGISTER(sample, &sample_commands,
102+
"Sample application commands", NULL);
103+
85104
void main(void)
86105
{
87106
init_app();

0 commit comments

Comments
 (0)