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-trackunit committed Sep 15, 2023
1 parent 67d4c83 commit 03d18d4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/subsys/modem/modem_chat/src/main.c
Expand Up @@ -566,6 +566,44 @@ 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 = match,
.match_size = strlen(match),
.separators = separators,
.separators_size = strlen(separators),
.wildcards = false,
.partial = false,
.callback = NULL,
};

struct modem_chat_script_chat stack_script_chat = {
.request = request,
.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,
};

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 03d18d4

Please sign in to comment.