osmo-msc/tests
Vadim Yanitskiy e1e7247500 Introduce initial unit test for db_sms_* API
Since OsmoMSC has built-in SMSC, it needs to store the messages
somewhere. Currently we use libdbi and SQLite3 back-end for that.

For a long time, the db_sms_* API remained uncovered by unit tests.
This change aims to fix that, and does cover the following calls:

  - db_sms_store(),
  - db_sms_get(),

  - db_sms_get_next_unsent(),
  - db_sms_mark_delivered(),

  - db_sms_delete_sent_message_by_id(),
  - db_sms_delete_by_msisdn(),
  - db_sms_delete_oldest_expired_message().

Due to performance reasons, the test database is initialized in
RAM using the magic filename ':memory:'. This is a feature of
SQLite3 (and not libdbi), see:

  https://www.sqlite.org/inmemorydb.html

Of course, this unit test helped to discover some problems:

  1) Storing an SMS with empty TP-User-Data (TP-UDL=0) causes
     buffer overruns in both db_sms_store() and db_sms_get().

  2) TP-User-Data-Length is always being interpreted in octets,
     regardless of DCS (Data Coding Scheme). This results in
     storing garbage in the database if the default 7-bit
     encoding is used. Fortunately, the 'user_data' buffer
     in structure 'gsm_sms' is large emough, so we don't
     experience buffer overruns.

  3) db_sms_delete_oldest_expired_message() doesn't work
     as expected. Instead of removing the *oldest* expired
     message, it tries to remove the *newest* one.

The current test expectations do reflect these problems.
All of them will be fixed in the follow-up patches.

Change-Id: Id94ad35b6f78f839137db2e17010fbf9b40111a3
2019-06-03 17:28:35 +07:00
..
db_sms Introduce initial unit test for db_sms_* API 2019-06-03 17:28:35 +07:00
msc_vlr tests: share stubs.h from msc_vlr_test as stubs.c 2019-06-03 17:17:58 +07:00
smpp use osmo_init_logging2() with proper talloc ctx 2018-03-30 23:20:03 +02:00
sms_queue Use GSM23003_MSISDN_MAX_DIGITS from libosmogsm 2019-05-29 08:48:16 +00:00
Makefile.am Introduce initial unit test for db_sms_* API 2019-06-03 17:28:35 +07:00
atlocal.in remove further files and autotest/autoconf bits irrelevant to osmo-msc 2017-10-03 09:44:23 +08:00
ctrl_test_runner.py python tests: use py shebang instead of $(PYTHON) 2018-12-05 19:35:11 +00:00
smpp_test_runner.py python tests: use py shebang instead of $(PYTHON) 2018-12-05 19:35:11 +00:00
stubs.c tests: share stubs.h from msc_vlr_test as stubs.c 2019-06-03 17:17:58 +07:00
test_neighbor_ident.vty vty/cfg: add missing write-back of inter-BSC and inter-MSC HO config 2019-05-09 02:06:42 +02:00
test_nodes.vty vty: Add option to enable osmux towards BSCs 2019-05-19 07:28:02 +00:00
testsuite.at Introduce initial unit test for db_sms_* API 2019-06-03 17:28:35 +07:00
vty_test_runner.py python tests: use py shebang instead of $(PYTHON) 2018-12-05 19:35:11 +00:00