[PATCH v2 2/3] qcdm: add IPv6 nvram setting to test suite

Bjørn Mork bjorn at mork.no
Thu Dec 5 03:43:19 PST 2013


Signed-off-by: Bjørn Mork <bjorn at mork.no>
---
 libqcdm/tests/test-qcdm-com.c |   55 +++++++++++++++++++++++++++++++++++++++++
 libqcdm/tests/test-qcdm-com.h |    2 ++
 libqcdm/tests/test-qcdm.c     |    1 +
 3 files changed, 58 insertions(+)

diff --git a/libqcdm/tests/test-qcdm-com.c b/libqcdm/tests/test-qcdm-com.c
index 369e7d4..8615284 100644
--- a/libqcdm/tests/test-qcdm-com.c
+++ b/libqcdm/tests/test-qcdm-com.c
@@ -698,6 +698,61 @@ test_com_read_hybrid_pref (void *f, void *data)
 }
 
 void
+test_com_read_ipv6_enabled (void *f, void *data)
+{
+    TestComData *d = data;
+    gboolean success;
+    int err = QCDM_SUCCESS;
+    char buf[512];
+    guint8 pref;
+    const char *msg;
+    gint len;
+    QcdmResult *result;
+    gsize reply_len;
+
+    len = qcdm_cmd_nv_get_ipv6_enabled_new (buf, sizeof (buf));
+    g_assert (len > 0);
+
+    /* Send the command */
+    success = send_command (d, buf, len);
+    g_assert (success);
+
+    /* Get a response */
+    reply_len = wait_reply (d, buf, sizeof (buf));
+
+    /* Parse the response into a result structure */
+    result = qcdm_cmd_nv_get_ipv6_enabled_result (buf, reply_len, &err);
+    if (!result) {
+        if (   err == -QCDM_ERROR_NVCMD_FAILED
+            || err == -QCDM_ERROR_RESPONSE_BAD_PARAMETER
+            || err == -QCDM_ERROR_NV_ERROR_INACTIVE
+            || err == -QCDM_ERROR_NV_ERROR_BAD_PARAMETER)
+            return;
+        g_assert_cmpint (err, ==, QCDM_SUCCESS);
+    }
+
+    g_print ("\n");
+
+    err = qcdm_result_get_u8 (result, QCDM_CMD_NV_GET_IPV6_ENABLED_ITEM_ENABLED, &pref);
+    g_assert_cmpint (err, ==, QCDM_SUCCESS);
+
+    switch (pref) {
+    case QCDM_CMD_NV_IPV6_ENABLED_OFF:
+        msg = "disabled";
+        break;
+    case QCDM_CMD_NV_IPV6_ENABLED_ON:
+        msg = "enabled";
+        break;
+    default:
+        msg = "unknown";
+        break;
+    }
+    g_message ("%s: IPv6 preference: 0x%02X (%s)", __func__, pref, msg);
+
+    qcdm_result_unref (result);
+}
+
+void
 test_com_read_hdr_rev_pref (void *f, void *data)
 {
     TestComData *d = data;
diff --git a/libqcdm/tests/test-qcdm-com.h b/libqcdm/tests/test-qcdm-com.h
index 341d44e..2a6d58f 100644
--- a/libqcdm/tests/test-qcdm-com.h
+++ b/libqcdm/tests/test-qcdm-com.h
@@ -35,6 +35,8 @@ void test_com_read_mode_pref (void *f, void *data);
 
 void test_com_read_hybrid_pref (void *f, void *data);
 
+void test_com_read_ipv6_enabled (void *f, void *data);
+
 void test_com_read_hdr_rev_pref (void *f, void *data);
 
 void test_com_status (void *f, void *data);
diff --git a/libqcdm/tests/test-qcdm.c b/libqcdm/tests/test-qcdm.c
index 8448364..2a21522 100644
--- a/libqcdm/tests/test-qcdm.c
+++ b/libqcdm/tests/test-qcdm.c
@@ -100,6 +100,7 @@ int main (int argc, char **argv)
         g_test_suite_add (suite, TESTCASE (test_com_read_roam_pref, data->com_data));
         g_test_suite_add (suite, TESTCASE (test_com_read_mode_pref, data->com_data));
         g_test_suite_add (suite, TESTCASE (test_com_read_hybrid_pref, data->com_data));
+        g_test_suite_add (suite, TESTCASE (test_com_read_ipv6_enabled, data->com_data));
         g_test_suite_add (suite, TESTCASE (test_com_read_hdr_rev_pref, data->com_data));
         g_test_suite_add (suite, TESTCASE (test_com_status, data->com_data));
         g_test_suite_add (suite, TESTCASE (test_com_sw_version, data->com_data));
-- 
1.7.10.4



More information about the ModemManager-devel mailing list