@@ -271,6 +271,8 @@ static int update_db_revision_3(void)
dbi_result result;
struct gsm_sms *sms;
+ LOGP(DDB, LOGL_NOTICE, "Going to migrate from revision 3\n");
+
result = dbi_conn_query(conn, "BEGIN EXCLUSIVE TRANSACTION");
if (!result) {
LOGP(DDB, LOGL_ERROR,
@@ -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
@@ -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();
new file mode 100644
@@ -0,0 +1,2 @@
+<000d> db.c:274 Going to migrate from revision 3
+[0;m
\ No newline at end of file
new file mode 100644
GIT binary patch
literal 29696
zcmeHQUufLO8P{mm`zQ7~e;jA;l5-+ML#*?9?e)gZo>Q*pB%9QY|K#j-b0H5xmd3Hp
z+SOXpnz)p5b`A=qv`{F04D=q_-b<g3yN4DEh0>Nnq4$tJ^r;U$C>&hjxU?jt{YF}8
zSKifn32{lXBi7o{%r~R?e&5VU`o5pm%WuwUHWAhgvn1O>j*D;zac>9$$8po}Hw1s)
z)(44*cL3k0Asv>S=EnYxd!Q8Ke^Qy3@FV<%n+&VM@)-gQfrCU~;0Uyy?1x=nJPCUQ
z6OzrzgG8LQ%@BA-5J;j3H+0w}TbiXA<=i3Y7Q&x%@L?N6fFaNY2=wBigtq`B@xQnz
zzTbm?kAH?g!5`y~@ck};fT_q3cpealMezVyo?qtsc|44ktE-k`YOBQL`+D#Yx@=U-
zHZiT!_zNzM@F1Eewj4PY!6GVbR<%lrl<k|ct*rA&jL+2bct`a(-P8Mj9>2rkU&D@V
z3;~9~{}qAP`CcxUizZWXF3wF(WY3RH<i;lQLUw98H#I$Zp*bth;oR0Q|C4{~e10lF
z`8sM>e<I&hf5NMOb22~m<vhLr=kX_S{|`I1F$5R_FCqecIEuV=gYU)BMD5_FJO4lB
z@I(CRi>Nr$i6Oucs3DNRDdgNW@Nt|<G+h55a`-WR$Z%o^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`5Oq9Br7wnbL^l)(Xd!@xRmsST
zLMrxnA5=(mRKX-~6U83urDtgVeQDQ<^w$C;x9b^&dS9}KsQ6d+>5#o$A(;v>HK61u
z<B3kX<Wwose?O;>$LTrt)4{0#Kmn?wF<K#P$gG3s#{ha$W=+;~qGqC0__YuXd|}_Z
z=^iQ{HWqw&`Y3Kx?eR#vzWdTJgcUd_6Fmd}7O#Wu_#-0Cx9g6w4*aT2z4dblq!Xhd
z%DU1v{78jP=YN8)()WLUins7}e4789{{w#?ve?EDI2Z&*PSepj7BV`4sFpD;U82)g
z90EzyN)pqH4HY#?uIR`sbb_=JrIK{kWlUYC7p9R@`%A7lryo5@CBqgNMb`C9$p-f{
zOlZXxU#7xg*E&zwB6hVh{t^`pTj^X;SSj3gC0W@JQ~S4VfCn7fPM@HnVe3}I<=L>;
GiTOV&I7qty
literal 0
HcmV?d00001
@@ -10,7 +10,9 @@ AT_CLEANUP
AT_SETUP([db])
AT_KEYWORDS([db])
cat $abs_srcdir/db/db_test.ok > expout
-AT_CHECK([$abs_top_builddir/tests/db/db_test], [], [expout], [ignore])
+cat $abs_srcdir/db/db_test.err > experr
+cat $abs_srcdir/db/hlr.sqlite3 > hlr.sqlite3
+AT_CHECK([$abs_top_builddir/tests/db/db_test], [], [expout], [experr])
AT_CLEANUP
AT_SETUP([channel])
From: Holger Hans Peter Freyther <holger@moiji-mobile.com> --- openbsc/src/libmsc/db.c | 2 ++ openbsc/tests/db/Makefile.am | 2 +- openbsc/tests/db/db_test.c | 34 ++++++++++++++++++++++++++++++++++ openbsc/tests/db/db_test.err | 2 ++ openbsc/tests/db/hlr.sqlite3 | Bin 0 -> 29696 bytes openbsc/tests/testsuite.at | 4 +++- 6 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 openbsc/tests/db/db_test.err create mode 100644 openbsc/tests/db/hlr.sqlite3