osmo-msc/src/libmsc
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
..
Makefile.am large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
call_leg.c Request Osmux CID and forward it in Assign Req and Assign Compl 2019-05-21 18:32:38 +02:00
cell_id_list.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
ctrl_commands.c vlr_subscr: use osmo_use_count 2019-04-12 02:15:25 +02:00
db.c Introduce initial unit test for db_sms_* API 2019-06-03 17:28:35 +07:00
e_link.c GSUP: include terminating nul in inter-MSC source/destination name 2019-05-08 17:02:32 +02:00
gsm_04_08.c libmsc/gsm_04_08.c: clarify IMEI rejection in gsm48_rx_mm_serv_req() 2019-05-12 10:35:18 +00:00
gsm_04_08_cc.c fix regression: fix internal MNCC operation 2019-05-09 01:23:09 +02:00
gsm_04_11.c libmsc/gsm_04_11.c: properly handle MMTS indication 2019-05-19 07:34:35 +00:00
gsm_04_11_gsup.c libmsc/gsm_04_11.c: properly handle MMTS indication 2019-05-19 07:34:35 +00:00
gsm_04_14.c rename bscconfig.h to config.h, cleanup 2019-05-08 17:02:32 +02:00
gsm_04_80.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
gsm_09_11.c add DSS logging category 2019-05-12 10:32:42 +00:00
gsup_client_mux.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
mncc.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
mncc_builtin.c fix regression: fix internal MNCC operation 2019-05-09 01:23:09 +02:00
mncc_call.c libmsc/mncc_call.c: fix uninitialized access of stack memory 2019-05-13 20:15:04 +00:00
mncc_sock.c fix regression: fix internal MNCC operation 2019-05-09 01:23:09 +02:00
msc_a.c Request Osmux CID and forward it in Assign Req and Assign Compl 2019-05-21 18:32:38 +02:00
msc_a_remote.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
msc_ho.c libmsc/msc_ho.c: fix unreacheable check of MSC-T role allocation 2019-05-13 20:15:04 +00:00
msc_i.c call_leg: remove unused event MSC_EV_CALL_LEG_RTP_RELEASED 2019-05-10 07:13:41 +00:00
msc_i_remote.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
msc_net_init.c rename bscconfig.h to config.h, cleanup 2019-05-08 17:02:32 +02:00
msc_t.c Use GSM23003_MSISDN_MAX_DIGITS from libosmogsm 2019-05-29 08:48:16 +00:00
msc_t_remote.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
msc_vty.c libmsc/msc_vty.c: do not abuse strlen() to check char buffers 2019-06-03 07:18:41 +00:00
msub.c msub_check_for_release(): Initialize msc_role_a_c 2019-05-09 08:42:48 +00:00
neighbor_ident.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
neighbor_ident_vty.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
paging.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
ran_conn.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
ran_infra.c rename bscconfig.h to config.h, cleanup 2019-05-08 17:02:32 +02:00
ran_msg.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
ran_msg_a.c Request Osmux CID and forward it in Assign Req and Assign Compl 2019-05-21 18:32:38 +02:00
ran_msg_iu.c Iu: Send SMS over SAPI-3 2019-05-10 23:56:49 +02:00
ran_peer.c bssap: Detect BSC Osmux support on RESET (ACK) recv 2019-05-19 07:28:02 +00:00
ran_up_l2.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
rrlp.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
rtp_stream.c Request Osmux CID and forward it in Assign Req and Assign Compl 2019-05-21 18:32:38 +02:00
sccp_ran.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
sgs_iface.c sgs_iface: detect and react to VLR/HLR failure 2019-05-27 11:49:50 +00:00
sgs_server.c libmsc/sgs_server.c: do not override rc in case of SCTP_SHUTDOWN_EVENT 2019-05-13 20:15:04 +00:00
sgs_vty.c libmsc: fix: properly initialize the SGs server 2019-03-28 17:10:11 +07:00
silent_call.c large refactoring: support inter-BSC and inter-MSC Handover 2019-05-08 17:02:32 +02:00
smpp_openbsc.c smpp: Make libsmpp34 use talloc for its allocations 2019-05-08 23:49:45 +02:00
smpp_smsc.c smpp_smsc: Call destroy_tlv() when using build_tlv() 2019-04-10 10:53:23 +00:00
smpp_smsc.h SMPP: Don't accept password or system-id exceeding spec length 2019-05-10 07:07:00 +00:00
smpp_utils.c dissolve libcommon: drop debug.c 2018-03-22 17:05:42 +01:00
smpp_vty.c Write configuration correctly from vty (alert notifications) 2019-03-29 22:48:38 +00:00
sms_queue.c Use GSM23003_MSISDN_MAX_DIGITS from libosmogsm 2019-05-29 08:48:16 +00:00
transaction.c transaction: accept trans_type enum in trans_log_subsys() 2019-05-26 09:27:22 +00:00