<p>fixeria <strong>uploaded patch set #5</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-msc/+/13629">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Introduce initial unit test for db_sms_* API<br><br>Since OsmoMSC has built-in SMSC, it needs to store the messages<br>somewhere. Currently we use libdbi and SQLite3 back-end for that.<br><br>For a long time, the db_sms_* API remained uncovered by unit tests.<br>This change aims to fix that, and does cover the following calls:<br><br>  - db_sms_store(),<br>  - db_sms_get(),<br><br>  - db_sms_get_next_unsent(),<br>  - db_sms_mark_delivered(),<br><br>  - db_sms_delete_sent_message_by_id(),<br>  - db_sms_delete_by_msisdn(),<br>  - db_sms_delete_oldest_expired_message().<br><br>Due to performance reasons, the test database is initialized in<br>RAM using the magic filename ':memory:'. This is a feature of<br>SQLite3 (and not libdbi), see:<br><br>  https://www.sqlite.org/inmemorydb.html<br><br>Of course, this unit test helped to discover some problems:<br><br>  1) Storing an SMS with empty TP-User-Data (TP-UDL=0) causes<br>     buffer overruns in both db_sms_store() and db_sms_get().<br><br>  2) TP-User-Data-Length is always being interpreted in octets,<br>     regardless of DCS (Data Coding Scheme). This results in<br>     storing garbage in the database if the default 7-bit<br>     encoding is used. Fortunately, the 'user_data' buffer<br>     in structure 'gsm_sms' is large emough, so we don't<br>     experience buffer overruns.<br><br>  3) db_sms_delete_oldest_expired_message() doesn't work<br>     as expected. Instead of removing the *oldest* expired<br>     message, it tries to remove the *newest* one.<br><br>The current test expectations do reflect these problems.<br>All of them will be fixed in the follow-up patches.<br><br>Change-Id: Id94ad35b6f78f839137db2e17010fbf9b40111a3<br>---<br>M configure.ac<br>M src/libmsc/db.c<br>M tests/Makefile.am<br>A tests/db_sms/Makefile.am<br>A tests/db_sms/db_sms_test.c<br>A tests/db_sms/db_sms_test.err<br>A tests/db_sms/db_sms_test.ok<br>M tests/testsuite.at<br>8 files changed, 714 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/29/13629/5</pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-msc/+/13629">change 13629</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-msc/+/13629"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-msc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id94ad35b6f78f839137db2e17010fbf9b40111a3 </div>
<div style="display:none"> Gerrit-Change-Number: 13629 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: Max <suraev@alumni.ntnu.no> </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>