Skip to content

Commit f5f205d

Browse files
committed
tests: shell: Add shell_set_bypass test
Add a test to the shell testsuite for validating shell_set_bypass. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent cfc64dd commit f5f205d

File tree

1 file changed

+28
-0
lines changed
  • tests/subsys/shell/shell/src

1 file changed

+28
-0
lines changed

tests/subsys/shell/shell/src/main.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
*/
1111

12+
#include <string.h>
1213
#include <zephyr/kernel.h>
1314
#include <zephyr/ztest.h>
1415

@@ -344,6 +345,33 @@ ZTEST(sh, test_shell_fprintf)
344345
"Expected string to contain '%s', got '%s'", expect, buf);
345346
}
346347

348+
static void test_bypass_cb(const struct shell *sh, uint8_t *data, size_t len,
349+
void *user_data)
350+
{
351+
ARG_UNUSED(sh);
352+
ARG_UNUSED(data);
353+
ARG_UNUSED(len);
354+
ARG_UNUSED(user_data);
355+
}
356+
357+
ZTEST(sh, test_shell_set_bypass)
358+
{
359+
const struct shell *sh = shell_backend_dummy_get_ptr();
360+
uint8_t user_data;
361+
362+
zassert_not_null(sh, "Failed to get shell backend");
363+
364+
shell_set_bypass(sh, test_bypass_cb, &user_data);
365+
366+
zassert_equal_ptr(sh->ctx->bypass, test_bypass_cb, "Bypass callback not stored");
367+
zassert_equal_ptr(sh->ctx->bypass_user_data, &user_data, "User data pointer not stored");
368+
369+
shell_set_bypass(sh, NULL, NULL);
370+
371+
zassert_is_null(sh->ctx->bypass, "Bypass callback not cleared");
372+
zassert_is_null(sh->ctx->bypass_user_data, "User data pointer not cleared");
373+
}
374+
347375
#define RAW_ARG "aaa \"\" bbb"
348376
#define CMD_MAND_1_OPT_RAW_NAME cmd_mand_1_opt_raw
349377

0 commit comments

Comments
 (0)