summaryrefslogtreecommitdiffstats
path: root/openbsc/tests/db
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-03-08 16:41:37 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-04-30 15:31:57 +0200
commit6114401b9bce9322fb2826fe41393d03d0981ab2 (patch)
tree99272bb5e327734193efdac665a7b81c92a0f664 /openbsc/tests/db
parente7cc9aa44730b42bcbab0cf179ac66a9b25f04da (diff)
db: Add testcase for the db migration.
Diffstat (limited to 'openbsc/tests/db')
-rw-r--r--openbsc/tests/db/Makefile.am2
-rw-r--r--openbsc/tests/db/db_test.c34
-rw-r--r--openbsc/tests/db/db_test.err2
-rw-r--r--openbsc/tests/db/hlr.sqlite3bin0 -> 29696 bytes
4 files changed, 37 insertions, 1 deletions
diff --git a/openbsc/tests/db/Makefile.am b/openbsc/tests/db/Makefile.am
index 26ea70345..647b51991 100644
--- a/openbsc/tests/db/Makefile.am
+++ b/openbsc/tests/db/Makefile.am
@@ -2,7 +2,7 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBSMPP34_CFLAGS) $(COVERAGE_CFLAGS)
AM_LDFLAGS = $(COVERAGE_LDFLAGS)
-EXTRA_DIST = db_test.ok
+EXTRA_DIST = db_test.ok db_test.err hlr.sqlite3
noinst_PROGRAMS = db_test
diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c
index ee2fee7b2..1494e77f7 100644
--- a/openbsc/tests/db/db_test.c
+++ b/openbsc/tests/db/db_test.c
@@ -118,6 +118,39 @@ static void test_sms(void)
subscr_put(subscr);
}
+static void test_sms_migrate(void)
+{
+ struct gsm_subscriber *rcv_subscr;
+ struct gsm_sms *sms;
+ static const uint8_t user_data_1[] = {
+ 0x41, 0xf1, 0xd8, 0x05, 0x22, 0x96, 0xcd, 0x2e,
+ 0x90, 0xf1, 0xfd, 0x06, 0x00 };
+ static const uint8_t user_data_2[] = {
+ 0x41, 0xf1, 0xd8, 0x05, 0x22, 0x96, 0xcd, 0x2e,
+ 0xd0, 0xf1, 0xfd, 0x06, 0x00 };
+
+ rcv_subscr = db_get_subscriber(GSM_SUBSCRIBER_IMSI, "901010000001111");
+ rcv_subscr->net = &dummy_net;
+
+ sms = db_sms_get(&dummy_net, 1);
+ OSMO_ASSERT(sms->id == 1);
+ OSMO_ASSERT(sms->receiver == rcv_subscr);
+ OSMO_ASSERT(strcmp(sms->text, "Abc. Def. Foo") == 0);
+ OSMO_ASSERT(sms->user_data_len == ARRAY_SIZE(user_data_1));
+ OSMO_ASSERT(memcmp(sms->user_data, user_data_1, ARRAY_SIZE(user_data_1)) == 0);
+ sms_free(sms);
+
+ sms = db_sms_get(&dummy_net, 2);
+ OSMO_ASSERT(sms->id == 2);
+ OSMO_ASSERT(sms->receiver == rcv_subscr);
+ OSMO_ASSERT(strcmp(sms->text, "Abc. Def. Goo") == 0);
+ OSMO_ASSERT(sms->user_data_len == ARRAY_SIZE(user_data_2));
+ OSMO_ASSERT(memcmp(sms->user_data, user_data_2, ARRAY_SIZE(user_data_2)) == 0);
+ sms_free(sms);
+
+ subscr_put(rcv_subscr);
+}
+
int main()
{
char scratch_str[256];
@@ -202,6 +235,7 @@ int main()
SUBSCR_PUT(alice);
test_sms();
+ test_sms_migrate();
db_fini();
diff --git a/openbsc/tests/db/db_test.err b/openbsc/tests/db/db_test.err
new file mode 100644
index 000000000..0a0f2f38c
--- /dev/null
+++ b/openbsc/tests/db/db_test.err
@@ -0,0 +1,2 @@
+<000d> db.c:274 Going to migrate from revision 3
+ \ No newline at end of file
diff --git a/openbsc/tests/db/hlr.sqlite3 b/openbsc/tests/db/hlr.sqlite3
new file mode 100644
index 000000000..e59dcdca3
--- /dev/null
+++ b/openbsc/tests/db/hlr.sqlite3
Binary files differ