File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
tests/subsys/shell/shell/src Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments