[PATCH 2/5] allow optional whitespace in +CGDCONT response; add testcase for Thuraya XT
Thomas Sailer
sailer at sailer.dynip.lugs.ch
Thu Feb 11 12:45:09 UTC 2016
From: Thomas Sailer <t.sailer at alumni.ethz.ch>
Signed-off-by: Thomas Sailer <t.sailer at alumni.ethz.ch>
---
src/mm-modem-helpers.c | 4 ++--
src/tests/test-modem-helpers.c | 14 ++++++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index cf80a40..bb7837e 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -867,7 +867,7 @@ mm_3gpp_parse_cgdcont_test_response (const gchar *response,
return NULL;
}
- r = g_regex_new ("\\+CGDCONT:\\s*\\((\\d+)-?(\\d+)?\\),\\(?\"(\\S+)\"",
+ r = g_regex_new ("\\+CGDCONT:\\s*\\(\\s*(\\d+)\\s*-?\\s*(\\d+)?\\s*\\)\\s*,\\s*\\(?\"(\\S+)\"",
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
0, &inner_error);
g_assert (r != NULL);
@@ -955,7 +955,7 @@ mm_3gpp_parse_cgdcont_read_response (const gchar *reply,
return NULL;
list = NULL;
- r = g_regex_new ("\\+CGDCONT:\\s*(\\d+)\\s*,([^,\\)]*),([^,\\)]*),([^,\\)]*)",
+ r = g_regex_new ("\\+CGDCONT:\\s*(\\d+)\\s*,([^, \\)]*)\\s*,([^, \\)]*)\\s*,([^, \\)]*)",
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
0, &inner_error);
if (r) {
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index c0a23da..4dc5662 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -1808,6 +1808,19 @@ test_cgdcont_test_response_single_context (void *f, gpointer d)
test_cgdcont_test_results ("Single Context", reply, &expected[0], G_N_ELEMENTS (expected));
}
+static void
+test_cgdcont_test_response_thuraya (void *f, gpointer d)
+{
+ const gchar *reply =
+ "+CGDCONT: ( 1 ) , \"IP\" ,,, (0-2),(0-3)\r\n"
+ "+CGDCONT: , \"PPP\" ,,, (0-2),(0-3)\r\n";
+ static MM3gppPdpContextFormat expected[] = {
+ { 1, 1, MM_BEARER_IP_FAMILY_IPV4 }
+ };
+
+ test_cgdcont_test_results ("Thuraya", reply, &expected[0], G_N_ELEMENTS (expected));
+}
+
/*****************************************************************************/
/* Test CGDCONT read responses */
@@ -2750,6 +2763,7 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_multiple, NULL));
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_multiple_and_ignore, NULL));
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_single_context, NULL));
+ g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_thuraya, NULL));
g_test_suite_add (suite, TESTCASE (test_cgdcont_read_response_nokia, NULL));
g_test_suite_add (suite, TESTCASE (test_cgdcont_read_response_samsung, NULL));
--
2.5.0
More information about the ModemManager-devel
mailing list