From: Yang Gu <yang.gu@intel.com>
To: ofono@ofono.org
Subject: [PATCH 08/27] test-stkutil: Refactor test for send sms parser
Date: Thu, 13 May 2010 18:48:25 +0800 [thread overview]
Message-ID: <1273747724-28019-8-git-send-email-yang.gu@intel.com> (raw)
In-Reply-To: <1273747724-28019-1-git-send-email-yang.gu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 6459 bytes --]
---
unit/test-stkutil.c | 132 ++++++++++++++++++++++++++++++++------------------
1 files changed, 84 insertions(+), 48 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index 8ec380f..82df2e3 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -71,6 +71,27 @@ static inline void check_common_text(const char *command, const char *test)
g_assert(g_str_equal(command, test));
}
+static inline void check_common_byte_array(
+ const struct stk_common_byte_array *command,
+ const struct stk_common_byte_array *test)
+{
+ if (test->len == 0) {
+ g_assert(command->len == 0);
+ return;
+ }
+
+ g_assert(command->len != 0);
+ g_assert(g_mem_equal(command->array, test->array, test->len));
+}
+
+/* Defined in TS 102.223 Section 8.1 */
+static inline void check_address(const struct stk_address *command,
+ const struct stk_address *test)
+{
+ g_assert(command->ton_npi == test->ton_npi);
+ g_assert(g_str_equal(command->number, test->number));
+}
+
/* Defined in TS 102.223 Section 8.2 */
static inline void check_alpha_id(const char *command, const char *test)
{
@@ -122,6 +143,18 @@ static void check_response_length(const struct stk_response_length *command,
g_assert(command->max == test->max);
}
+/* Defined in TS 102.223 Section 8.13 */
+static void check_gsm_sms_tpdu(const struct sms *command,
+ const struct sms *test)
+{
+ g_assert(command->submit.mr == test->submit.mr);
+ g_assert(command->submit.udl == test->submit.udl);
+ g_assert(g_str_equal(command->submit.daddr.address,
+ test->submit.daddr.address));
+ g_assert(g_mem_equal(command->submit.ud, test->submit.ud,
+ test->submit.udl));
+}
+
/* Defined in TS 102.223 Section 8.15 */
static inline void check_text(const char *command, const char *test)
{
@@ -174,6 +207,14 @@ static inline void check_imm_resp(const unsigned char command,
check_common_byte(command, test);
}
+/* Defined in TS 102.223 Section 8.71 */
+static inline void check_cdma_sms_tpdu(
+ const struct stk_common_byte_array *command,
+ const struct stk_common_byte_array *test)
+{
+ check_common_byte_array(command, test);
+}
+
/* Defined in TS 102.223 Section 8.72 */
static void check_text_attr(const struct stk_text_attribute *command,
const struct stk_text_attribute *test)
@@ -7445,45 +7486,51 @@ struct send_sms_test {
const unsigned char *pdu;
unsigned int pdu_len;
unsigned char qualifier;
- const char *alpha_id;
- unsigned char ton_npi;
- const char *address;
- unsigned char sms_mr;
- const char *sms_address;
- unsigned char sms_udl;
- const char *sms_ud;
+ char *alpha_id;
+ struct stk_address address;
+ struct sms gsm_sms;
+ struct stk_common_byte_array cdma_sms;
+ struct stk_icon_id icon_id;
+ struct stk_text_attribute text_attr;
+ struct stk_frame_id frame_id;
};
/* 3GPP TS 31.124 Section 27.22.4.10.1.4.2 */
-static unsigned char send_sms_11[] = { 0xD0, 0x37, 0x81, 0x03, 0x01, 0x13, 0x00,
- 0x82, 0x02, 0x81, 0x83, 0x85, 0x07,
- 0x53, 0x65, 0x6E, 0x64, 0x20, 0x53,
- 0x4D, 0x86, 0x09, 0x91, 0x11, 0x22,
- 0x33, 0x44, 0x55, 0x66, 0x77, 0xF8,
- 0x8B, 0x18, 0x01, 0x00, 0x09, 0x91,
- 0x10, 0x32, 0x54, 0x76, 0xF8, 0x40,
- 0xF4, 0x0C, 0x54, 0x65, 0x73, 0x74,
- 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61,
- 0x67, 0x65 };
-
-static struct send_sms_test send_sms_data_11 = {
- .pdu = send_sms_11,
- .pdu_len = sizeof(send_sms_11),
+static unsigned char send_sms_111[] = { 0xD0, 0x37, 0x81, 0x03, 0x01, 0x13,
+ 0x00, 0x82, 0x02, 0x81, 0x83, 0x85,
+ 0x07, 0x53, 0x65, 0x6E, 0x64, 0x20,
+ 0x53, 0x4D, 0x86, 0x09, 0x91, 0x11,
+ 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0xF8, 0x8B, 0x18, 0x01, 0x00, 0x09,
+ 0x91, 0x10, 0x32, 0x54, 0x76, 0xF8,
+ 0x40, 0xF4, 0x0C, 0x54, 0x65, 0x73,
+ 0x74, 0x20, 0x4D, 0x65, 0x73, 0x73,
+ 0x61, 0x67, 0x65 };
+
+static struct send_sms_test send_sms_data_111 = {
+ .pdu = send_sms_111,
+ .pdu_len = sizeof(send_sms_111),
.qualifier = 0x00,
.alpha_id = "Send SM",
- .ton_npi = 0x91,
- .address = "112233445566778",
- .sms_mr = 0x00,
- .sms_address = "012345678",
- .sms_udl = 12,
- .sms_ud = "Test Message",
+ .address = {
+ .ton_npi = 0x91,
+ .number = "112233445566778"
+ },
+ .gsm_sms = {
+ {}, SMS_TYPE_SUBMIT,
+ {.submit = {
+ .mr = 0x00,
+ .daddr.address = "012345678",
+ .udl = 12,
+ .ud = "Test Message"
+ } }
+ }
};
static void test_send_sms(gconstpointer data)
{
const struct send_sms_test *test = data;
struct stk_command *command;
- int i;
command = stk_command_new_from_pdu(test->pdu, test->pdu_len);
@@ -7496,24 +7543,13 @@ static void test_send_sms(gconstpointer data)
g_assert(command->src == STK_DEVICE_IDENTITY_TYPE_UICC);
g_assert(command->dst == STK_DEVICE_IDENTITY_TYPE_NETWORK);
- if (test->alpha_id)
- g_assert(g_str_equal(test->alpha_id,
- command->send_sms.alpha_id));
-
- if (test->address) {
- g_assert(test->ton_npi == command->send_sms.address.ton_npi);
- g_assert(g_str_equal(test->address,
- command->send_sms.address.number));
- }
-
- g_assert(test->sms_mr == command->send_sms.gsm_sms.submit.mr);
- g_assert(test->sms_udl == command->send_sms.gsm_sms.submit.udl);
- g_assert(g_str_equal(test->sms_address,
- command->send_sms.gsm_sms.submit.daddr.address));
-
- for (i = 0; i < test->sms_udl; i++)
- g_assert(test->sms_ud[i] ==
- command->send_sms.gsm_sms.submit.ud[i]);
+ check_alpha_id(command->send_sms.alpha_id, test->alpha_id);
+ check_address(&command->send_sms.address, &test->address);
+ check_gsm_sms_tpdu(&command->send_sms.gsm_sms, &test->gsm_sms);
+ check_cdma_sms_tpdu(&command->send_sms.cdma_sms, &test->cdma_sms);
+ check_icon_id(&command->select_item.icon_id, &test->icon_id);
+ check_text_attr(&command->select_item.text_attr, &test->text_attr);
+ check_frame_id(&command->select_item.frame_id, &test->frame_id);
stk_command_free(command);
}
@@ -8050,8 +8086,8 @@ int main(int argc, char **argv)
g_test_add_data_func("/teststk/Select Item 12.3.1",
&select_item_data_1231, test_select_item);
- g_test_add_data_func("/teststk/Send SMS 1.1",
- &send_sms_data_11, test_send_sms);
+ g_test_add_data_func("/teststk/Send SMS 1.1.1",
+ &send_sms_data_111, test_send_sms);
return g_test_run();
}
--
1.7.0.4
next prev parent reply other threads:[~2010-05-13 10:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-13 10:48 [PATCH 01/27] stk: Add poll interval proactive command parser Yang Gu
2010-05-13 10:48 ` [PATCH 02/27] test-stkutil: Add test for poll interval parser Yang Gu
2010-05-13 10:48 ` [PATCH 03/27] stkutil: Add setup menu proactive command parser Yang Gu
2010-05-13 10:48 ` [PATCH 04/27] test-stkutil: Add test for setup menu parser Yang Gu
2010-05-13 10:48 ` [PATCH 05/27] stkutil: Add select item proactive command parser Yang Gu
2010-05-13 10:48 ` [PATCH 06/27] test-stkutil: Add test for select item parser Yang Gu
2010-05-13 10:48 ` [PATCH 07/27] test-stkutil: Use dedicated functions to check Yang Gu
2010-05-13 10:48 ` Yang Gu [this message]
2010-05-13 10:48 ` [PATCH 09/27] stk: Adjust the sequence of dataobj Yang Gu
2010-05-13 10:48 ` [PATCH 10/27] stkutil: Add setup call proactive command parser Yang Gu
2010-05-13 10:48 ` [PATCH 11/27] test-stkutil: Add unit test for setup call parser Yang Gu
2010-05-13 10:48 ` [PATCH 12/27] stkutil: Add refresh proactive command parser Yang Gu
2010-05-13 10:48 ` [PATCH 13/27] test-stkutil: Add test for refresh parser Yang Gu
2010-05-13 10:48 ` [PATCH 14/27] stkutil: Add polling off proactive command parser Yang Gu
2010-05-13 10:48 ` [PATCH 15/27] test-stkutil: Add test for polling off parser Yang Gu
2010-05-13 10:48 ` [PATCH 16/27] stkutil: Add provide local info command parser Yang Gu
2010-05-13 10:48 ` [PATCH 17/27] test-stk: Add test for provide local info parser Yang Gu
2010-05-13 10:48 ` [PATCH 18/27] stkutil: Add event list command parser Yang Gu
2010-05-13 10:48 ` [PATCH 19/27] test-stkutil: Add test for event list parser Yang Gu
2010-05-13 10:48 ` [PATCH 20/27] stkutil: Add perform card apdu command parser Yang Gu
2010-05-13 10:48 ` [PATCH 21/27] test-stk: Add test for perform card apdu parser Yang Gu
2010-05-13 10:48 ` [PATCH 22/27] stkutil: Add power off card command parser Yang Gu
2010-05-13 10:48 ` [PATCH 23/27] stkutil: Add power on " Yang Gu
2010-05-13 10:48 ` [PATCH 24/27] stkutil: Add get reader status " Yang Gu
2010-05-13 10:48 ` [PATCH 25/27] test-stk: Add test for get reader status parser Yang Gu
2010-05-13 10:48 ` [PATCH 26/27] stkutil: Add timer management command parser Yang Gu
2010-05-13 10:48 ` [PATCH 27/27] test-stk: Add test for timer management parser Yang Gu
2010-05-13 20:37 ` [PATCH 01/27] stk: Add poll interval proactive command parser Denis Kenzior
2010-05-14 8:37 ` Gu, Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1273747724-28019-8-git-send-email-yang.gu@intel.com \
--to=yang.gu@intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.