summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-10-24 23:26:27 +0200
committerHarald Welte <laforge@gnumonks.org>2017-10-28 16:49:33 +0000
commit7750d2cedc5403cd1d756d1d30a8e08fccd12f74 (patch)
treed6c4036ad34832f2f59746237b2d80e949f860cf /tests
parentcd7fa4502cc2e003ae1d6520f7a49fdaef490a3c (diff)
automatically create db tables on osmo-hlr invocation
If a database file is missing, osmo-hlr creates it, as is the default sqlite3 API behavior -- before this patch, that db file is created, but lacks useful tables. Actually also create initial tables in it, as osmo-nitb did. In effect, the 'vty-test' target in tests/Makefile.am no longer needs to create a database manually. (The 'ctrl-test' still does, because it also wants to add subscriber data on top of the bare tables.) Note: it could be desirable to bail if the desired database file does not exist. That is however a different semantic from this patch; this is not changing the fact that a db file is created, this just creates a usable one. Note: I am about to add osmo-hlr-db-tool to do database migration from osmo-nitb. For that, it is desirable to bootstrap a usable database, which is the core reason for this patch. Don't plainly duplicate hlr.sql to .c, but create db_bootstrap.h as a BUILT_SOURCE from reading in sql/hlr.sql and mangling via sed to a list of SQL statement strings. On each db_open(), run this bootstrap sequence. In sql/hlr.sql, these tweaks are necessary: * Add 'IF NOT EXISTS' to 'CREATE TABLE', so that the bootstrap sequence can be run on an already bootstrapped db. * Drop the final comment at the bottom, which ended up being an empty SQL statement and causing sqlite3 API errors, seemed to have no purpose anyway. Note: by composing the statement strings as multiline and including the SQL comments, sqlite3 actually retains the comments contained in table definitions and prints them back during 'sqlite3 hlr.db .dump'. Change-Id: If77dbbfe1af3e66aaec91cb6295b687f37678636
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/db/Makefile.am1
2 files changed, 1 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2dba6a1..f1cc710 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -51,7 +51,6 @@ VTY_TEST_DB = hlr_vty_test.db
# make vty-test U=-u
vty-test:
-rm -f $(VTY_TEST_DB)
- sqlite3 $(VTY_TEST_DB) < $(top_srcdir)/sql/hlr.sql
osmo_verify_transcript_vty.py -v \
-n OsmoHLR -p 4258 \
-r "$(top_builddir)/src/osmo-hlr -c $(top_srcdir)/doc/examples/osmo-hlr.cfg -l $(VTY_TEST_DB)" \
diff --git a/tests/db/Makefile.am b/tests/db/Makefile.am
index b706bec..55b1655 100644
--- a/tests/db/Makefile.am
+++ b/tests/db/Makefile.am
@@ -1,6 +1,7 @@
AM_CFLAGS = \
$(all_includes) \
-I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
-Wall \
-ggdb3 \
$(LIBOSMOCORE_CFLAGS) \