diff options
author | Guido Günther <agx@sigxcpu.org> | 2014-02-05 08:38:23 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-02-05 08:38:23 +0100 |
commit | dc645b92b9a7db3076ae34986ac219d01677d124 (patch) | |
tree | 963a5d6ad150a88a2a8ab6d994d79d539e19383a /libqcdm/tests | |
parent | 87bd9deec22af69bb27226254803ac5c63b18d78 (diff) |
Imported Upstream version 0.4+git.20100624t180933.6e79d15upstream/0.4+git.20100624t180933.6e79d15
Diffstat (limited to 'libqcdm/tests')
-rw-r--r-- | libqcdm/tests/Makefile.am | 32 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-com.c | 1184 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-com.h | 51 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-crc.c | 65 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-crc.h | 25 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-escaping.c | 124 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-escaping.h | 26 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-result.c | 71 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-result.h | 26 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-utils.c | 86 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm-utils.h | 26 | ||||
-rw-r--r-- | libqcdm/tests/test-qcdm.c | 115 |
12 files changed, 1831 insertions, 0 deletions
diff --git a/libqcdm/tests/Makefile.am b/libqcdm/tests/Makefile.am new file mode 100644 index 0000000..eb38fdb --- /dev/null +++ b/libqcdm/tests/Makefile.am @@ -0,0 +1,32 @@ +INCLUDES = \ + -I$(top_srcdir)/libqcdm/src + +noinst_PROGRAMS = test-qcdm + +test_qcdm_SOURCES = \ + test-qcdm-crc.c \ + test-qcdm-crc.h \ + test-qcdm-escaping.c \ + test-qcdm-escaping.h \ + test-qcdm-utils.c \ + test-qcdm-utils.h \ + test-qcdm-com.c \ + test-qcdm-com.h \ + test-qcdm-result.c \ + test-qcdm-result.h \ + test-qcdm.c + +test_qcdm_CPPFLAGS = \ + $(MM_CFLAGS) + +test_qcdm_LDADD = \ + $(top_builddir)/libqcdm/src/libqcdm.la \ + $(MM_LIBS) + +if WITH_TESTS + +check-local: test-qcdm + $(abs_builddir)/test-qcdm + +endif + diff --git a/libqcdm/tests/test-qcdm-com.c b/libqcdm/tests/test-qcdm-com.c new file mode 100644 index 0000000..f41d249 --- /dev/null +++ b/libqcdm/tests/test-qcdm-com.c @@ -0,0 +1,1184 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <glib.h> +#include <string.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <termios.h> +#include <unistd.h> +#include <stdlib.h> + +#include "test-qcdm-com.h" +#include "com.h" +#include "utils.h" +#include "result.h" +#include "commands.h" +#include "error.h" + +/************************************************************/ + +static const char * +prev_to_string (guint8 prev) +{ + switch (prev) { + case QCDM_CDMA_PREV_IS_95: + return "IS-95"; + case QCDM_CDMA_PREV_IS_95A: + return "IS-95A"; + case QCDM_CDMA_PREV_IS_95A_TSB74: + return "IS-95A TSB-74"; + case QCDM_CDMA_PREV_IS_95B_PHASE1: + return "IS-95B Phase I"; + case QCDM_CDMA_PREV_IS_95B_PHASE2: + return "IS-95B Phase II"; + case QCDM_CDMA_PREV_IS2000_REL0: + return "IS-2000 Release 0"; + case QCDM_CDMA_PREV_IS2000_RELA: + return "IS-2000 Release A"; + default: + break; + } + return "unknown"; +} + +static const char * +band_class_to_string (guint8 band_class) +{ + switch (band_class) { + case QCDM_CDMA_BAND_CLASS_0_CELLULAR_800: + return "0 (Cellular 800)"; + case QCDM_CDMA_BAND_CLASS_1_PCS: + return "1 (PCS 1900)"; + case QCDM_CDMA_BAND_CLASS_2_TACS: + return "2 (TACS)"; + case QCDM_CDMA_BAND_CLASS_3_JTACS: + return "3 (JTACS)"; + case QCDM_CDMA_BAND_CLASS_4_KOREAN_PCS: + return "4 (Korean PCS)"; + case QCDM_CDMA_BAND_CLASS_5_NMT450: + return "5 (NMT-450)"; + case QCDM_CDMA_BAND_CLASS_6_IMT2000: + return "6 (IMT-2000)"; + case QCDM_CDMA_BAND_CLASS_7_CELLULAR_700: + return "7 (Cellular 700)"; + case QCDM_CDMA_BAND_CLASS_8_1800: + return "8 (1800 MHz)"; + case QCDM_CDMA_BAND_CLASS_9_900: + return "9 (1900 MHz)"; + case QCDM_CDMA_BAND_CLASS_10_SECONDARY_800: + return "10 (Secondary 800 MHz)"; + case QCDM_CDMA_BAND_CLASS_11_PAMR_400: + return "11 (PAMR 400)"; + case QCDM_CDMA_BAND_CLASS_12_PAMR_800: + return "11 (PAMR 800)"; + default: + break; + } + return "unknown"; +} + +static const char * +hdr_rev_to_string (guint8 hdr_rev) +{ + switch (hdr_rev) { + case QCDM_HDR_REV_0: + return "0"; + case QCDM_HDR_REV_A: + return "A"; + default: + break; + } + return "unknown"; +} + +/************************************************************/ + +typedef struct { + char *port; + int fd; + struct termios old_t; + gboolean debug; +} TestComData; + +gpointer +test_com_setup (const char *port) +{ + TestComData *d; + int ret; + + d = g_malloc0 (sizeof (TestComData)); + g_assert (d); + + if (getenv ("SERIAL_DEBUG")) + d->debug = TRUE; + + errno = 0; + d->fd = open (port, O_RDWR | O_EXCL | O_NONBLOCK | O_NOCTTY); + if (d->fd < 0) + g_warning ("%s: open failed: (%d) %s", port, errno, strerror (errno)); + g_assert (d->fd >= 0); + + ret = ioctl (d->fd, TIOCEXCL); + if (ret) { + g_warning ("%s: lock failed: (%d) %s", port, errno, strerror (errno)); + close (d->fd); + d->fd = -1; + } + g_assert (ret == 0); + + ret = ioctl (d->fd, TCGETA, &d->old_t); + if (ret) { + g_warning ("%s: old termios failed: (%d) %s", port, errno, strerror (errno)); + close (d->fd); + d->fd = -1; + } + g_assert (ret == 0); + + d->port = g_strdup (port); + return d; +} + +void +test_com_teardown (gpointer user_data) +{ + TestComData *d = user_data; + + g_assert (d); + + g_free (d->port); + close (d->fd); + g_free (d); +} + +static void +print_buf (const char *detail, const char *buf, gsize len) +{ + int i = 0; + gboolean newline = FALSE; + + g_print ("%s (%zu) ", detail, len); + for (i = 0; i < len; i++) { + g_print ("0x%02x ", buf[i] & 0xFF); + if (((i + 1) % 12) == 0) { + g_print ("\n"); + newline = TRUE; + } else + newline = FALSE; + } + + if (!newline) + g_print ("\n"); +} + +static gboolean +send_command (TestComData *d, char *buf, gsize len) +{ + int status; + int eagain_count = 1000; + gsize i = 0; + + if (d->debug) + print_buf (">>>", buf, len); + + while (i < len) { + errno = 0; + status = write (d->fd, &buf[i], 1); + if (status < 0) { + if (errno == EAGAIN) { + eagain_count--; + if (eagain_count <= 0) + return FALSE; + } else + g_assert (errno == 0); + } else + i++; + + usleep (1000); + } + + return TRUE; +} + +static gsize +wait_reply (TestComData *d, char *buf, gsize len) +{ + fd_set in; + int result; + struct timeval timeout = { 1, 0 }; + char readbuf[1024]; + ssize_t bytes_read; + int total = 0, retries = 0; + gsize decap_len = 0; + + FD_ZERO (&in); + FD_SET (d->fd, &in); + result = select (d->fd + 1, &in, NULL, NULL, &timeout); + if (result != 1 || !FD_ISSET (d->fd, &in)) + return 0; + + do { + errno = 0; + bytes_read = read (d->fd, &readbuf[total], 1); + if ((bytes_read == 0) || (errno == EAGAIN)) { + /* Haven't gotten the async control char yet */ + if (retries > 20) + return 0; /* 2 seconds, give up */ + + /* Otherwise wait a bit and try again */ + usleep (100000); + retries++; + continue; + } else if (bytes_read == 1) { + gboolean more = FALSE, success; + gsize used = 0; + + total++; + decap_len = 0; + success = dm_decapsulate_buffer (readbuf, total, buf, len, &decap_len, &used, &more); + + /* Discard used data */ + if (used > 0) { + total -= used; + memmove (readbuf, &readbuf[used], total); + } + + if (success && !more) { + /* Success; we have a packet */ + break; + } + } else { + /* Some error occurred */ + return 0; + } + } while (total < sizeof (readbuf)); + + if (d->debug) { + print_buf ("<<<", readbuf, total); + print_buf ("D<<", buf, decap_len); + } + + return decap_len; +} + +void +test_com_port_init (void *f, void *data) +{ + TestComData *d = data; + GError *error = NULL; + gboolean success; + + success = qcdm_port_setup (d->fd, &error); + if (!success) { + g_warning ("%s: error setting up port: (%d) %s", + d->port, + error ? error->code : -1, + error && error->message ? error->message : "(unknown)"); + } + g_assert (success); +} + +void +test_com_version_info (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[512]; + const char *str; + gint len; + QCDMResult *result; + gsize reply_len; + + len = qcdm_cmd_version_info_new (buf, sizeof (buf), NULL); + g_assert (len == 4); + + /* 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_version_info_result (buf, reply_len, &error); + g_assert (result); + + g_print ("\n"); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_VERSION_INFO_ITEM_COMP_DATE, &str); + g_message ("%s: Compiled Date: %s", __func__, str); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_VERSION_INFO_ITEM_COMP_TIME, &str); + g_message ("%s: Compiled Time: %s", __func__, str); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_VERSION_INFO_ITEM_RELEASE_DATE, &str); + g_message ("%s: Release Date: %s", __func__, str); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_VERSION_INFO_ITEM_RELEASE_TIME, &str); + g_message ("%s: Release Time: %s", __func__, str); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_VERSION_INFO_ITEM_MODEL, &str); + g_message ("%s: Model: %s", __func__, str); + + qcdm_result_unref (result); +} + +void +test_com_esn (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[512]; + const char *str; + gint len; + QCDMResult *result; + gsize reply_len; + + len = qcdm_cmd_esn_new (buf, sizeof (buf), NULL); + g_assert (len == 4); + + /* 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_esn_result (buf, reply_len, &error); + g_assert (result); + + g_print ("\n"); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_ESN_ITEM_ESN, &str); + g_message ("%s: ESN: %s", __func__, str); + + qcdm_result_unref (result); +} + +void +test_com_mdn (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[512]; + const char *str; + gint len; + QCDMResult *result; + gsize reply_len; + + len = qcdm_cmd_nv_get_mdn_new (buf, sizeof (buf), 0, NULL); + 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_mdn_result (buf, reply_len, &error); + if (!result) { + g_assert_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_NVCMD_FAILED); + return; + } + + g_print ("\n"); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_NV_GET_MDN_ITEM_MDN, &str); + g_message ("%s: MDN: %s", __func__, str); + + qcdm_result_unref (result); +} + +void +test_com_read_roam_pref (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[512]; + guint8 pref; + const char *msg; + gint len; + QCDMResult *result; + gsize reply_len; + + len = qcdm_cmd_nv_get_roam_pref_new (buf, sizeof (buf), 0, NULL); + 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_roam_pref_result (buf, reply_len, &error); + g_assert (result); + + g_print ("\n"); + + success = qcdm_result_get_uint8 (result, QCDM_CMD_NV_GET_ROAM_PREF_ITEM_ROAM_PREF, &pref); + g_assert (success); + + switch (pref) { + case QCDM_CMD_NV_ROAM_PREF_ITEM_ROAM_PREF_HOME_ONLY: + msg = "home only"; + break; + case QCDM_CMD_NV_ROAM_PREF_ITEM_ROAM_PREF_ROAM_ONLY: + msg = "roaming only"; + break; + case QCDM_CMD_NV_ROAM_PREF_ITEM_ROAM_PREF_AUTO: + msg = "automatic"; + break; + default: + g_assert_not_reached (); + } + g_message ("%s: Roam preference: 0x%02X (%s)", __func__, pref, msg); + + qcdm_result_unref (result); +} + +void +test_com_read_mode_pref (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[512]; + guint8 pref; + const char *msg; + gint len; + QCDMResult *result; + gsize reply_len; + + len = qcdm_cmd_nv_get_mode_pref_new (buf, sizeof (buf), 0, NULL); + 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_mode_pref_result (buf, reply_len, &error); + if (!result) { + g_assert_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_NVCMD_FAILED); + return; + } + + g_print ("\n"); + + success = qcdm_result_get_uint8 (result, QCDM_CMD_NV_GET_MODE_PREF_ITEM_MODE_PREF, &pref); + g_assert (success); + + switch (pref) { + case QCDM_CMD_NV_MODE_PREF_ITEM_MODE_PREF_1X_ONLY: + msg = "1X only"; + break; + case QCDM_CMD_NV_MODE_PREF_ITEM_MODE_PREF_HDR_ONLY: + msg = "HDR only"; + break; + case QCDM_CMD_NV_MODE_PREF_ITEM_MODE_PREF_AUTO: + msg = "automatic"; + break; + default: + msg = "unknown"; + break; + } + g_message ("%s: Mode preference: 0x%02X (%s)", __func__, pref, msg); + + qcdm_result_unref (result); +} + +void +test_com_status (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[100]; + const char *str, *detail; + gint len; + QCDMResult *result; + gsize reply_len; + guint32 n32; + guint8 n8; + + len = qcdm_cmd_cdma_status_new (buf, sizeof (buf), NULL); + g_assert (len == 4); + + /* 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_cdma_status_result (buf, reply_len, &error); + g_assert (result); + + g_print ("\n"); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_CDMA_STATUS_ITEM_ESN, &str); + g_message ("%s: ESN: %s", __func__, str); + + n32 = 0; + detail = NULL; + qcdm_result_get_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RF_MODE, &n32); + switch (n32) { + case QCDM_CMD_CDMA_STATUS_RF_MODE_ANALOG: + detail = "analog"; + break; + case QCDM_CMD_CDMA_STATUS_RF_MODE_CDMA_CELLULAR: + detail = "CDMA cellular"; + break; + case QCDM_CMD_CDMA_STATUS_RF_MODE_CDMA_PCS: + detail = "CDMA PCS"; + break; + case QCDM_CMD_CDMA_STATUS_RF_MODE_SLEEP: + detail = "sleep"; + break; + case QCDM_CMD_CDMA_STATUS_RF_MODE_GPS: + detail = "GPS"; + break; + case QCDM_CMD_CDMA_STATUS_RF_MODE_HDR: + detail = "HDR"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: CDMA RF Mode: %u (%s)", __func__, n32, detail); + + n32 = 0; + detail = NULL; + qcdm_result_get_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, &n32); + switch (n32) { + case QCDM_CMD_CDMA_STATUS_RX_STATE_ENTERING_CDMA: + detail = "entering CDMA"; + break; + case QCDM_CMD_CDMA_STATUS_RX_STATE_SYNC_CHANNEL: + detail = "sync channel"; + break; + case QCDM_CMD_CDMA_STATUS_RX_STATE_PAGING_CHANNEL: + detail = "paging channel"; + break; + case QCDM_CMD_CDMA_STATUS_RX_STATE_TRAFFIC_CHANNEL_INIT: + detail = "traffic channel init"; + break; + case QCDM_CMD_CDMA_STATUS_RX_STATE_TRAFFIC_CHANNEL: + detail = "traffic channel"; + break; + case QCDM_CMD_CDMA_STATUS_RX_STATE_EXITING_CDMA: + detail = "exiting CDMA"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: CDMA RX State: %u (%s)", __func__, n32, detail); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_ENTRY_REASON, &n32); + g_message ("%s: Entry Reason: %u", __func__, n32); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_CURRENT_CHANNEL, &n32); + g_message ("%s: Current Channel: %u", __func__, n32); + + n8 = 0; + qcdm_result_get_uint8 (result, QCDM_CMD_CDMA_STATUS_ITEM_CODE_CHANNEL, &n8); + g_message ("%s: Code Channel: %u", __func__, n8); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_PILOT_BASE, &n32); + g_message ("%s: Pilot Base: %u", __func__, n32); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_SID, &n32); + g_message ("%s: CDMA System ID: %u", __func__, n32); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_NID, &n32); + g_message ("%s: CDMA Network ID: %u", __func__, n32); + + qcdm_result_unref (result); +} + +void +test_com_sw_version (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[100]; + gint len; + QCDMResult *result; + gsize reply_len; + + len = qcdm_cmd_sw_version_new (buf, sizeof (buf), NULL); + g_assert (len == 4); + + /* 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_sw_version_result (buf, reply_len, &error); + + /* Recent devices don't appear to implement this command */ + g_assert (result == NULL); + g_assert_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_BAD_COMMAND); + +/* + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_SW_VERSION_ITEM_VERSION, &str); + g_message ("%s: SW Version: %s", __func__, str); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_SW_VERSION_ITEM_COMP_DATE, &str); + g_message ("%s: Compiled Date: %s", __func__, str); + + str = NULL; + qcdm_result_get_string (result, QCDM_CMD_SW_VERSION_ITEM_COMP_TIME, &str); + g_message ("%s: Compiled Time: %s", __func__, str); + + qcdm_result_unref (result); +*/ +} + +void +test_com_pilot_sets (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[256]; + gint len; + QCDMResult *result; + gsize reply_len; + guint32 num, i; + + len = qcdm_cmd_pilot_sets_new (buf, sizeof (buf), NULL); + g_assert (len == 4); + + /* 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_pilot_sets_result (buf, reply_len, &error); + g_assert (result); + + num = 0; + qcdm_cmd_pilot_sets_result_get_num (result, QCDM_CMD_PILOT_SETS_TYPE_ACTIVE, &num); + g_message ("%s: Active Pilots: %d", __func__, num); + for (i = 0; i < num; i++) { + guint32 pn_offset = 0, ecio = 0; + float db = 0; + + qcdm_cmd_pilot_sets_result_get_pilot (result, + QCDM_CMD_PILOT_SETS_TYPE_ACTIVE, + i, + &pn_offset, + &ecio, + &db); + g_message (" %d: PN offset %d", i, pn_offset); + g_message (" EC/IO %d (%.1f dB)", ecio, db); + } + + num = 0; + qcdm_cmd_pilot_sets_result_get_num (result, QCDM_CMD_PILOT_SETS_TYPE_CANDIDATE, &num); + g_message ("%s: Candidate Pilots: %d", __func__, num); + + num = 0; + qcdm_cmd_pilot_sets_result_get_num (result, QCDM_CMD_PILOT_SETS_TYPE_NEIGHBOR, &num); + g_message ("%s: Neighbor Pilots: %d", __func__, num); + + qcdm_result_unref (result); +} + +void +test_com_cm_subsys_state_info (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[100]; + gint len; + QCDMResult *result; + gsize reply_len; + guint32 n32; + const char *detail; + + len = qcdm_cmd_cm_subsys_state_info_new (buf, sizeof (buf), NULL); + g_assert (len == 7); + + /* 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_cm_subsys_state_info_result (buf, reply_len, &error); + g_assert (result); + + g_print ("\n"); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_CALL_STATE, &n32); + g_message ("%s: Call State: %u", __func__, n32); + + n32 = 0; + detail = NULL; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_OPERATING_MODE, &n32); + switch (n32) { + case QCDM_CMD_CM_SUBSYS_STATE_INFO_OPERATING_MODE_ONLINE: + detail = "online"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Operating Mode: %u (%s)", __func__, n32, detail); + + n32 = 0; + detail = NULL; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_SYSTEM_MODE, &n32); + switch (n32) { + case QCDM_CMD_CM_SUBSYS_STATE_INFO_SYSTEM_MODE_NO_SERVICE: + detail = "no service"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_SYSTEM_MODE_AMPS: + detail = "AMPS"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_SYSTEM_MODE_CDMA: + detail = "CDMA"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_SYSTEM_MODE_HDR: + detail = "HDR/EVDO"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_SYSTEM_MODE_WCDMA: + detail = "WCDMA"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: System Mode: %u (%s)", __func__, n32, detail); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_MODE_PREF, &n32); + switch (n32) { + case QCDM_CMD_CM_SUBSYS_STATE_INFO_MODE_PREF_DIGITAL_ONLY: + detail = "digital only"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_MODE_PREF_AUTO: + detail = "automatic"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_MODE_PREF_1X_ONLY: + detail = "1X only"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_MODE_PREF_HDR_ONLY: + detail = "HDR only"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Mode Preference: 0x%02X (%s)", __func__, n32 & 0xFF, detail); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_BAND_PREF, &n32); + g_message ("%s: Band Preference: %u", __func__, n32); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_ROAM_PREF, &n32); + switch (n32) { + case QCDM_CMD_CM_SUBSYS_STATE_INFO_ROAM_PREF_HOME_ONLY: + detail = "home only"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_ROAM_PREF_ROAM_ONLY: + detail = "roaming only"; + break; + case QCDM_CMD_CM_SUBSYS_STATE_INFO_ROAM_PREF_AUTO: + detail = "automatic"; + break; + default: + g_assert_not_reached (); + } + g_message ("%s: Roam Preference: 0x%02X (%s)", __func__, n32 & 0xFF, detail); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_SERVICE_DOMAIN_PREF, &n32); + g_message ("%s: Service Domain Preference: %u", __func__, n32); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_ACQ_ORDER_PREF, &n32); + g_message ("%s: Acquisition Order Preference: %u", __func__, n32); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_HYBRID_PREF, &n32); + g_message ("%s: Hybrid Preference: %u", __func__, n32); + + n32 = 0; + qcdm_result_get_uint32 (result, QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_NETWORK_SELECTION_PREF, &n32); + g_message ("%s: Network Selection Preference: %u", __func__, n32); + + qcdm_result_unref (result); +} + +void +test_com_hdr_subsys_state_info (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[100]; + gint len; + QCDMResult *result; + gsize reply_len; + guint8 num; + const char *detail; + + len = qcdm_cmd_hdr_subsys_state_info_new (buf, sizeof (buf), NULL); + g_assert (len == 7); + + /* Send the command */ + success = send_command (d, buf, len); + g_assert (success); + + /* Get a response */ + reply_len = wait_reply (d, buf, sizeof (buf)); + + g_print ("\n"); + + /* Parse the response into a result structure */ + result = qcdm_cmd_hdr_subsys_state_info_result (buf, reply_len, &error); + if (!result) { + /* 1x-only devices won't implement the HDR subsystem of course */ + g_assert_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_BAD_COMMAND); + g_message ("%s: device does not implement the HDR subsystem", __func__); + return; + } + g_assert (result); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_AT_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_INACTIVE: + detail = "inactive"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_ACQUISITION: + detail = "acquisition"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_SYNC: + detail = "sync"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_IDLE: + detail = "idle"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_ACCESS: + detail = "access"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_CONNECTED: + detail = "connected"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: AT State: %u (%s)", __func__, num, detail); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_SESSION_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_CLOSED: + detail = "closed"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_SETUP: + detail = "setup"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_AT_INIT: + detail = "AT init"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_AN_INIT: + detail = "AN init"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_OPEN: + detail = "open"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_CLOSING: + detail = "closing"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Session State: %u (%s)", __func__, num, detail); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ALMP_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_INACTIVE: + detail = "inactive"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_INIT: + detail = "init"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_IDLE: + detail = "idle"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_CONNECTED: + detail = "connected"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: ALMP State: %u (%s)", __func__, num, detail); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_INIT_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_INIT_STATE_INACTIVE: + detail = "inactive"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_INIT_STATE_NET_DETERMINE: + detail = "searching"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_INIT_STATE_ACQUISITION: + detail = "acquisition"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_INIT_STATE_SYNC: + detail = "sync"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Init State: %u (%s)", __func__, num, detail); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_IDLE_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_IDLE_STATE_INACTIVE: + detail = "inactive"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_IDLE_STATE_SLEEP: + detail = "sleep"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_IDLE_STATE_MONITOR: + detail = "monitor"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_IDLE_STATE_SETUP: + detail = "setup"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Idle State: %u (%s)", __func__, num, detail); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_CONNECTED_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_CONNECTED_STATE_INACTIVE: + detail = "inactive"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_CONNECTED_STATE_OPEN: + detail = "open"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_CONNECTED_STATE_CLOSING: + detail = "closing"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Connected State: %u (%s)", __func__, num, detail); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ROUTE_UPDATE_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ROUTE_UPDATE_STATE_INACTIVE: + detail = "inactive"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ROUTE_UPDATE_STATE_IDLE: + detail = "idle"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ROUTE_UPDATE_STATE_CONNECTED: + detail = "connected"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Route Update State: %u (%s)", __func__, num, detail); + + num = 0; + detail = NULL; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_OVERHEAD_MSG_STATE, &num); + switch (num) { + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_OVERHEAD_MSG_STATE_INIT: + detail = "initial"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_OVERHEAD_MSG_STATE_INACTIVE: + detail = "inactive"; + break; + case QCDM_CMD_HDR_SUBSYS_STATE_INFO_OVERHEAD_MSG_STATE_ACTIVE: + detail = "active"; + break; + default: + detail = "unknown"; + break; + } + g_message ("%s: Overhead Msg State: %u (%s)", __func__, num, detail); + + num = 0; + qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_HDR_HYBRID_MODE, &num); + g_message ("%s: HDR Hybrid Mode: %u", __func__, num); + + qcdm_result_unref (result); +} + +void +test_com_zte_subsys_status (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[100]; + gint len; + QCDMResult *result; + gsize reply_len; + guint8 ind = 0; + + len = qcdm_cmd_zte_subsys_status_new (buf, sizeof (buf), NULL); + g_assert (len == 7); + + /* Send the command */ + success = send_command (d, buf, len); + g_assert (success); + + /* Get a response */ + reply_len = wait_reply (d, buf, sizeof (buf)); + + g_print ("\n"); + + /* Parse the response into a result structure */ + result = qcdm_cmd_zte_subsys_status_result (buf, reply_len, &error); + if (!result) { + /* Obviously not all devices implement this command */ + g_assert_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_BAD_COMMAND); + g_message ("%s: device does not implement the ZTE subsystem", __func__); + return; + } + g_assert (result); + + qcdm_result_get_uint8 (result, QCDM_CMD_ZTE_SUBSYS_STATUS_ITEM_SIGNAL_INDICATOR, &ind); + g_message ("%s: Signal Indicator: %d", __func__, ind); + + qcdm_result_unref (result); +} + +void +test_com_nw_subsys_modem_snapshot_cdma (void *f, void *data) +{ + TestComData *d = data; + gboolean success; + GError *error = NULL; + char buf[200]; + gint len; + QCDMResult *result; + gsize reply_len; + guint8 num8 = 0; + guint32 num32 = 0; + + len = qcdm_cmd_nw_subsys_modem_snapshot_cdma_new (buf, sizeof (buf), QCDM_NW_CHIPSET_6800, NULL); + g_assert (len == 12); + + /* Send the command */ + success = send_command (d, buf, len); + g_assert (success); + + /* Get a response */ + reply_len = wait_reply (d, buf, sizeof (buf)); + + g_print ("\n"); + + /* Parse the response into a result structure */ + result = qcdm_cmd_nw_subsys_modem_snapshot_cdma_result (buf, reply_len, &error); + if (!result) { + /* Obviously not all devices implement this command */ + g_assert_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_BAD_COMMAND); + return; + } + g_assert (result); + + qcdm_result_get_uint32 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_RSSI, &num32); + g_message ("%s: RSSI: %d", __func__, num32); + + qcdm_result_get_uint8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_PREV, &num8); + g_message ("%s: P_REV: %s", __func__, prev_to_string (num8)); + + qcdm_result_get_uint8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_BAND_CLASS, &num8); + g_message ("%s: Band Class: %s", __func__, band_class_to_string (num8)); + + qcdm_result_get_uint8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_ERI, &num8); + g_message ("%s: ERI: %d", __func__, num8); + + qcdm_result_get_uint8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_HDR_REV, &num8); + g_message ("%s: HDR Revision: %s", __func__, hdr_rev_to_string (num8)); + + qcdm_result_unref (result); +} + diff --git a/libqcdm/tests/test-qcdm-com.h b/libqcdm/tests/test-qcdm-com.h new file mode 100644 index 0000000..3cf7c4f --- /dev/null +++ b/libqcdm/tests/test-qcdm-com.h @@ -0,0 +1,51 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_QCDM_COM_H +#define TEST_QCDM_COM_H + +gpointer test_com_setup (const char *port); +void test_com_teardown (gpointer d); + +void test_com_port_init (void *f, void *data); + +void test_com_version_info (void *f, void *data); + +void test_com_esn (void *f, void *data); + +void test_com_mdn (void *f, void *data); + +void test_com_read_roam_pref (void *f, void *data); + +void test_com_read_mode_pref (void *f, void *data); + +void test_com_status (void *f, void *data); + +void test_com_sw_version (void *f, void *data); + +void test_com_pilot_sets (void *f, void *data); + +void test_com_cm_subsys_state_info (void *f, void *data); + +void test_com_hdr_subsys_state_info (void *f, void *data); + +void test_com_zte_subsys_status (void *f, void *data); + +void test_com_nw_subsys_modem_snapshot_cdma (void *f, void *data); + +#endif /* TEST_QCDM_COM_H */ + diff --git a/libqcdm/tests/test-qcdm-crc.c b/libqcdm/tests/test-qcdm-crc.c new file mode 100644 index 0000000..0cb3e86 --- /dev/null +++ b/libqcdm/tests/test-qcdm-crc.c @@ -0,0 +1,65 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <glib.h> +#include <string.h> + +#include "test-qcdm-crc.h" +#include "utils.h" + +void +test_crc16_2 (void *f, void *data) +{ + static const char buf[] = { + 0x26, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00 + }; + guint16 crc; + guint16 expected = 0x6D69; + + /* CRC check */ + crc = crc16 (buf, sizeof (buf)); + g_assert (crc == expected); +} + +void +test_crc16_1 (void *f, void *data) +{ + static const char buf[] = { + 0x4b, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3f, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff + }; + guint16 crc; + guint16 expected = 0x097A; + + /* CRC check */ + crc = crc16 (buf, sizeof (buf)); + g_assert (crc == expected); +} + diff --git a/libqcdm/tests/test-qcdm-crc.h b/libqcdm/tests/test-qcdm-crc.h new file mode 100644 index 0000000..91b95a0 --- /dev/null +++ b/libqcdm/tests/test-qcdm-crc.h @@ -0,0 +1,25 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_QCDM_CRC_H +#define TEST_QCDM_CRC_H + +void test_crc16_2 (void *f, void *data); +void test_crc16_1 (void *f, void *data); + +#endif /* TEST_QCDM_CRC_H */ + diff --git a/libqcdm/tests/test-qcdm-escaping.c b/libqcdm/tests/test-qcdm-escaping.c new file mode 100644 index 0000000..fb5fb82 --- /dev/null +++ b/libqcdm/tests/test-qcdm-escaping.c @@ -0,0 +1,124 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <glib.h> +#include <string.h> + +#include "test-qcdm-escaping.h" +#include "utils.h" + +static const char data1[] = { + 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, + 0x0a, 0x6e, 0x6f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x74, 0x6f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x0a, 0x70, 0x68, 0x6f, + 0x6e, 0x7e, 0x7e, 0x7e, 0x7d, 0x7d, 0x7e, 0x7d, 0x7e, 0x7d, 0x7e, 0x6e, + 0x6b, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x0a, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x6c, + 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x6e, 0x6f, 0x74, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, + 0x74, 0x65, 0x64, 0x0a, 0x70, 0x68, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, + 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x70, 0x68, 0x66, + 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x64, 0x0a, 0x70, 0x68, 0x66, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b, + 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, + 0x6e, 0x6f, 0x74, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x65, 0x64, 0x0a, + 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b, 0x72, 0x65, 0x71, + 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x66, 0x61, 0x69, + 0x6c, 0x75, 0x72, 0x65, 0x0a, 0x73, 0x69, 0x6d, 0x62, 0x75, 0x73, 0x79, + 0x0a, 0x73, 0x69, 0x6d, 0x77, 0x72, 0x6f, 0x6e, 0x67, 0x0a, 0x69, 0x6e, + 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x32, 0x72, + 0x65, 0x71, 0x75, 0x69 +}; + +static const char expected1[] = { + 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, + 0x0a, 0x6e, 0x6f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x74, 0x6f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x0a, 0x70, 0x68, 0x6f, + 0x6e, 0x7d, 0x5e, 0x7d, 0x5e, 0x7d, 0x5e, 0x7d, 0x5d, 0x7d, 0x5d, 0x7d, + 0x5e, 0x7d, 0x5d, 0x7d, 0x5e, 0x7d, 0x5d, 0x7d, 0x5e, 0x6e, 0x6b, 0x72, + 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x0a, 0x6f, 0x70, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x6c, 0x6c, 0x6f, + 0x77, 0x65, 0x64, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x6e, 0x6f, 0x74, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, + 0x64, 0x0a, 0x70, 0x68, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x70, 0x68, 0x66, 0x73, 0x69, + 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, + 0x0a, 0x70, 0x68, 0x66, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b, 0x72, 0x65, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x6e, 0x6f, + 0x74, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x65, 0x64, 0x0a, 0x73, 0x69, + 0x6d, 0x70, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, + 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x75, 0x6b, 0x72, 0x65, 0x71, 0x75, 0x69, + 0x72, 0x65, 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x66, 0x61, 0x69, 0x6c, 0x75, + 0x72, 0x65, 0x0a, 0x73, 0x69, 0x6d, 0x62, 0x75, 0x73, 0x79, 0x0a, 0x73, + 0x69, 0x6d, 0x77, 0x72, 0x6f, 0x6e, 0x67, 0x0a, 0x69, 0x6e, 0x63, 0x6f, + 0x72, 0x72, 0x65, 0x63, 0x74, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, + 0x64, 0x0a, 0x73, 0x69, 0x6d, 0x70, 0x69, 0x6e, 0x32, 0x72, 0x65, 0x71, + 0x75, 0x69 +}; + +void +test_escape1 (void *f, void *data) +{ + char escaped[1024]; + gsize len; + + /* Ensure that escaping in general works */ + len = dm_escape (data1, sizeof (data1), escaped, sizeof (escaped)); + g_assert (len == 266); + g_assert (len == sizeof (expected1)); + g_assert (memcmp (escaped, expected1, len) == 0); +} + +static const char data2[] = { + 0x4b, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3f, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff +}; + +void +test_escape2 (void *f, void *data) +{ + char escaped[1024]; + gsize len; + + /* Ensure that escaping data that doesn't need escaping works */ + len = dm_escape (data2, sizeof (data2), escaped, sizeof (escaped)); + g_assert (len == sizeof (data2)); + g_assert (memcmp (escaped, data2, len) == 0); +} + +void +test_escape_unescape (void *f, void *data) +{ + char escaped[512]; + char unescaped[512]; + gsize len, unlen; + gboolean escaping = FALSE; + + /* Ensure that escaping data that needs escaping, and then unescaping it, + * produces the exact same data as was originally escaped. + */ + len = dm_escape (data1, sizeof (data1), escaped, sizeof (escaped)); + unlen = dm_unescape (escaped, len, unescaped, sizeof (unescaped), &escaping); + + g_assert (unlen == sizeof (data1)); + g_assert (memcmp (unescaped, data1, unlen) == 0); +} + diff --git a/libqcdm/tests/test-qcdm-escaping.h b/libqcdm/tests/test-qcdm-escaping.h new file mode 100644 index 0000000..91706ee --- /dev/null +++ b/libqcdm/tests/test-qcdm-escaping.h @@ -0,0 +1,26 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_QCDM_ESCAPING_H +#define TEST_QCDM_ESCAPING_H + +void test_escape1 (void *f, void *data); +void test_escape2 (void *f, void *data); +void test_escape_unescape (void *f, void *data); + +#endif /* TEST_QCDM_ESCAPING_H */ + diff --git a/libqcdm/tests/test-qcdm-result.c b/libqcdm/tests/test-qcdm-result.c new file mode 100644 index 0000000..87f264b --- /dev/null +++ b/libqcdm/tests/test-qcdm-result.c @@ -0,0 +1,71 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <glib.h> +#include <string.h> + +#include "test-qcdm-result.h" +#include "result.h" +#include "result-private.h" + +#define TEST_TAG "test" + +void +test_result_string (void *f, void *data) +{ + const char *str = "foobarblahblahblah"; + const char *tmp = NULL; + QCDMResult *result; + + result = qcdm_result_new (); + qcdm_result_add_string (result, TEST_TAG, str); + + qcdm_result_get_string (result, TEST_TAG, &tmp); + g_assert (tmp); + g_assert (strcmp (tmp, str) == 0); + + qcdm_result_unref (result); +} + +void +test_result_uint32 (void *f, void *data) +{ + guint32 num = 0xDEADBEEF; + guint32 tmp = 0; + QCDMResult *result; + + result = qcdm_result_new (); + qcdm_result_add_uint32 (result, TEST_TAG, num); + + qcdm_result_get_uint32 (result, TEST_TAG, &tmp); + g_assert (tmp == num); +} + +void +test_result_uint8 (void *f, void *data) +{ + guint8 num = 0x1E; + guint8 tmp = 0; + QCDMResult *result; + + result = qcdm_result_new (); + qcdm_result_add_uint8 (result, TEST_TAG, num); + + qcdm_result_get_uint8 (result, TEST_TAG, &tmp); + g_assert (tmp == num); +} + diff --git a/libqcdm/tests/test-qcdm-result.h b/libqcdm/tests/test-qcdm-result.h new file mode 100644 index 0000000..20d6cec --- /dev/null +++ b/libqcdm/tests/test-qcdm-result.h @@ -0,0 +1,26 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_QCDM_RESULT_H +#define TEST_QCDM_RESULT_H + +void test_result_string (void *f, void *data); +void test_result_uint32 (void *f, void *data); +void test_result_uint8 (void *f, void *data); + +#endif /* TEST_QCDM_RESULT_H */ + diff --git a/libqcdm/tests/test-qcdm-utils.c b/libqcdm/tests/test-qcdm-utils.c new file mode 100644 index 0000000..27ec8d6 --- /dev/null +++ b/libqcdm/tests/test-qcdm-utils.c @@ -0,0 +1,86 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <glib.h> +#include <string.h> + +#include "test-qcdm-utils.h" +#include "utils.h" + +static const char decap_inbuf[] = { + 0x40, 0x03, 0x00, 0x01, 0x00, 0x19, 0xf0, 0x00, 0x16, 0x00, 0x21, 0x00, + 0x1c, 0x00, 0xd8, 0x00, 0x3f, 0x00, 0x56, 0x01, 0x3f, 0x00, 0x15, 0x00, + 0x1a, 0x00, 0x11, 0x01, 0x3f, 0x00, 0x92, 0x01, 0x3f, 0x00, 0x39, 0x00, + 0x3f, 0x00, 0x95, 0x01, 0x3f, 0x00, 0x12, 0x00, 0x3f, 0x00, 0x23, 0x01, + 0x3f, 0x00, 0x66, 0x00, 0x3f, 0x00, 0x0b, 0x01, 0x3f, 0x00, 0xae, 0x00, + 0x3f, 0x00, 0x02, 0x01, 0x3f, 0x00, 0xa8, 0x00, 0x3f, 0x00, 0x50, 0x01, + 0x3f, 0x00, 0xf8, 0x01, 0x3f, 0x00, 0x57, 0x00, 0x3f, 0x00, 0x7d, 0x5e, + 0x00, 0x3f, 0x00, 0x93, 0x00, 0x3f, 0x00, 0xbd, 0x00, 0x3f, 0x00, 0x77, + 0x01, 0x3f, 0x00, 0xb7, 0x00, 0x3f, 0x00, 0xab, 0x00, 0x3f, 0x00, 0x33, + 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xad, 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, + 0x13, 0x50, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x00, 0xaa, 0x19, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0xc4, 0x7d, 0x5e, + 0x7d, 0x5e, 0x7d, 0x5d, 0x5d, 0x04, 0x58, 0x1b, 0x5b, 0x1b, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x65, 0x69, 0x7e +}; + +void +test_utils_decapsulate_buffer (void *f, void *data) +{ + gboolean success; + char outbuf[512]; + gsize decap_len = 0; + gsize used = 0; + gboolean more = FALSE; + + success = dm_decapsulate_buffer (decap_inbuf, sizeof (decap_inbuf), + outbuf, sizeof (outbuf), + &decap_len, &used, &more); + g_assert (success); + g_assert (decap_len == 214); + g_assert (used == 221); + g_assert (more == FALSE); +} + + +static const char encap_outbuf[] = { + 0x4b, 0x05, 0x08, 0x00, 0x01, 0xdd, 0x7e +}; + +void +test_utils_encapsulate_buffer (void *f, void *data) +{ + char cmdbuf[10]; + char outbuf[512]; + gsize encap_len = 0; + + cmdbuf[0] = 0x4B; /* DIAG_CMD_SUBSYS */ + cmdbuf[1] = 0x05; /* DIAG_SUBSYS_HDR */ + cmdbuf[2] = 0x08; /* first byte of DIAG_SUBSYS_HDR_STATE_INFO in LE */ + cmdbuf[3] = 0x00; /* second byte of DIAG_SUBSYS_HDR_STATE_INFO in LE */ + + encap_len = dm_encapsulate_buffer (cmdbuf, 4, sizeof (cmdbuf), + &outbuf[0], sizeof (outbuf)); + g_assert (encap_len == sizeof (encap_outbuf)); + g_assert (memcmp (outbuf, encap_outbuf, encap_len) == 0); +} + diff --git a/libqcdm/tests/test-qcdm-utils.h b/libqcdm/tests/test-qcdm-utils.h new file mode 100644 index 0000000..8038666 --- /dev/null +++ b/libqcdm/tests/test-qcdm-utils.h @@ -0,0 +1,26 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_QCDM_UTILS_H +#define TEST_QCDM_UTILS_H + +void test_utils_decapsulate_buffer (void *f, void *data); + +void test_utils_encapsulate_buffer (void *f, void *data); + +#endif /* TEST_QCDM_UTILS_H */ + diff --git a/libqcdm/tests/test-qcdm.c b/libqcdm/tests/test-qcdm.c new file mode 100644 index 0000000..a58780e --- /dev/null +++ b/libqcdm/tests/test-qcdm.c @@ -0,0 +1,115 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Red Hat, Inc. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <glib.h> +#include <string.h> + +#include "test-qcdm-crc.h" +#include "test-qcdm-escaping.h" +#include "test-qcdm-com.h" +#include "test-qcdm-result.h" +#include "test-qcdm-utils.h" + +typedef struct { + gpointer com_data; +} TestData; + +typedef void (*TCFunc)(void); + +#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) + +static TestData * +test_data_new (const char *port) +{ + TestData *d; + + d = g_malloc0 (sizeof (TestData)); + g_assert (d); + + if (port) + d->com_data = test_com_setup (port); + + return d; +} + +static void +test_data_free (TestData *d) +{ + if (d->com_data) + test_com_teardown (d->com_data); + + g_free (d); +} + +int main (int argc, char **argv) +{ + GTestSuite *suite; + TestData *data; + int i; + const char *port = NULL; + gint result; + + g_test_init (&argc, &argv, NULL); + + /* See if we got passed a serial port for live testing */ + for (i = 0; i < argc; i++) { + if (!strcmp (argv[i], "--port")) { + /* Make sure there's actually a port in the next arg */ + g_assert (argc > i + 1); + port = argv[++i]; + } + } + + data = test_data_new (port); + + suite = g_test_get_root (); + + g_test_suite_add (suite, TESTCASE (test_crc16_1, NULL)); + g_test_suite_add (suite, TESTCASE (test_crc16_2, NULL)); + g_test_suite_add (suite, TESTCASE (test_escape1, NULL)); + g_test_suite_add (suite, TESTCASE (test_escape2, NULL)); + g_test_suite_add (suite, TESTCASE (test_escape_unescape, NULL)); + g_test_suite_add (suite, TESTCASE (test_utils_decapsulate_buffer, NULL)); + g_test_suite_add (suite, TESTCASE (test_utils_encapsulate_buffer, NULL)); + g_test_suite_add (suite, TESTCASE (test_result_string, NULL)); + g_test_suite_add (suite, TESTCASE (test_result_uint32, NULL)); + g_test_suite_add (suite, TESTCASE (test_result_uint8, NULL)); + + /* Live tests */ + if (port) { + g_test_suite_add (suite, TESTCASE (test_com_port_init, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_version_info, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_esn, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_mdn, data->com_data)); + 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_status, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_sw_version, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_pilot_sets, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_cm_subsys_state_info, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_hdr_subsys_state_info, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_zte_subsys_status, data->com_data)); + g_test_suite_add (suite, TESTCASE (test_com_nw_subsys_modem_snapshot_cdma, data->com_data)); + } + + result = g_test_run (); + + test_data_free (data); + + return result; +} + |