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-04-09 09:55:44 +00:00
|
|
|
AM_CPPFLAGS = \
|
|
|
|
$(all_includes) \
|
|
|
|
-I$(top_srcdir)/include \
|
|
|
|
$(NULL)
|
|
|
|
|
|
|
|
AM_CFLAGS = \
|
|
|
|
-Wall \
|
|
|
|
-ggdb3 \
|
|
|
|
$(LIBOSMOCORE_CFLAGS) \
|
|
|
|
$(LIBOSMOGSM_CFLAGS) \
|
|
|
|
$(LIBASN1C_CFLAGS) \
|
|
|
|
$(LIBOSMOVTY_CFLAGS) \
|
|
|
|
$(LIBOSMOABIS_CFLAGS) \
|
|
|
|
$(LIBOSMOSIGTRAN_CFLAGS) \
|
|
|
|
$(LIBOSMORANAP_CFLAGS) \
|
|
|
|
$(LIBOSMONETIF_CFLAGS) \
|
|
|
|
$(LIBSMPP34_CFLAGS) \
|
|
|
|
$(LIBOSMOMGCPCLIENT_CFLAGS) \
|
|
|
|
$(LIBOSMOGSUPCLIENT_CFLAGS) \
|
|
|
|
$(NULL)
|
|
|
|
|
|
|
|
EXTRA_DIST = \
|
|
|
|
db_sms_test.ok \
|
|
|
|
db_sms_test.err \
|
|
|
|
$(NULL)
|
|
|
|
|
2022-04-13 16:55:35 +00:00
|
|
|
check_PROGRAMS = \
|
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-04-09 09:55:44 +00:00
|
|
|
db_sms_test \
|
|
|
|
$(NULL)
|
|
|
|
|
|
|
|
db_sms_test_SOURCES = \
|
|
|
|
db_sms_test.c \
|
|
|
|
$(srcdir)/../stubs.c \
|
|
|
|
$(NULL)
|
|
|
|
|
|
|
|
db_sms_test_LDADD = \
|
|
|
|
$(top_builddir)/src/libmsc/libmsc.a \
|
|
|
|
$(top_builddir)/src/libvlr/libvlr.a \
|
|
|
|
$(LIBSMPP34_LIBS) \
|
|
|
|
$(LIBOSMOCORE_LIBS) \
|
|
|
|
$(LIBOSMOGSM_LIBS) \
|
|
|
|
$(LIBOSMOVTY_LIBS) \
|
|
|
|
$(LIBOSMOABIS_LIBS) \
|
|
|
|
$(LIBOSMOSIGTRAN_LIBS) \
|
|
|
|
$(LIBOSMORANAP_LIBS) \
|
|
|
|
$(LIBASN1C_LIBS) \
|
|
|
|
$(LIBOSMOMGCPCLIENT_LIBS) \
|
|
|
|
$(LIBOSMOGSUPCLIENT_LIBS) \
|
|
|
|
$(LIBRARY_GSM) \
|
|
|
|
-ldbi \
|
|
|
|
$(NULL)
|