summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2011-06-30 16:19:24 -0700
committerMarcel Holtmann <marcel@holtmann.org>2011-06-30 16:19:24 -0700
commit7f7492669aaec6f3fb52e48f0f5a0ed32c99bea1 (patch)
tree2d17006fbdf0e888bb00ccba6c636a77033c7a1f
parent0c20ee6c533b62b4527525e924b04eb6a1e40fdf (diff)
downloadofono-7f7492669aaec6f3fb52e48f0f5a0ed32c99bea1.tar.bz2
build: Split non-root unit tests to have make check succeed
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am6
-rw-r--r--unit/test-sms-root.c97
-rw-r--r--unit/test-sms.c55
4 files changed, 103 insertions, 56 deletions
diff --git a/.gitignore b/.gitignore
index 8baa561b..8f955501 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,7 @@ unit/test-common
unit/test-util
unit/test-idmap
unit/test-sms
+unit/test-sms-root
unit/test-simutil
unit/test-mux
unit/test-caif
diff --git a/Makefile.am b/Makefile.am
index 6a2c0fe5..ef6196be 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -571,7 +571,11 @@ unit_test_cdmasms_SOURCES = unit/test-cdmasms.c src/cdma-smsutil.c
unit_test_cdmasms_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_cdmasms_OBJECTS)
-noinst_PROGRAMS = unit/test-mux unit/test-caif
+noinst_PROGRAMS = unit/test-sms-root unit/test-mux unit/test-caif
+
+unit_test_sms_root_SOURCES = unit/test-sms.c src/util.c src/smsutil.c src/storage.c
+unit_test_sms_root_LDADD = @GLIB_LIBS@
+unit_objects += $(unit_test_sms_root_OBJECTS)
unit_test_mux_SOURCES = unit/test-mux.c $(gatchat_sources)
unit_test_mux_LDADD = @GLIB_LIBS@
diff --git a/unit/test-sms-root.c b/unit/test-sms-root.c
new file mode 100644
index 00000000..8ac7e2af
--- /dev/null
+++ b/unit/test-sms-root.c
@@ -0,0 +1,97 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel 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 version 2 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, 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 <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "util.h"
+#include "smsutil.h"
+
+static void test_serialize_assembly(void)
+{
+ unsigned char pdu[176];
+ long pdu_len;
+ struct sms sms;
+ struct sms_assembly *assembly = sms_assembly_new("1234");
+ guint16 ref;
+ guint8 max;
+ guint8 seq;
+ GSList *l;
+
+ decode_hex_own_buf(assembly_pdu1, -1, &pdu_len, 0, pdu);
+ sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len1, &sms);
+
+ sms_extract_concatenation(&sms, &ref, &max, &seq);
+ l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
+ &sms.deliver.oaddr, ref, max, seq);
+
+ if (g_test_verbose()) {
+ g_print("Ref: %u\n", ref);
+ g_print("Max: %u\n", max);
+ g_print("From: %s\n",
+ sms_address_to_string(&sms.deliver.oaddr));
+ }
+
+ g_assert(g_slist_length(assembly->assembly_list) == 1);
+ g_assert(l == NULL);
+
+ decode_hex_own_buf(assembly_pdu2, -1, &pdu_len, 0, pdu);
+ sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len2, &sms);
+
+ sms_extract_concatenation(&sms, &ref, &max, &seq);
+ l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
+ &sms.deliver.oaddr, ref, max, seq);
+ g_assert(l == NULL);
+
+ sms_assembly_free(assembly);
+
+ assembly = sms_assembly_new("1234");
+
+ decode_hex_own_buf(assembly_pdu3, -1, &pdu_len, 0, pdu);
+ sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len3, &sms);
+
+ sms_extract_concatenation(&sms, &ref, &max, &seq);
+ l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
+ &sms.deliver.oaddr, ref, max, seq);
+
+ g_assert(l != NULL);
+
+ sms_assembly_free(assembly);
+}
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/testsms/Test SMS Assembly Serialize",
+ test_serialize_assembly);
+
+ return g_test_run();
+}
diff --git a/unit/test-sms.c b/unit/test-sms.c
index abaed359..39e84428 100644
--- a/unit/test-sms.c
+++ b/unit/test-sms.c
@@ -1389,58 +1389,6 @@ static void test_cbs_assembly(void)
cbs_assembly_free(assembly);
}
-static void test_serialize_assembly(void)
-{
- unsigned char pdu[176];
- long pdu_len;
- struct sms sms;
- struct sms_assembly *assembly = sms_assembly_new("1234");
- guint16 ref;
- guint8 max;
- guint8 seq;
- GSList *l;
-
- decode_hex_own_buf(assembly_pdu1, -1, &pdu_len, 0, pdu);
- sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len1, &sms);
-
- sms_extract_concatenation(&sms, &ref, &max, &seq);
- l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
- &sms.deliver.oaddr, ref, max, seq);
-
- if (g_test_verbose()) {
- g_print("Ref: %u\n", ref);
- g_print("Max: %u\n", max);
- g_print("From: %s\n",
- sms_address_to_string(&sms.deliver.oaddr));
- }
-
- g_assert(g_slist_length(assembly->assembly_list) == 1);
- g_assert(l == NULL);
-
- decode_hex_own_buf(assembly_pdu2, -1, &pdu_len, 0, pdu);
- sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len2, &sms);
-
- sms_extract_concatenation(&sms, &ref, &max, &seq);
- l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
- &sms.deliver.oaddr, ref, max, seq);
- g_assert(l == NULL);
-
- sms_assembly_free(assembly);
-
- assembly = sms_assembly_new("1234");
-
- decode_hex_own_buf(assembly_pdu3, -1, &pdu_len, 0, pdu);
- sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len3, &sms);
-
- sms_extract_concatenation(&sms, &ref, &max, &seq);
- l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
- &sms.deliver.oaddr, ref, max, seq);
-
- g_assert(l != NULL);
-
- sms_assembly_free(assembly);
-}
-
static const char *ranges[] = { "1-5, 2, 3, 600, 569-900, 999",
"0-20, 33, 44, 50-60, 20-50, 1-5, 5, 3, 5",
NULL };
@@ -1731,9 +1679,6 @@ int main(int argc, char **argv)
test_cbs_encode_decode);
g_test_add_func("/testsms/Test CBS Assembly", test_cbs_assembly);
- g_test_add_func("/testsms/Test SMS Assembly Serialize",
- test_serialize_assembly);
-
g_test_add_func("/testsms/Range minimizer", test_range_minimizer);
g_test_add_func("/testsms/Status Report Assembly", test_sr_assembly);