tests: modem: Add tests for sync script run functions
This commit adds tests to validate the behavior of the new script run functions. Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit is contained in:
parent
c9bc07a4f3
commit
add09f389b
1 changed files with 47 additions and 0 deletions
|
@ -193,6 +193,34 @@ MODEM_CHAT_SCRIPT_CMDS_DEFINE(
|
|||
|
||||
MODEM_CHAT_SCRIPT_DEFINE(script_partial, script_partial_cmds, abort_matches, on_script_result, 4);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/* Small echo script and mock transactions */
|
||||
/*************************************************************************************************/
|
||||
static const uint8_t at_echo_data[] = {'A', 'T', '\r', '\n'};
|
||||
static const struct modem_backend_mock_transaction at_echo_transaction = {
|
||||
.get = at_echo_data,
|
||||
.get_size = sizeof(at_echo_data),
|
||||
.put = at_echo_data,
|
||||
.put_size = sizeof(at_echo_data),
|
||||
};
|
||||
|
||||
static const uint8_t at_echo_error_data[] = {'E', 'R', 'R', 'O', 'R', ' ', '1', '\r', '\n'};
|
||||
static const struct modem_backend_mock_transaction at_echo_error_transaction = {
|
||||
.get = at_echo_data,
|
||||
.get_size = sizeof(at_echo_data),
|
||||
.put = at_echo_error_data,
|
||||
.put_size = sizeof(at_echo_error_data),
|
||||
};
|
||||
|
||||
MODEM_CHAT_MATCH_DEFINE(at_match, "AT", "", NULL);
|
||||
|
||||
MODEM_CHAT_SCRIPT_CMDS_DEFINE(
|
||||
script_echo_cmds,
|
||||
MODEM_CHAT_SCRIPT_CMD_RESP("AT", at_match),
|
||||
);
|
||||
|
||||
MODEM_CHAT_SCRIPT_DEFINE(script_echo, script_echo_cmds, abort_matches, on_script_result, 4);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/* Script responses */
|
||||
/*************************************************************************************************/
|
||||
|
@ -519,6 +547,25 @@ ZTEST(modem_chat, test_script_with_partial_matches)
|
|||
"Script sent too many requests");
|
||||
}
|
||||
|
||||
ZTEST(modem_chat, test_script_run_sync_complete)
|
||||
{
|
||||
modem_backend_mock_prime(&mock, &at_echo_transaction);
|
||||
zassert_ok(modem_chat_run_script(&cmd, &script_echo), "Failed to run echo script");
|
||||
}
|
||||
|
||||
ZTEST(modem_chat, test_script_run_sync_timeout)
|
||||
{
|
||||
zassert_equal(modem_chat_run_script(&cmd, &script_echo), -EAGAIN,
|
||||
"Failed to run echo script");
|
||||
}
|
||||
|
||||
ZTEST(modem_chat, test_script_run_sync_abort)
|
||||
{
|
||||
modem_backend_mock_prime(&mock, &at_echo_error_transaction);
|
||||
zassert_equal(modem_chat_run_script(&cmd, &script_echo), -EAGAIN,
|
||||
"Echo script should time out and return -EAGAIN");
|
||||
}
|
||||
|
||||
/*************************************************************************************************/
|
||||
/* Test suite */
|
||||
/*************************************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue