All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2, 6/7] test: Add CDMA SMS Support
@ 2010-12-22  0:02 Lei Yu
  2011-01-04 21:25 ` Denis Kenzior
  0 siblings, 1 reply; 3+ messages in thread
From: Lei Yu @ 2010-12-22  0:02 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 5332 bytes --]

---
 Makefile.am         |    6 ++-
 unit/test-cdmasms.c |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+), 1 deletions(-)
 create mode 100644 unit/test-cdmasms.c

diff --git a/Makefile.am b/Makefile.am
index 3035b69..771f57d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -449,7 +449,7 @@ dist_man_MANS = doc/ofonod.8
 noinst_PROGRAMS = unit/test-common unit/test-util unit/test-idmap \
 					unit/test-sms unit/test-simutil \
 					unit/test-mux unit/test-caif \
-					unit/test-stkutil
+					unit/test-stkutil unit/test-cdmasms
 
 unit_objects =
 
@@ -469,6 +469,10 @@ unit_test_sms_SOURCES = unit/test-sms.c src/util.c src/smsutil.c src/storage.c
 unit_test_sms_LDADD = @GLIB_LIBS@
 unit_objects += $(unit_test_sms_OBJECTS)
 
+unit_test_cdmasms_SOURCES = unit/test-cdmasms.c src/cdma-smsutil.c
+unit_test_cdmasms_LDADD = @GLIB_LIBS@
+unit_objects += $(unit_test_cdmasms_OBJECTS)
+
 unit_test_simutil_SOURCES = unit/test-simutil.c src/util.c \
 				src/simutil.c src/smsutil.c src/storage.c
 unit_test_simutil_LDADD = @GLIB_LIBS@
diff --git a/unit/test-cdmasms.c b/unit/test-cdmasms.c
new file mode 100644
index 0000000..7dac360
--- /dev/null
+++ b/unit/test-cdmasms.c
@@ -0,0 +1,137 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 Nokia Corporation.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "cdma-smsutil.h"
+
+static void cdma_sms_receive_test1()
+{
+	gboolean ret;
+	struct cdma_sms s;
+	char *addr;
+	char *message;
+
+	/*
+	 * 0x00,  :P2P
+	 * 0x00, 0x02, 0x10, 0x02, :Teleservice Id
+	 * 0x02, 0x05, 0x01, 0xC4, 0x8D, 0x15, 0x9C, :Orig Addr
+	 * 0x08, 0x0D, :Bearer Data
+	 *   0x00, 0x03, 0x1B, 0xEE, 0xF0, 0x01, :Message Id
+	 *   0x06, 0x10, 0x2C, 0x8C, 0xBB, 0x36, 0x6F :User Data
+	*/
+	guint8 mt_cdma_sms_pdu[] = {
+		0x00, 0x00, 0x02, 0x10, 0x02, 0x02, 0x05,
+		0x01, 0xC4, 0x8D, 0x15, 0x9C, 0x08, 0x0D,
+		0x00, 0x03, 0x1B, 0xEE, 0xF0, 0x01, 0x06,
+		0x10, 0x2C, 0x8C, 0xBB, 0x36, 0x6F
+	};
+
+	memset(&s, 0, sizeof(struct cdma_sms));
+
+	/* Decode the incoming CDMA SMS TPDU */
+	ret = cdma_sms_decode(mt_cdma_sms_pdu, sizeof(mt_cdma_sms_pdu), &s);
+
+	g_assert(ret == TRUE);
+
+	/* Verify message type is Point to Point */
+	g_assert(s.type == CDMA_SMS_P2P);
+
+	/* Verify teleservice id is WMT */
+	g_assert(s.p2p_msg.teleservice_id == TELESERVICE_WMT);
+
+	addr = cdma_sms_address_to_string(&s.p2p_msg.oaddr);
+	g_assert(strcmp(addr, "1234567") == 0);
+
+	message = cdma_sms_decode_text(&s.p2p_msg.bearer_data.ud);
+	g_assert(strcmp(message, "Hello") == 0);
+
+	return;
+}
+
+static void cdma_sms_receive_test2()
+{
+	gboolean ret;
+	struct cdma_sms s;
+	char *addr;
+	char *message;
+
+	/*
+	 * 0x00, :Point-to-Point
+	 * 0x00, 0x02, 0x10, 0x02, :Teleservie ID
+	 * 0x02, 0x07, 0x02, 0xA1, 0x62, 0x51, 0x55, 0xA6, 0x40, :Orig Address
+	 * 0x08, 0x18, :Bearer Data
+	 *   0x00, 0x03, 0x10, 0x00, 0x40, :Message Identifier
+	 *   0x01, 0x06, 0x10, 0x25, 0x4C, 0xBC, 0xFA, 0x00, :User Data
+	 *   0x03, 0x06, 0x03, 0x08, 0x20, 0x13, 0x43, 0x12, :MC Time Stamp
+	 *   0x0D, 0x01, 0x01 :Language Indicator
+	*/
+	guint8 mt_cdma_sms_pdu[] = {
+		0x00, 0x00, 0x02, 0x10, 0x02, 0x02,
+		0x07, 0x02, 0xA1, 0x62, 0x51, 0x55,
+		0xA6, 0x40, 0x08, 0x18, 0x00, 0x03,
+		0x10, 0x00, 0x40, 0x01, 0x06, 0x10,
+		0x25, 0x4C, 0xBC, 0xFA, 0x00, 0x03,
+		0x06, 0x03, 0x08, 0x20, 0x13, 0x43,
+		0x12, 0x0D, 0x01, 0x01
+	};
+
+	memset(&s, 0, sizeof(struct cdma_sms));
+
+	/* Decode the incoming CDMA SMS TPDU */
+	ret = cdma_sms_decode(mt_cdma_sms_pdu, sizeof(mt_cdma_sms_pdu), &s);
+
+	g_assert(ret == TRUE);
+
+	/* Verify message type is Point to Point */
+	g_assert(s.type == CDMA_SMS_P2P);
+
+	/* Verify teleservice id is WMT */
+	g_assert(s.p2p_msg.teleservice_id == TELESERVICE_WMT);
+
+	addr = cdma_sms_address_to_string(&s.p2p_msg.oaddr);
+	g_assert(strcmp(addr, "8589455699") == 0);
+
+	message = cdma_sms_decode_text(&s.p2p_msg.bearer_data.ud);
+	g_assert(s.p2p_msg.bearer_data.ud.num_fields == 4);
+	g_assert(strcmp(message, "Test") == 0);
+
+	return;
+}
+
+int main(int argc, char **argv)
+{
+	g_test_init(&argc, &argv, NULL);
+
+	g_test_add_func("/test-cdmasms/Test Simple Msg Receive 1",
+			cdma_sms_receive_test1);
+
+	g_test_add_func("/test-cdmasms/Test Simple Msg Receive 2",
+			cdma_sms_receive_test2);
+
+	return g_test_run();
+}
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2, 6/7] test: Add CDMA SMS Support
  2010-12-22  0:02 [PATCH v2, 6/7] test: Add CDMA SMS Support Lei Yu
@ 2011-01-04 21:25 ` Denis Kenzior
  2011-01-05 17:57   ` Lei Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Kenzior @ 2011-01-04 21:25 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

Hi Lei,

On 12/21/2010 06:02 PM, Lei Yu wrote:
> ---
>  Makefile.am         |    6 ++-
>  unit/test-cdmasms.c |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 142 insertions(+), 1 deletions(-)
>  create mode 100644 unit/test-cdmasms.c
> 

This one looks fine but have you considered using g_test_add_data_func
instead of g_test_add_func?  That makes it much easier to add new tests...

Regards,
-Denis

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2, 6/7] test: Add CDMA SMS Support
  2011-01-04 21:25 ` Denis Kenzior
@ 2011-01-05 17:57   ` Lei Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Lei Yu @ 2011-01-05 17:57 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

Hi Denis,

On 01/04/2011 01:25 PM, ext Denis Kenzior wrote:
> Hi Lei,
>
> On 12/21/2010 06:02 PM, Lei Yu wrote:
>> ---
>>   Makefile.am         |    6 ++-
>>   unit/test-cdmasms.c |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 142 insertions(+), 1 deletions(-)
>>   create mode 100644 unit/test-cdmasms.c
>>
>
> This one looks fine but have you considered using g_test_add_data_func
> instead of g_test_add_func?  That makes it much easier to add new tests...
>

No, have not looked g_test_add_data_func. Will look into that and 
re-submit patch or ask questions. :-)

> Regards,
> -Denis

Regards,
-Lei

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-05 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-22  0:02 [PATCH v2, 6/7] test: Add CDMA SMS Support Lei Yu
2011-01-04 21:25 ` Denis Kenzior
2011-01-05 17:57   ` Lei Yu

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.