Skip to content

Commit

Permalink
modem: chat: Add test for runtime chat scripts
Browse files Browse the repository at this point in the history
This commit adds a test to ensure chat scripts can
be created and modified at runtime.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
  • Loading branch information
Bjarki Arge Andreasen committed Sep 16, 2023
1 parent 353985e commit a0efd27
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/subsys/modem/modem_chat/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,51 @@ ZTEST(modem_chat, test_script_run_sync_abort)
"Echo script should time out and return -EAGAIN");
}

ZTEST(modem_chat, test_script_run_dynamic_script_sync)
{
char match[] = "AT";
char separators[] = ",";
char request[] = "AT";
char name[] = "Dynamic";

struct modem_chat_match stack_response_match = {
.match = NULL,
.match_size = 0,
.separators = NULL,
.separators_size = 0,
.wildcards = false,
.partial = false,
.callback = NULL,
};

struct modem_chat_script_chat stack_script_chat = {
.request = NULL,
.response_matches = &stack_response_match,
.response_matches_size = 1,
.timeout = 0,
};

struct modem_chat_script stack_script = {
.name = name,
.script_chats = &stack_script_chat,
.script_chats_size = 1,
.abort_matches = NULL,
.abort_matches_size = 0,
.callback = NULL,
.timeout = 1,
};

stack_response_match.match = match;
stack_response_match.match_size = strlen(match);
stack_response_match.separators = separators;
stack_response_match.separators_size = strlen(match);
stack_script_chat.request = request;
stack_script_chat.request_size = strlen(request);

modem_backend_mock_prime(&mock, &at_echo_transaction);
zassert_ok(modem_chat_run_script(&cmd, &stack_script), "Failed to run script");
}

/*************************************************************************************************/
/* Test suite */
/*************************************************************************************************/
Expand Down

0 comments on commit a0efd27

Please sign in to comment.