aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dan@ioncontrol.co>2025-04-13 19:56:56 -0500
committerDan Williams <dan@ioncontrol.co>2025-04-13 19:58:30 -0500
commit6b6997362b5530708725c16c80ef36cd21609f20 (patch)
tree13fa0f2417a8cbb9af5f54bf4b99cf2ee7db5072
parent8fc3f44e763c388ee8b976ab367758a1bf9052d3 (diff)
modem-helpers-cinterion: allow spaces in ^SXRAT test response
^SXRAT: (0-6), (0,2,3), (0,2,3) Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/974 Signed-off-by: Dan Williams <dan@ioncontrol.co>
-rw-r--r--src/plugins/cinterion/mm-modem-helpers-cinterion.c2
-rw-r--r--src/plugins/cinterion/tests/test-modem-helpers-cinterion.c33
2 files changed, 34 insertions, 1 deletions
diff --git a/src/plugins/cinterion/mm-modem-helpers-cinterion.c b/src/plugins/cinterion/mm-modem-helpers-cinterion.c
index b2ef89a9..53f4cff4 100644
--- a/src/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/src/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -794,7 +794,7 @@ mm_cinterion_parse_sxrat_test (const gchar *response,
return FALSE;
}
- r = g_regex_new ("\\^SXRAT:\\s*\\(([^\\)]*)\\),\\(([^\\)]*)\\)(,\\(([^\\)]*)\\))?(?:\\r\\n)?",
+ r = g_regex_new ("\\^SXRAT:\\s*\\(([^\\)]*)\\),\\s*\\(([^\\)]*)\\)(,\\s*\\(([^\\)]*)\\))?(?:\\r\\n)?",
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
0, NULL);
diff --git a/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c
index e5857ede..2f6e3d10 100644
--- a/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c
+++ b/src/plugins/cinterion/tests/test-modem-helpers-cinterion.c
@@ -1827,6 +1827,38 @@ test_sxrat_response_els61 (void)
}
static void
+test_sxrat_response_pls63_w (void)
+{
+ GArray *expected_rat;
+ GArray *expected_pref1;
+ GArray *expected_pref2;
+ const guint vals[] = { 0, 2, 3 };
+ guint val;
+ const gchar *response =
+ "^SXRAT: (0-6), (0,2,3), (0,2,3)\r\n"
+ "\r\n";
+
+ expected_rat = g_array_sized_new (FALSE, FALSE, sizeof (guint), 7);
+ for (val = 0; val < 7; val++)
+ g_array_append_val (expected_rat, val);
+
+ expected_pref1 = g_array_sized_new (FALSE, FALSE, sizeof (guint), 3);
+ g_array_append_vals (expected_pref1, &vals, 3);
+
+ expected_pref2 = g_array_sized_new (FALSE, FALSE, sizeof (guint), 3);
+ g_array_append_vals (expected_pref2, &vals, 3);
+
+ common_test_sxrat (response,
+ expected_rat,
+ expected_pref1,
+ expected_pref2);
+
+ g_array_unref (expected_rat);
+ g_array_unref (expected_pref1);
+ g_array_unref (expected_pref2);
+}
+
+static void
test_sxrat_response_other (void)
{
GArray *expected_rat;
@@ -2177,6 +2209,7 @@ int main (int argc, char **argv)
g_test_add_func ("/MM/cinterion/sgauth", test_sgauth_response);
g_test_add_func ("/MM/cinterion/sxrat", test_sxrat);
g_test_add_func ("/MM/cinterion/sxrat/response/els61", test_sxrat_response_els61);
+ g_test_add_func ("/MM/cinterion/sxrat/response/pls63w", test_sxrat_response_pls63_w);
g_test_add_func ("/MM/cinterion/sxrat/response/other", test_sxrat_response_other);
g_test_add_func ("/MM/cinterion/cops/only-mode-2g", test_cops_only_mode_2g);
g_test_add_func ("/MM/cinterion/cops/only-mode-3g", test_cops_only_mode_3g);