aboutsummaryrefslogtreecommitdiff
path: root/src/tests/test-modem-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-03-25 00:47:50 +0100
committerAleksander Morgado <aleksander@aleksander.es>2017-04-18 18:08:57 +0200
commit973c7d0970d5151f1b5d40b01ce0f2334c226b7c (patch)
treebb449bd4fb1b30852ca602b04fe540fdf5703061 /src/tests/test-modem-helpers.c
parent75d9c0bc9542e04887e8b73fd0238d97d7ad263a (diff)
helpers: new parser for AT+IFC=?
Instead of having the parser return separate list of supported flow controls for TE and TA, we simplify it by only returning those settings that apply to both TE and TA. This logic isn't perfect either, though, as some settings (e.g. '3' in TE in some modems, specifying a different XON/XOFF behavior) may not have a corresponding setting in the other end. The most common cases we care about (i.e. standard XON/XOFF, RTS/CTS) should be properly reported with this logic.
Diffstat (limited to 'src/tests/test-modem-helpers.c')
-rw-r--r--src/tests/test-modem-helpers.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index ae0eec99..b59c5900 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -33,6 +33,93 @@
g_assert_cmpfloat (fabs (val1 - val2), <, tolerance)
/*****************************************************************************/
+/* Test IFC=? responses */
+
+static void
+test_ifc_response (const gchar *str,
+ const MMFlowControl expected)
+{
+ MMFlowControl mask;
+ GError *error = NULL;
+
+ mask = mm_parse_ifc_test_response (str, &error);
+ g_assert_no_error (error);
+ g_assert_cmpuint (mask, ==, expected);
+}
+
+static void
+test_ifc_response_all_simple (void)
+{
+ test_ifc_response ("+IFC (0,1,2),(0,1,2)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_XON_XOFF | MM_FLOW_CONTROL_RTS_CTS));
+}
+
+static void
+test_ifc_response_all_groups (void)
+{
+ test_ifc_response ("+IFC (0-2),(0-2)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_XON_XOFF | MM_FLOW_CONTROL_RTS_CTS));
+}
+
+static void
+test_ifc_response_none_only (void)
+{
+ test_ifc_response ("+IFC (0),(0)", MM_FLOW_CONTROL_NONE);
+}
+
+static void
+test_ifc_response_xon_xoff_only (void)
+{
+ test_ifc_response ("+IFC (1),(1)", MM_FLOW_CONTROL_XON_XOFF);
+}
+
+static void
+test_ifc_response_rts_cts_only (void)
+{
+ test_ifc_response ("+IFC (2),(2)", MM_FLOW_CONTROL_RTS_CTS);
+}
+
+static void
+test_ifc_response_no_xon_xoff (void)
+{
+ test_ifc_response ("+IFC (0,2),(0,2)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_RTS_CTS));
+}
+
+static void
+test_ifc_response_no_xon_xoff_in_ta (void)
+{
+ test_ifc_response ("+IFC (0,1,2),(0,2)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_RTS_CTS));
+}
+
+static void
+test_ifc_response_no_xon_xoff_in_te (void)
+{
+ test_ifc_response ("+IFC (0,2),(0,1,2)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_RTS_CTS));
+}
+
+static void
+test_ifc_response_no_rts_cts_simple (void)
+{
+ test_ifc_response ("+IFC (0,1),(0,1)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_XON_XOFF));
+}
+
+static void
+test_ifc_response_no_rts_cts_groups (void)
+{
+ test_ifc_response ("+IFC (0-1),(0-1)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_XON_XOFF));
+}
+
+static void
+test_ifc_response_all_simple_and_unknown (void)
+{
+ test_ifc_response ("+IFC (0,1,2,3),(0,1,2)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_XON_XOFF | MM_FLOW_CONTROL_RTS_CTS));
+}
+
+static void
+test_ifc_response_all_groups_and_unknown (void)
+{
+ test_ifc_response ("+IFC (0-3),(0-2)", (MM_FLOW_CONTROL_NONE | MM_FLOW_CONTROL_XON_XOFF | MM_FLOW_CONTROL_RTS_CTS));
+}
+
+/*****************************************************************************/
/* Test WS46=? responses */
static void
@@ -3536,6 +3623,19 @@ int main (int argc, char **argv)
suite = g_test_get_root ();
reg_data = reg_test_data_new ();
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_all_simple, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_all_groups, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_none_only, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_xon_xoff_only, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_rts_cts_only, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_no_xon_xoff, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_no_xon_xoff_in_ta, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_no_xon_xoff_in_te, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_no_rts_cts_simple, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_no_rts_cts_groups, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_all_simple_and_unknown, NULL));
+ g_test_suite_add (suite, TESTCASE (test_ifc_response_all_groups_and_unknown, NULL));
+
g_test_suite_add (suite, TESTCASE (test_ws46_response_generic_2g3g4g, NULL));
g_test_suite_add (suite, TESTCASE (test_ws46_response_generic_2g3g, NULL));
g_test_suite_add (suite, TESTCASE (test_ws46_response_generic_2g3g_v2, NULL));