<p>Max <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/12571">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">VLR tests: use msgb_eq_data_print() for comparison<br><br>This simplifies tests refactoring by showing exact byte where mismatch<br>happened. It also makes code more readable.<br><br>No changes in expected test output are necessary because the additional<br>logging will be triggered iff the test fails so the result will be<br>visible only during debugging of unit test issues.<br><br>Change-Id: If9771c973f2bc55580f4c146bdbeeb1609d56786<br>---<br>M tests/msc_vlr/msc_vlr_tests.c<br>1 file changed, 12 insertions(+), 11 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c</span><br><span>index 296f055..eb6df09 100644</span><br><span>--- a/tests/msc_vlr/msc_vlr_tests.c</span><br><span>+++ b/tests/msc_vlr/msc_vlr_tests.c</span><br><span>@@ -570,15 +570,21 @@</span><br><span> int __real_osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg);</span><br><span> int __wrap_osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-       const char *is = osmo_hexdump_nospc(msg->data, msg->len);</span><br><span style="color: hsl(120, 100%, 40%);">+       uint8_t buf[512];</span><br><span style="color: hsl(120, 100%, 40%);">+     int len;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   fprintf(stderr, "GSUP --> HLR: %s: %s\n",</span><br><span style="color: hsl(0, 100%, 40%);">-          osmo_gsup_message_type_name(msg->data[0]), is);</span><br><span style="color: hsl(120, 100%, 40%);">+            osmo_gsup_message_type_name(msg->data[0]), osmo_hexdump_nospc(msg->data, msg->len));</span><br><span> </span><br><span>    OSMO_ASSERT(gsup_tx_expected);</span><br><span style="color: hsl(0, 100%, 40%);">-  if (strcmp(gsup_tx_expected, is)) {</span><br><span style="color: hsl(0, 100%, 40%);">-             fprintf(stderr, "Mismatch! Expected:\n%s\n", gsup_tx_expected);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(strlen(gsup_tx_expected) <= (sizeof(buf) * 2));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      len = osmo_hexparse(gsup_tx_expected, buf, sizeof(buf));</span><br><span style="color: hsl(120, 100%, 40%);">+      if (len < 1)</span><br><span>              abort();</span><br><span style="color: hsl(0, 100%, 40%);">-        }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!msgb_eq_data_print(msg, buf, len))</span><br><span style="color: hsl(120, 100%, 40%);">+               abort();</span><br><span> </span><br><span>         talloc_free(msg);</span><br><span>    gsup_tx_confirmed = true;</span><br><span>@@ -596,13 +602,8 @@</span><br><span> </span><br><span>         /* Mask the sequence number out before comparing */</span><br><span>  msg->data[1] &= 0x3f;</span><br><span style="color: hsl(0, 100%, 40%);">-    if (msg->len != dtap_tx_expected->len</span><br><span style="color: hsl(0, 100%, 40%);">-         || memcmp(msg->data, dtap_tx_expected->data, msg->len)) {</span><br><span style="color: hsl(0, 100%, 40%);">-          fprintf(stderr, "Mismatch! Expected:\n%s\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                 osmo_hexdump_nospc(dtap_tx_expected->data,</span><br><span style="color: hsl(0, 100%, 40%);">-                                      dtap_tx_expected->len));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!msgb_eq_data_print(msg, dtap_tx_expected->data, dtap_tx_expected->len))</span><br><span>           abort();</span><br><span style="color: hsl(0, 100%, 40%);">-        }</span><br><span> </span><br><span>        btw("DTAP matches expected message");</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12571">change 12571</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/12571"/><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-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: If9771c973f2bc55580f4c146bdbeeb1609d56786 </div>
<div style="display:none"> Gerrit-Change-Number: 12571 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Stefan Sperling <stsp@stsp.name> </div>
<div style="display:none"> Gerrit-Reviewer: osmith <osmith@sysmocom.de> </div>