diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-10-15 10:40:11 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-10-15 11:14:40 +0200 |
commit | 345922caa10fc86dad181ccd83239af1f43fd30e (patch) | |
tree | 1900b7bc68b9c0c72044fb17cb5766d1c000cca6 /plugins/simtech/tests/test-modem-helpers-simtech.c | |
parent | 395b22178c4f6dd24d552e82d2d46dfb24c65297 (diff) |
simtech: handle non-standard '+CRING' URCs
The SIM7600E ends up emitting these URCs with too many <CR>s, and the
generic +CRING handler doesn't catch them, interfering with other
actions, e.g.:
$ sudo mmcli --call 1 --accept
error: couldn't accept the call: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Failed: Couldn't accept the call: Unhandled response '+CRING: VOICE
+CRING: VOICE''
Diffstat (limited to 'plugins/simtech/tests/test-modem-helpers-simtech.c')
-rw-r--r-- | plugins/simtech/tests/test-modem-helpers-simtech.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/simtech/tests/test-modem-helpers-simtech.c b/plugins/simtech/tests/test-modem-helpers-simtech.c index 3092e936..0274ae92 100644 --- a/plugins/simtech/tests/test-modem-helpers-simtech.c +++ b/plugins/simtech/tests/test-modem-helpers-simtech.c @@ -193,6 +193,47 @@ test_voice_call_end_duration_urc (void) /*****************************************************************************/ +static void +common_test_cring_urc (const gchar *urc, + const gchar *expected_type) +{ + GError *error = NULL; + GRegex *cring_regex = NULL; + GMatchInfo *match_info = NULL; + gchar *type; + gboolean result; + + cring_regex = mm_simtech_get_cring_urc_regex (); + + /* Same matching logic as done in MMSerialPortAt when processing URCs! */ + result = g_regex_match_full (cring_regex, urc, -1, 0, 0, &match_info, &error); + g_assert_no_error (error); + g_assert (result); + + type = g_match_info_fetch (match_info, 1); + g_assert (type); + + g_assert_cmpstr (type, ==, expected_type); + + g_match_info_free (match_info); + g_regex_unref (cring_regex); + g_free (type); +} + +static void +test_cring_urc_two_crs (void) +{ + common_test_cring_urc ("\r\r\n+CRING: VOICE\r\r\n", "VOICE"); +} + +static void +test_cring_urc_one_cr (void) +{ + common_test_cring_urc ("\r\n+CRING: VOICE\r\n", "VOICE"); +} + +/*****************************************************************************/ + void _mm_log (const char *loc, const char *func, @@ -227,5 +268,8 @@ int main (int argc, char **argv) g_test_add_func ("/MM/simtech/voicecall/urc/end", test_voice_call_end_urc); g_test_add_func ("/MM/simtech/voicecall/urc/end-duration", test_voice_call_end_duration_urc); + g_test_add_func ("/MM/simtech/cring/urc/two-crs", test_cring_urc_two_crs); + g_test_add_func ("/MM/simtech/cring/urc/one-cr", test_cring_urc_one_cr); + return g_test_run (); } |