aboutsummaryrefslogtreecommitdiff
path: root/plugins/cinterion/tests/test-modem-helpers-cinterion.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-06-25 15:04:09 +0200
committerAleksander Morgado <aleksander@aleksander.es>2014-06-25 15:04:09 +0200
commit58d2806f4cceba6adde76d5df8f0781129bc7e1f (patch)
treeb677e64d2041029b2663953e7b2807a40fbea978 /plugins/cinterion/tests/test-modem-helpers-cinterion.c
parent08ecc147221b6f02c6db83d16b7c241efdfbc91e (diff)
cinterion: new 'AT+CNMI=?' parser helper
Diffstat (limited to 'plugins/cinterion/tests/test-modem-helpers-cinterion.c')
-rw-r--r--plugins/cinterion/tests/test-modem-helpers-cinterion.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/plugins/cinterion/tests/test-modem-helpers-cinterion.c
index 7604dfaa..26b07ab2 100644
--- a/plugins/cinterion/tests/test-modem-helpers-cinterion.c
+++ b/plugins/cinterion/tests/test-modem-helpers-cinterion.c
@@ -213,6 +213,123 @@ test_scfg_response_3g (void)
}
/*****************************************************************************/
+/* Test ^SCFG test */
+
+static void
+compare_arrays (const GArray *supported,
+ const GArray *expected)
+{
+ guint i;
+
+ g_assert_cmpuint (supported->len, ==, expected->len);
+ for (i = 0; i < supported->len; i++) {
+ gboolean found = FALSE;
+ guint j;
+
+ for (j = 0; j < expected->len && !found; j++) {
+ if (g_array_index (supported, guint, i) == g_array_index (expected, guint, j))
+ found = TRUE;
+ }
+ g_assert (found);
+ }
+}
+
+static void
+common_test_cnmi (const gchar *response,
+ const GArray *expected_mode,
+ const GArray *expected_mt,
+ const GArray *expected_bm,
+ const GArray *expected_ds,
+ const GArray *expected_bfr)
+{
+ GArray *supported_mode = NULL;
+ GArray *supported_mt = NULL;
+ GArray *supported_bm = NULL;
+ GArray *supported_ds = NULL;
+ GArray *supported_bfr = NULL;
+ GError *error = NULL;
+ gboolean res;
+
+ g_assert (expected_mode != NULL);
+ g_assert (expected_mt != NULL);
+ g_assert (expected_bm != NULL);
+ g_assert (expected_ds != NULL);
+ g_assert (expected_bfr != NULL);
+
+ res = mm_cinterion_parse_cnmi_test (response,
+ &supported_mode,
+ &supported_mt,
+ &supported_bm,
+ &supported_ds,
+ &supported_bfr,
+ &error);
+ g_assert_no_error (error);
+ g_assert (res == TRUE);
+ g_assert (supported_mode != NULL);
+ g_assert (supported_mt != NULL);
+ g_assert (supported_bm != NULL);
+ g_assert (supported_ds != NULL);
+ g_assert (supported_bfr != NULL);
+
+ compare_arrays (supported_mode, expected_mode);
+ compare_arrays (supported_mt, expected_mt);
+ compare_arrays (supported_bm, expected_bm);
+ compare_arrays (supported_ds, expected_ds);
+ compare_arrays (supported_bfr, expected_bfr);
+
+ g_array_unref (supported_mode);
+ g_array_unref (supported_mt);
+ g_array_unref (supported_bm);
+ g_array_unref (supported_ds);
+ g_array_unref (supported_bfr);
+}
+
+static void
+test_cnmi_phs8 (void)
+{
+ GArray *expected_mode;
+ GArray *expected_mt;
+ GArray *expected_bm;
+ GArray *expected_ds;
+ GArray *expected_bfr;
+ guint val;
+ const gchar *response =
+ "+CNMI: (0,1,2),(0,1),(0,2),(0),(1)\r\n"
+ "\r\n";
+
+ expected_mode = g_array_sized_new (FALSE, FALSE, sizeof (guint), 3);
+ val = 0, g_array_append_val (expected_mode, val);
+ val = 1, g_array_append_val (expected_mode, val);
+ val = 2, g_array_append_val (expected_mode, val);
+
+ expected_mt = g_array_sized_new (FALSE, FALSE, sizeof (guint), 2);
+ val = 0, g_array_append_val (expected_mt, val);
+ val = 1, g_array_append_val (expected_mt, val);
+
+ expected_bm = g_array_sized_new (FALSE, FALSE, sizeof (guint), 2);
+ val = 0, g_array_append_val (expected_bm, val);
+ val = 2, g_array_append_val (expected_bm, val);
+
+ expected_ds = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
+ val = 0, g_array_append_val (expected_ds, val);
+
+ expected_bfr = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
+ val = 1, g_array_append_val (expected_bfr, val);
+
+ common_test_cnmi (response,
+ expected_mode,
+ expected_mt,
+ expected_bm,
+ expected_ds,
+ expected_bfr);
+
+ g_array_unref (expected_mode);
+ g_array_unref (expected_mt);
+ g_array_unref (expected_bm);
+ g_array_unref (expected_ds);
+ g_array_unref (expected_bfr);}
+
+/*****************************************************************************/
/* Test ^SIND responses */
static void
@@ -281,6 +398,7 @@ int main (int argc, char **argv)
g_test_add_func ("/MM/cinterion/scfg/response/3g", test_scfg_response_3g);
g_test_add_func ("/MM/cinterion/scfg/response/2g", test_scfg_response_2g);
g_test_add_func ("/MM/cinterion/scfg/response/2g/ucs2", test_scfg_response_2g_ucs2);
+ g_test_add_func ("/MM/cinterion/cnmi/phs8", test_cnmi_phs8);
g_test_add_func ("/MM/cinterion/sind/response/simstatus", test_sind_response_simstatus);
return g_test_run ();