From: Yang Gu <yang.gu@intel.com>
To: ofono@ofono.org
Subject: [PATCH 17/19] test-stkutil: Refactor test for send sms parser
Date: Mon, 10 May 2010 18:39:00 +0800 [thread overview]
Message-ID: <1273487942-27213-17-git-send-email-yang.gu@intel.com> (raw)
In-Reply-To: <1273487942-27213-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 52aa050..ffe0a3f 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -70,6 +70,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)
{
@@ -121,6 +142,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)
{
@@ -173,6 +206,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)
@@ -7443,45 +7484,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);
@@ -7494,24 +7541,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);
}
@@ -8048,8 +8084,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-10 10:39 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 10:38 [PATCH 01/19] stkutil: Free default text for get input parser Yang Gu
2010-05-10 10:38 ` [PATCH 02/19] test-stkutil: Add unit test " Yang Gu
2010-05-11 19:25 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 03/19] stk: Unify variable names to use abbreviation Yang Gu
2010-05-11 19:25 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 04/19] test-stkutil: Use enum for icon_id Yang Gu
2010-05-11 19:25 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 05/19] stkutil: Add play tone proactive command parser Yang Gu
2010-05-11 19:26 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 06/19] Replace check_text with check_common_text Yang Gu
2010-05-11 19:26 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 07/19] stkutil: Refactor parser for tone objects Yang Gu
2010-05-11 19:26 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 08/19] test-stkutil: Add unit test for play tone parser Yang Gu
2010-05-11 19:27 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 09/19] stkutil: Add poll interval proactive command parser Yang Gu
2010-05-11 19:23 ` Denis Kenzior
2010-05-12 9:03 ` Gu, Yang
2010-05-12 14:21 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 10/19] test-stkutil: Add unit test for poll interval parser Yang Gu
2010-05-10 10:38 ` [PATCH 11/19] stkutil: Add setup menu proactive command parser Yang Gu
2010-05-11 19:21 ` Denis Kenzior
2010-05-12 8:53 ` Gu, Yang
2010-05-12 14:43 ` Denis Kenzior
2010-05-10 10:38 ` [PATCH 12/19] test-stkutil: Add unit test for setup menu parser Yang Gu
2010-05-10 10:38 ` [PATCH 13/19] stkutil: Add select item proactive command parser Yang Gu
2010-05-10 10:38 ` [PATCH 14/19] test-stkutil: Add unit test for select item parser Yang Gu
2010-05-10 10:38 ` [PATCH 15/19] test-stkutil: Use dedicated functions to check Yang Gu
2010-05-10 10:38 ` [PATCH 16/19] stkutil: Parse cdma tpdu in send sms parser Yang Gu
2010-05-11 19:38 ` Denis Kenzior
2010-05-10 10:39 ` Yang Gu [this message]
2010-05-10 10:39 ` [PATCH 18/19] stkutil: Add setup call proactive command parser Yang Gu
2010-05-10 10:39 ` [PATCH 19/19] test-stkutil: Add unit test for setup call parser Yang Gu
2010-05-11 19:24 ` [PATCH 01/19] stkutil: Free default text for get input parser Denis Kenzior
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=1273487942-27213-17-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox