Skip to content

Commit be98483

Browse files
committed
tests: lib: lte_lc_api: Enable missing subscriptions
Enabled CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS and CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS in unit tests. The notifications were tested by the UT, but not the notification subscriptions. Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
1 parent 9398c96 commit be98483

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

tests/lib/lte_lc_api/prj.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ CONFIG_LTE_LC_RAI_MODULE=y
3535
CONFIG_LTE_LC_MODEM_SLEEP_MODULE=y
3636
CONFIG_LTE_LC_TAU_PRE_WARNING_MODULE=y
3737
CONFIG_LTE_LC_ENV_EVAL_MODULE=y
38+
39+
CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS=y
40+
CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS=y

tests/lib/lte_lc_api/src/lte_lc_api_test.c

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,20 @@ static int sys_init_helper(void)
371371
extern void on_modem_init(int err, void *ctx);
372372
extern void lte_lc_on_modem_cfun(int mode, void *ctx);
373373

374+
void enable_notifications(void)
375+
{
376+
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", EXIT_SUCCESS);
377+
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", EXIT_SUCCESS);
378+
if (IS_ENABLED(CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS)) {
379+
__mock_nrf_modem_at_printf_ExpectAndReturn("AT%XMODEMSLEEP=1,5000,1200000",
380+
EXIT_SUCCESS);
381+
}
382+
if (IS_ENABLED(CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS)) {
383+
__mock_nrf_modem_at_printf_ExpectAndReturn("AT%XT3412=1,5000,1200000",
384+
EXIT_SUCCESS);
385+
}
386+
}
387+
374388
/* Helper function to initialize LTE LC with the given firmware version. */
375389
void lte_lc_on_modem_init_with_firmware(const char *cgmr_resp, uint16_t cgmr_resp_len)
376390
{
@@ -609,8 +623,7 @@ void test_lte_lc_connect_success(void)
609623
__mock_nrf_modem_at_scanf_ExpectAndReturn("AT+CFUN?", "+CFUN: %hu", 1);
610624
__mock_nrf_modem_at_scanf_ReturnVarg_uint16(LTE_LC_FUNC_MODE_OFFLINE);
611625

612-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", 0);
613-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", 0);
626+
enable_notifications();
614627
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=1", 0);
615628

616629
/* AT commands triggered by lte_lc_offline() */
@@ -696,8 +709,7 @@ void test_lte_lc_connect_timeout_fail(void)
696709
__mock_nrf_modem_at_scanf_ExpectAndReturn("AT+CFUN?", "+CFUN: %hu", 1);
697710
__mock_nrf_modem_at_scanf_ReturnVarg_uint16(LTE_LC_FUNC_MODE_POWER_OFF);
698711

699-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", 0);
700-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", 0);
712+
enable_notifications();
701713
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=1", 0);
702714

703715
/* Modem switched back to original functional mode after the timeout */
@@ -750,8 +762,7 @@ void test_lte_lc_connect_cfun_normal_set_fail(void)
750762
__mock_nrf_modem_at_scanf_ExpectAndReturn("AT+CFUN?", "+CFUN: %hu", 1);
751763
__mock_nrf_modem_at_scanf_ReturnVarg_uint16(LTE_LC_FUNC_MODE_POWER_OFF);
752764

753-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", 0);
754-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", 0);
765+
enable_notifications();
755766
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=1", -NRF_ENOMEM);
756767

757768
ret = lte_lc_connect();
@@ -770,8 +781,7 @@ void test_lte_lc_connect_async_success(void)
770781
__mock_nrf_modem_at_scanf_ExpectAndReturn("AT+CFUN?", "+CFUN: %hu", 1);
771782
__mock_nrf_modem_at_scanf_ReturnVarg_uint16(LTE_LC_FUNC_MODE_OFFLINE);
772783

773-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", 0);
774-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", 0);
784+
enable_notifications();
775785
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=1", 0);
776786

777787
/* AT commands triggered by lte_lc_offline() */
@@ -842,8 +852,7 @@ void test_lte_lc_normal_success(void)
842852
{
843853
int ret;
844854

845-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", EXIT_SUCCESS);
846-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", EXIT_SUCCESS);
855+
enable_notifications();
847856
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=1", EXIT_SUCCESS);
848857
ret = lte_lc_normal();
849858
TEST_ASSERT_EQUAL(EXIT_SUCCESS, ret);
@@ -874,8 +883,7 @@ void test_lte_lc_normal_cfun_fail(void)
874883
{
875884
int ret;
876885

877-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", EXIT_SUCCESS);
878-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", EXIT_SUCCESS);
886+
enable_notifications();
879887
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=1", -NRF_ENOMEM);
880888
ret = lte_lc_normal();
881889
TEST_ASSERT_EQUAL(-EFAULT, ret);
@@ -921,12 +929,10 @@ void test_lte_lc_rx_only(void)
921929
{
922930
int ret;
923931

924-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", 0);
925-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", 0);
932+
enable_notifications();
926933
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=2", 0);
927934

928-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", 0);
929-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", 0);
935+
enable_notifications();
930936
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=1", 0);
931937

932938
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=4", 0);
@@ -2156,14 +2162,12 @@ void test_lte_lc_func_mode_set_all_modes(void)
21562162
int ret;
21572163
char at_cmd[12];
21582164

2159-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", EXIT_SUCCESS);
2160-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", EXIT_SUCCESS);
2165+
enable_notifications();
21612166
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=2", EXIT_SUCCESS);
21622167
ret = lte_lc_func_mode_set(LTE_LC_FUNC_MODE_RX_ONLY);
21632168
TEST_ASSERT_EQUAL(EXIT_SUCCESS, ret);
21642169

2165-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CEREG=5", EXIT_SUCCESS);
2166-
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CSCON=1", EXIT_SUCCESS);
2170+
enable_notifications();
21672171
__mock_nrf_modem_at_printf_ExpectAndReturn("AT+CFUN=21", EXIT_SUCCESS);
21682172
ret = lte_lc_func_mode_set(LTE_LC_FUNC_MODE_ACTIVATE_LTE);
21692173
TEST_ASSERT_EQUAL(EXIT_SUCCESS, ret);

tests/lib/lte_lc_api/testcase.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests:
2-
unity.lte_lc_api_test:
2+
lte_lc_api.unit_test:
33
sysbuild: true
44
tags:
55
- lte_lc_api

0 commit comments

Comments
 (0)