aboutsummaryrefslogtreecommitdiff
path: root/src/tests/test-modem-helpers.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-03-09 23:34:19 -0800
committerDan Williams <dcbw@redhat.com>2010-03-09 23:34:19 -0800
commit46ec3bdb47cbc0c40f39bb139783dedc5d3c9986 (patch)
tree48519aa5ccdffa9dd2ede1a0c42506e8826cc538 /src/tests/test-modem-helpers.c
parent658d3d572dc5313d815d9b8ab09c6b563fcbc8bf (diff)
gsm: fix CREG/CGREG parsing with multiple responses
When a modem sends both CREG and CGREG in the same response packet, the parser was failing to correctly distinguish which response was being parsed, since the string passed to g_regex_match() is the whole response including both CREG + CGREG.
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r--src/tests/test-modem-helpers.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index 980c4ae7..addeee3e 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -670,6 +670,25 @@ test_cgreg2_f3607gw_unsolicited (void *f, gpointer d)
test_creg_match ("Ericsson F3607gw CGREG=2", FALSE, reply, data, &result);
}
+static void
+test_creg_cgreg_multi_unsolicited (void *f, gpointer d)
+{
+ TestData *data = (TestData *) d;
+ const char *reply = "\r\n+CREG: 5\r\n\r\n+CGREG: 0\r\n";
+ const CregResult result = { 5, 0, 0, -1, 1, FALSE};
+
+ test_creg_match ("Multi CREG/CGREG", FALSE, reply, data, &result);
+}
+
+static void
+test_creg_cgreg_multi2_unsolicited (void *f, gpointer d)
+{
+ TestData *data = (TestData *) d;
+ const char *reply = "\r\n+CGREG: 0\r\n\r\n+CREG: 5\r\n";
+ const CregResult result = { 0, 0, 0, -1, 1, TRUE};
+
+ test_creg_match ("Multi CREG/CGREG #2", FALSE, reply, data, &result);
+}
static TestData *
test_data_new (void)
@@ -753,6 +772,9 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_solicited, data));
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_unsolicited, data));
+ g_test_suite_add (suite, TESTCASE (test_creg_cgreg_multi_unsolicited, data));
+ g_test_suite_add (suite, TESTCASE (test_creg_cgreg_multi2_unsolicited, data));
+
result = g_test_run ();
test_data_free (data);