aboutsummaryrefslogtreecommitdiff
path: root/src/tests/test-modem-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-05-23 10:40:23 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-06-05 19:15:13 +0200
commit2acb125819fbda75dfc19b6c008137bb3b2ebb6e (patch)
tree7a2333781a9f6e8e21ba5c0ec32d7958e7c4acd7 /src/tests/test-modem-helpers.c
parentbd360aa029f27ad2fc9f8a937765f4c3e61581fd (diff)
modem-helpers: new CGDCONT=? test response parser
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r--src/tests/test-modem-helpers.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index 8453840b..0d245b29 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -1456,6 +1456,92 @@ test_cind_response_moto_v3m (void *f, gpointer d)
}
/*****************************************************************************/
+/* Test CGDCONT test responses */
+
+static void
+test_cgdcont_test_results (const gchar *desc,
+ const gchar *reply,
+ MM3gppPdpContextFormat *expected_results,
+ guint32 expected_results_len)
+{
+ GList *l;
+ GError *error = NULL;
+ GList *results;
+
+ g_print ("\nTesting %s +CGDCONT test response...\n", desc);
+
+ results = mm_3gpp_parse_cgdcont_test_response (reply, &error);
+ g_assert (results);
+ g_assert_no_error (error);
+ g_assert_cmpuint (g_list_length (results), ==, expected_results_len);
+
+ for (l = results; l; l = g_list_next (l)) {
+ MM3gppPdpContextFormat *format = l->data;
+ gboolean found = FALSE;
+ guint i;
+
+ for (i = 0; !found && i < expected_results_len; i++) {
+ MM3gppPdpContextFormat *expected;
+
+ expected = &expected_results[i];
+ if (format->pdp_type == expected->pdp_type) {
+ found = TRUE;
+
+ g_assert_cmpuint (format->min_cid, ==, expected->min_cid);
+ g_assert_cmpuint (format->max_cid, ==, expected->max_cid);
+ }
+ }
+
+ g_assert (found == TRUE);
+ }
+
+ mm_3gpp_pdp_context_format_list_free (results);
+}
+
+static void
+test_cgdcont_test_response_single (void *f, gpointer d)
+{
+ const gchar *reply = "+CGDCONT: (1-10),\"IP\",,,(0,1),(0,1)";
+ static MM3gppPdpContextFormat expected[] = {
+ { 1, 10, MM_BEARER_IP_FAMILY_IPV4 }
+ };
+
+ test_cgdcont_test_results ("Single", reply, &expected[0], G_N_ELEMENTS (expected));
+}
+
+static void
+test_cgdcont_test_response_multiple (void *f, gpointer d)
+{
+ const gchar *reply =
+ "+CGDCONT: (1-10),\"IP\",,,(0,1),(0,1)\r\n"
+ "+CGDCONT: (1-10),\"IPV6\",,,(0,1),(0,1)\r\n"
+ "+CGDCONT: (1-10),\"IPV4V6\",,,(0,1),(0,1)\r\n";
+ static MM3gppPdpContextFormat expected[] = {
+ { 1, 10, MM_BEARER_IP_FAMILY_IPV4 },
+ { 1, 10, MM_BEARER_IP_FAMILY_IPV6 },
+ { 1, 10, MM_BEARER_IP_FAMILY_IPV4V6 }
+ };
+
+ test_cgdcont_test_results ("Multiple", reply, &expected[0], G_N_ELEMENTS (expected));
+}
+
+static void
+test_cgdcont_test_response_multiple_and_ignore (void *f, gpointer d)
+{
+ const gchar *reply =
+ "+CGDCONT: (1-16),\"IP\",,,(0-2),(0-4)\r\n"
+ "+CGDCONT: (1-16),\"PPP\",,,(0-2),(0-4)\r\n"
+ "+CGDCONT: (1-16),\"IPV6\",,,(0-2),(0-4)\r\n";
+ static MM3gppPdpContextFormat expected[] = {
+ { 1, 16, MM_BEARER_IP_FAMILY_IPV4 },
+ /* PPP is ignored */
+ { 1, 16, MM_BEARER_IP_FAMILY_IPV6 }
+ };
+
+ test_cgdcont_test_results ("Multiple and Ignore", reply, &expected[0], G_N_ELEMENTS (expected));
+}
+
+/*****************************************************************************/
/* Test CGDCONT read responses */
static void
@@ -1950,6 +2036,10 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_cpms_response_cinterion, NULL));
+ g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_single, NULL));
+ 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_read_response_nokia, NULL));
g_test_suite_add (suite, TESTCASE (test_cgdcont_read_response_samsung, NULL));