<p>Pau Espin Pedrol has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/9171">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">tests: jibuf_test: Add scenario to show out-of-order bug<br><br>Related: OS#3262<br><br>Change-Id: I1e78cc44f8a04dcb983352b513f8de2574b2394b<br>---<br>M tests/jibuf/jibuf_test.c<br>M tests/jibuf/jibuf_test.ok<br>2 files changed, 83 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/71/9171/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/jibuf/jibuf_test.c b/tests/jibuf/jibuf_test.c</span><br><span>index c0c24fd..7993a65 100644</span><br><span>--- a/tests/jibuf/jibuf_test.c</span><br><span>+++ b/tests/jibuf/jibuf_test.c</span><br><span>@@ -619,6 +619,66 @@</span><br><span>  osmo_jibuf_delete(jb);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* This test aims at testing scenarios described in OS#3262, in which syncpoint</span><br><span style="color: hsl(120, 100%, 40%);">+   packets can provoke a situation in which packets are stored out-of-order in</span><br><span style="color: hsl(120, 100%, 40%);">+   the queue. */</span><br><span style="color: hsl(120, 100%, 40%);">+static void test_rtp_marker_queue_order()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      int min_delay = 60;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct msgb *msg;</span><br><span style="color: hsl(120, 100%, 40%);">+     struct rtp_hdr *rtph;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       printf("===test_rtp_marker_queue_order===\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    clock_override_enable(true);</span><br><span style="color: hsl(120, 100%, 40%);">+  clock_override_set(0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+     rtp_init(32, 400);</span><br><span style="color: hsl(120, 100%, 40%);">+    jb = osmo_jibuf_alloc(NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+  osmo_jibuf_set_dequeue_cb(jb, dequeue_cb, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+      osmo_jibuf_set_min_delay(jb, min_delay);</span><br><span style="color: hsl(120, 100%, 40%);">+      osmo_jibuf_set_max_delay(jb, 200);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* First rtp at t=0, should be scheduled in min_delay time */</span><br><span style="color: hsl(120, 100%, 40%);">+ clock_debug("enqueue 1st packet");</span><br><span style="color: hsl(120, 100%, 40%);">+  ENQUEUE_NEXT(jb);</span><br><span style="color: hsl(120, 100%, 40%);">+     clock_override_add(0, TIME_RTP_PKT_MS*1000);</span><br><span style="color: hsl(120, 100%, 40%);">+  clock_debug("enqueue 2nd packet");</span><br><span style="color: hsl(120, 100%, 40%);">+  ENQUEUE_NEXT(jb);</span><br><span style="color: hsl(120, 100%, 40%);">+     clock_override_add(0, TIME_RTP_PKT_MS*1000);</span><br><span style="color: hsl(120, 100%, 40%);">+  clock_debug("enqueue 3rd packet");</span><br><span style="color: hsl(120, 100%, 40%);">+  ENQUEUE_NEXT(jb);</span><br><span style="color: hsl(120, 100%, 40%);">+     clock_override_add(0, TIME_RTP_PKT_MS*1000);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* We then emulate an scenario in which an Osmux queue in front of us</span><br><span style="color: hsl(120, 100%, 40%);">+    receives a new frame before expected time, which means the packets in</span><br><span style="color: hsl(120, 100%, 40%);">+         the osmux genreated rtp queue will be flushed and sent to jibuf</span><br><span style="color: hsl(120, 100%, 40%);">+       directly. On top, the first packet of the new frame has the RTP</span><br><span style="color: hsl(120, 100%, 40%);">+       Marker bit set. */</span><br><span style="color: hsl(120, 100%, 40%);">+ clock_debug("enqueue 3 packets instantly");</span><br><span style="color: hsl(120, 100%, 40%);">+ ENQUEUE_NEXT(jb); /* scheduled min_delay+0 */</span><br><span style="color: hsl(120, 100%, 40%);">+ ENQUEUE_NEXT(jb); /* a min_delay+TIME_RTP_PKT_MS */</span><br><span style="color: hsl(120, 100%, 40%);">+   ENQUEUE_NEXT(jb); /* scheduled min_delay+TIME_RTP_PKT_MS*2 */</span><br><span style="color: hsl(120, 100%, 40%);">+ clock_debug("enqueue pkt with marker=1 instantly");</span><br><span style="color: hsl(120, 100%, 40%);">+ msg = rtp_next();</span><br><span style="color: hsl(120, 100%, 40%);">+     rtph = osmo_rtp_get_hdr(msg);</span><br><span style="color: hsl(120, 100%, 40%);">+ rtph->marker = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+  OSMO_ASSERT(osmo_jibuf_enqueue(jb, msg) == 0); /* syncpoint, scheduled in min_delay+0 */</span><br><span style="color: hsl(120, 100%, 40%);">+      osmo_select_main(0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        clock_override_add(0, TIME_RTP_PKT_MS*1000);</span><br><span style="color: hsl(120, 100%, 40%);">+  clock_debug("enqueue pkt after syncpoint");</span><br><span style="color: hsl(120, 100%, 40%);">+ ENQUEUE_NEXT(jb); /* scheduled min_delay+0 */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       clock_debug("all packets dequeued");</span><br><span style="color: hsl(120, 100%, 40%);">+        clock_override_add(0, min_delay*1000);</span><br><span style="color: hsl(120, 100%, 40%);">+        osmo_select_main(0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* This assert shows that packets are queued out of order in this case:*/</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(!osmo_jibuf_empty(jb));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_jibuf_delete(jb);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void test_rtp_out_of_sync(unsigned int time_inc_ms, uint16_t seq_nosync_inc, uint32_t ts_nosync_inc, bool expect_drop)</span><br><span> {</span><br><span>    int min_delay = 60;</span><br><span>@@ -754,6 +814,7 @@</span><br><span>    test_seq_wraparound();</span><br><span>       test_timestamp_wraparound();</span><br><span>         test_rtp_marker();</span><br><span style="color: hsl(120, 100%, 40%);">+    test_rtp_marker_queue_order();</span><br><span>       test_rtp_out_of_sync(80*TIME_RTP_PKT_MS, 5, 5*SAMPLES_PER_PKT, true);</span><br><span>        test_rtp_out_of_sync(80*TIME_RTP_PKT_MS, 6, 5*SAMPLES_PER_PKT, false);</span><br><span>       test_rtp_out_of_sync(80*TIME_RTP_PKT_MS, 5, 5*SAMPLES_PER_PKT + 3, false);</span><br><span>diff --git a/tests/jibuf/jibuf_test.ok b/tests/jibuf/jibuf_test.ok</span><br><span>index e495435..6bf52fb 100644</span><br><span>--- a/tests/jibuf/jibuf_test.ok</span><br><span>+++ b/tests/jibuf/jibuf_test.ok</span><br><span>@@ -365,6 +365,28 @@</span><br><span> sys={0.200000}, mono={0.200000}: clock_override_add</span><br><span> sys={0.200000}, mono={0.200000}: dequeue: seq=35 ts=880 INTERMEDIATE</span><br><span> sys={0.200000}, mono={0.200000}: dequeue: seq=36 ts=1040 LATEST</span><br><span style="color: hsl(120, 100%, 40%);">+===test_rtp_marker_queue_order===</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.000000}, mono={0.000000}: clock_override_set</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.000000}, mono={0.000000}: enqueue 1st packet</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.020000}, mono={0.020000}: clock_override_add</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.020000}, mono={0.020000}: enqueue 2nd packet</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.040000}, mono={0.040000}: clock_override_add</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.040000}, mono={0.040000}: enqueue 3rd packet</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.060000}, mono={0.060000}: clock_override_add</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.060000}, mono={0.060000}: enqueue 3 packets instantly</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.060000}, mono={0.060000}: enqueue pkt with marker=1 instantly</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.060000}, mono={0.060000}: dequeue: seq=33 ts=560 INTERMEDIATE</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.080000}, mono={0.080000}: clock_override_add</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.080000}, mono={0.080000}: enqueue pkt after syncpoint</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.080000}, mono={0.080000}: all packets dequeued</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: clock_override_add</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: dequeue: seq=34 ts=720 INTERMEDIATE</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: dequeue: seq=35 ts=880 INTERMEDIATE</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: dequeue: seq=36 ts=1040 INTERMEDIATE</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: dequeue: seq=39 ts=1520 INTERMEDIATE</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: dequeue: seq=37 ts=1200 INTERMEDIATE</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: dequeue: seq=40 ts=1680 LATEST</span><br><span style="color: hsl(120, 100%, 40%);">+sys={0.140000}, mono={0.140000}: dequeue: seq=38 ts=1360 INTERMEDIATE</span><br><span> ===test_rtp_out_of_sync(1600, 5, 800, 1)===</span><br><span> sys={0.000000}, mono={0.000000}: clock_override_set</span><br><span> sys={0.000000}, mono={0.000000}: enqueue 1st packet (seq=33, ts=560)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9171">change 9171</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/9171"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-netif </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1e78cc44f8a04dcb983352b513f8de2574b2394b </div>
<div style="display:none"> Gerrit-Change-Number: 9171 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Pau Espin Pedrol <pespin@sysmocom.de> </div>