diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-21 13:05:27 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-03-21 13:40:01 +0100 |
commit | d01bca493dad933b9df51bec1254c79089ffa1c7 (patch) | |
tree | b570511cc337354a26a275c2594f80949fafb8ff /plugins/cinterion/tests | |
parent | 5285e958abcd734de73a13011b5243bcfdf4d20c (diff) |
cinterion: make sure FALSE sets GError in provcfg_response_to_cid()
The g_regex_match_full() method may return FALSE without setting the
GError, so that case needs to be considered.
Reported by Jan Mazura.
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/347
Diffstat (limited to 'plugins/cinterion/tests')
-rw-r--r-- | plugins/cinterion/tests/test-modem-helpers-cinterion.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/plugins/cinterion/tests/test-modem-helpers-cinterion.c index 25e08473..8ea7d909 100644 --- a/plugins/cinterion/tests/test-modem-helpers-cinterion.c +++ b/plugins/cinterion/tests/test-modem-helpers-cinterion.c @@ -1602,45 +1602,57 @@ test_smoni_response_to_signal (void) typedef struct { const gchar *str; MMCinterionModemFamily modem_family; - gdouble expected_cid; + gboolean success; + guint expected_cid; } ProvcfgResponseTest; - static const ProvcfgResponseTest provcfg_response_tests[] = { { .str = "^SCFG: \"MEopMode/Prov/Cfg\",\"vdfde\"", .modem_family = MM_CINTERION_MODEM_FAMILY_DEFAULT, + .success = TRUE, .expected_cid = 1, }, { .str = "* ^SCFG: \"MEopMode/Prov/Cfg\",\"attus\"", .modem_family = MM_CINTERION_MODEM_FAMILY_IMT, + .success = TRUE, .expected_cid = 1, }, { .str = "* ^SCFG: \"MEopMode/Prov/Cfg\",\"2\"", .modem_family = MM_CINTERION_MODEM_FAMILY_DEFAULT, + .success = TRUE, .expected_cid = 3, }, { .str = "* ^SCFG: \"MEopMode/Prov/Cfg\",\"vzwdcus\"", .modem_family = MM_CINTERION_MODEM_FAMILY_DEFAULT, + .success = TRUE, .expected_cid = 3, }, { .str = "* ^SCFG: \"MEopMode/Prov/Cfg\",\"tmode\"", .modem_family = MM_CINTERION_MODEM_FAMILY_DEFAULT, + .success = TRUE, .expected_cid = 2, }, { .str = "* ^SCFG: \"MEopMode/Prov/Cfg\",\"fallback*\"", .modem_family = MM_CINTERION_MODEM_FAMILY_DEFAULT, + .success = TRUE, .expected_cid = 1, + }, + { + /* commas not allowed by the regex */ + .str = "* ^SCFG: \"MEopMode/Prov/Cfg\",\"something,with,commas\"", + .modem_family = MM_CINTERION_MODEM_FAMILY_DEFAULT, + .success = FALSE, } }; @@ -1660,9 +1672,14 @@ test_provcfg_response (void) NULL, &cid, &error); - g_assert_no_error (error); - g_assert (result); - g_assert_cmpuint (cid, ==, provcfg_response_tests[i].expected_cid); + if (provcfg_response_tests[i].success) { + g_assert_no_error (error); + g_assert (result); + g_assert_cmpuint (cid, ==, provcfg_response_tests[i].expected_cid); + } else { + g_assert (error); + g_assert (!result); + } } } |