3 * oFono - Open Source Telephony
5 * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #include <glib/gprintf.h>
37 static const char *assembly_pdu1 = "038121F340048155550119906041001222048C0500"
38 "031E0301041804420430043A002C002004100"
39 "43B0435043A04410430043D04340440002000"
40 "200441043B044304480430043B00200437043"
41 "000200434043204350440044C044E00200020"
42 "04380020002004320441043500200431043E0"
43 "43B044C044804350020043F04400435043804"
44 "41043F043E043B043D044F043B0441044F002"
46 static int assembly_pdu_len1 = 155;
48 static const char *assembly_pdu2 = "038121F340048155550119906041001222048C0500"
49 "031E03020432043E043C002E000A041D04300"
50 "43A043E043D04350446002C0020043D043500"
51 "200432002004410438043B043004450020043"
52 "40430043B043504350020044204350440043F"
53 "04350442044C002C0020043E043D002004410"
54 "44204400435043C043804420435043B044C04"
55 "3D043E002004320431043504360430043B002"
57 static int assembly_pdu_len2 = 155;
59 static const char *assembly_pdu3 = "038121F340048155550119906041001222044A0500"
60 "031E0303043C043D043004420443002C00200"
61 "43F043E043704300431044B0432000A043404"
62 "3004360435002C002004470442043E0020002"
63 "00431044B043B0020043D04300433002E";
64 static int assembly_pdu_len3 = 89;
66 static void test_serialize_assembly(void)
68 unsigned char pdu[176];
71 struct sms_assembly *assembly = sms_assembly_new("1234");
77 decode_hex_own_buf(assembly_pdu1, -1, &pdu_len, 0, pdu);
78 sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len1, &sms);
80 sms_extract_concatenation(&sms, &ref, &max, &seq);
81 l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
82 &sms.deliver.oaddr, ref, max, seq);
84 if (g_test_verbose()) {
85 g_print("Ref: %u\n", ref);
86 g_print("Max: %u\n", max);
88 sms_address_to_string(&sms.deliver.oaddr));
91 g_assert(g_slist_length(assembly->assembly_list) == 1);
94 decode_hex_own_buf(assembly_pdu2, -1, &pdu_len, 0, pdu);
95 sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len2, &sms);
97 sms_extract_concatenation(&sms, &ref, &max, &seq);
98 l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
99 &sms.deliver.oaddr, ref, max, seq);
102 sms_assembly_free(assembly);
104 assembly = sms_assembly_new("1234");
106 decode_hex_own_buf(assembly_pdu3, -1, &pdu_len, 0, pdu);
107 sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len3, &sms);
109 sms_extract_concatenation(&sms, &ref, &max, &seq);
110 l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
111 &sms.deliver.oaddr, ref, max, seq);
115 sms_assembly_free(assembly);
118 int main(int argc, char **argv)
120 g_test_init(&argc, &argv, NULL);
122 g_test_add_func("/testsms/Test SMS Assembly Serialize",
123 test_serialize_assembly);