test_rechist.c revision b62ec17f
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov#include <assert.h>
350aadb33SDmitri Tikhonov#include <inttypes.h>
450aadb33SDmitri Tikhonov#include <stdio.h>
550aadb33SDmitri Tikhonov#include <stdlib.h>
650aadb33SDmitri Tikhonov#include <string.h>
750aadb33SDmitri Tikhonov
8fb3e20e0SDmitri Tikhonov#ifdef WIN32
9fb3e20e0SDmitri Tikhonov#include "vc_compat.h"
10fb3e20e0SDmitri Tikhonov#endif
11fb3e20e0SDmitri Tikhonov
1250aadb33SDmitri Tikhonov#include "lsquic_int_types.h"
1350aadb33SDmitri Tikhonov#include "lsquic_rechist.h"
1450aadb33SDmitri Tikhonov#include "lsquic_util.h"
1550aadb33SDmitri Tikhonov
1650aadb33SDmitri Tikhonov
1750aadb33SDmitri Tikhonovstatic void
1850aadb33SDmitri Tikhonovtest4 (void)
1950aadb33SDmitri Tikhonov{
2050aadb33SDmitri Tikhonov    lsquic_rechist_t rechist;
2150aadb33SDmitri Tikhonov    const struct lsquic_packno_range *range;
2250aadb33SDmitri Tikhonov    lsquic_packno_t packno;
2350aadb33SDmitri Tikhonov
24b62ec17fSDmitri Tikhonov    lsquic_rechist_init(&rechist, 0);
2550aadb33SDmitri Tikhonov
2650aadb33SDmitri Tikhonov    for (packno = 11917; packno <= 11941; ++packno)
2750aadb33SDmitri Tikhonov        lsquic_rechist_received(&rechist, packno, 0);
2850aadb33SDmitri Tikhonov    for (packno = 11946; packno <= 11994; ++packno)
2950aadb33SDmitri Tikhonov        lsquic_rechist_received(&rechist, packno, 0);
3050aadb33SDmitri Tikhonov
3150aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
3250aadb33SDmitri Tikhonov    assert(range);
3350aadb33SDmitri Tikhonov    assert(range->high == 11994);
3450aadb33SDmitri Tikhonov    assert(range->low == 11946);
3550aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
3650aadb33SDmitri Tikhonov    assert(range);
3750aadb33SDmitri Tikhonov    assert(range->high == 11941);
3850aadb33SDmitri Tikhonov    assert(range->low == 11917);
3950aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
4050aadb33SDmitri Tikhonov    assert(!range);
4150aadb33SDmitri Tikhonov
4250aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 11995, 0);
4350aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 11996, 0);
4450aadb33SDmitri Tikhonov
4550aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
4650aadb33SDmitri Tikhonov    assert(range);
4750aadb33SDmitri Tikhonov    assert(range->high == 11996);
4850aadb33SDmitri Tikhonov    assert(range->low == 11946);
4950aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
5050aadb33SDmitri Tikhonov    assert(range);
5150aadb33SDmitri Tikhonov    assert(range->high == 11941);
5250aadb33SDmitri Tikhonov    assert(range->low == 11917);
5350aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
5450aadb33SDmitri Tikhonov    assert(!range);
5550aadb33SDmitri Tikhonov
5650aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 11912, 0);
5750aadb33SDmitri Tikhonov    lsquic_rechist_stop_wait(&rechist, 11860);
5850aadb33SDmitri Tikhonov
5950aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
6050aadb33SDmitri Tikhonov    assert(range);
6150aadb33SDmitri Tikhonov    assert(range->high == 11996);
6250aadb33SDmitri Tikhonov    assert(range->low == 11946);
6350aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
6450aadb33SDmitri Tikhonov    assert(range);
6550aadb33SDmitri Tikhonov    assert(range->high == 11941);
6650aadb33SDmitri Tikhonov    assert(range->low == 11917);
6750aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
6850aadb33SDmitri Tikhonov    assert(range);
6950aadb33SDmitri Tikhonov    assert(range->high == 11912);
7050aadb33SDmitri Tikhonov    assert(range->low == 11912);
7150aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
7250aadb33SDmitri Tikhonov    assert(!range);
7350aadb33SDmitri Tikhonov
7450aadb33SDmitri Tikhonov    for (packno = 12169; packno <= 12193; ++packno)
7550aadb33SDmitri Tikhonov        lsquic_rechist_received(&rechist, packno, 0);
7650aadb33SDmitri Tikhonov
7750aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
7850aadb33SDmitri Tikhonov    assert(range);
7950aadb33SDmitri Tikhonov    assert(range->high == 12193);
8050aadb33SDmitri Tikhonov    assert(range->low == 12169);
8150aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
8250aadb33SDmitri Tikhonov    assert(range);
8350aadb33SDmitri Tikhonov    assert(range->high == 11996);
8450aadb33SDmitri Tikhonov    assert(range->low == 11946);
8550aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
8650aadb33SDmitri Tikhonov    assert(range);
8750aadb33SDmitri Tikhonov    assert(range->high == 11941);
8850aadb33SDmitri Tikhonov    assert(range->low == 11917);
8950aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
9050aadb33SDmitri Tikhonov    assert(range);
9150aadb33SDmitri Tikhonov    assert(range->high == 11912);
9250aadb33SDmitri Tikhonov    assert(range->low == 11912);
9350aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
9450aadb33SDmitri Tikhonov    assert(!range);
9550aadb33SDmitri Tikhonov
9650aadb33SDmitri Tikhonov    lsquic_rechist_cleanup(&rechist);
9750aadb33SDmitri Tikhonov}
9850aadb33SDmitri Tikhonov
9950aadb33SDmitri Tikhonov
10050aadb33SDmitri Tikhonovstatic void
10150aadb33SDmitri Tikhonovrechist2str (lsquic_rechist_t *rechist, char *buf, size_t bufsz)
10250aadb33SDmitri Tikhonov{
10350aadb33SDmitri Tikhonov    const struct lsquic_packno_range *range;
10450aadb33SDmitri Tikhonov    size_t off;
10550aadb33SDmitri Tikhonov    int n;
10650aadb33SDmitri Tikhonov
10750aadb33SDmitri Tikhonov    for (off = 0, range = lsquic_rechist_first(rechist);
10850aadb33SDmitri Tikhonov            range && off < bufsz;
10950aadb33SDmitri Tikhonov                off += n, range = lsquic_rechist_next(rechist))
11050aadb33SDmitri Tikhonov    {
11150aadb33SDmitri Tikhonov        n = snprintf(buf + off, bufsz - off, "[%"PRIu64"-%"PRIu64"]",
11250aadb33SDmitri Tikhonov                                                    range->high, range->low);
11350aadb33SDmitri Tikhonov        if (n < 0 || (size_t) n >= bufsz - off)
11450aadb33SDmitri Tikhonov            break;
11550aadb33SDmitri Tikhonov    }
11650aadb33SDmitri Tikhonov}
11750aadb33SDmitri Tikhonov
11850aadb33SDmitri Tikhonov
11950aadb33SDmitri Tikhonovstatic void
12050aadb33SDmitri Tikhonovtest5 (void)
12150aadb33SDmitri Tikhonov{
12250aadb33SDmitri Tikhonov    lsquic_rechist_t rechist;
12350aadb33SDmitri Tikhonov    char buf[100];
12450aadb33SDmitri Tikhonov
125b62ec17fSDmitri Tikhonov    lsquic_rechist_init(&rechist, 0);
12650aadb33SDmitri Tikhonov
12750aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 1, 0);
12850aadb33SDmitri Tikhonov    /* Packet 2 omitted because it could not be decrypted */
12950aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 3, 0);
13050aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 12, 0);
13150aadb33SDmitri Tikhonov
13250aadb33SDmitri Tikhonov    rechist2str(&rechist, buf, sizeof(buf));
13350aadb33SDmitri Tikhonov    assert(0 == strcmp(buf, "[12-12][3-3][1-1]"));
13450aadb33SDmitri Tikhonov
13550aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 4, 0);
13650aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 10, 0);
13750aadb33SDmitri Tikhonov
13850aadb33SDmitri Tikhonov    rechist2str(&rechist, buf, sizeof(buf));
13950aadb33SDmitri Tikhonov    assert(0 == strcmp(buf, "[12-12][10-10][4-3][1-1]"));
14050aadb33SDmitri Tikhonov
14150aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 6, 0);
14250aadb33SDmitri Tikhonov
14350aadb33SDmitri Tikhonov    rechist2str(&rechist, buf, sizeof(buf));
14450aadb33SDmitri Tikhonov    assert(0 == strcmp(buf, "[12-12][10-10][6-6][4-3][1-1]"));
14550aadb33SDmitri Tikhonov
14650aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 7, 0);
14750aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 8, 0);
14850aadb33SDmitri Tikhonov
14950aadb33SDmitri Tikhonov    rechist2str(&rechist, buf, sizeof(buf));
15050aadb33SDmitri Tikhonov    assert(0 == strcmp(buf, "[12-12][10-10][8-6][4-3][1-1]"));
15150aadb33SDmitri Tikhonov
15250aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 9, 0);
15350aadb33SDmitri Tikhonov
15450aadb33SDmitri Tikhonov    rechist2str(&rechist, buf, sizeof(buf));
15550aadb33SDmitri Tikhonov    assert(0 == strcmp(buf, "[12-12][10-6][4-3][1-1]"));
15650aadb33SDmitri Tikhonov
15750aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 5, 0);
15850aadb33SDmitri Tikhonov    lsquic_rechist_received(&rechist, 11, 0);
15950aadb33SDmitri Tikhonov
16050aadb33SDmitri Tikhonov    rechist2str(&rechist, buf, sizeof(buf));
16150aadb33SDmitri Tikhonov    assert(0 == strcmp(buf, "[12-3][1-1]"));
16250aadb33SDmitri Tikhonov
16350aadb33SDmitri Tikhonov    lsquic_rechist_cleanup(&rechist);
16450aadb33SDmitri Tikhonov}
16550aadb33SDmitri Tikhonov
16650aadb33SDmitri Tikhonov
167b62ec17fSDmitri Tikhonovstatic void
168b62ec17fSDmitri Tikhonovtest_rand_sequence (unsigned seed)
169b62ec17fSDmitri Tikhonov{
170b62ec17fSDmitri Tikhonov    struct lsquic_rechist rechist;
171b62ec17fSDmitri Tikhonov    const struct lsquic_packno_range *range;
172b62ec17fSDmitri Tikhonov    lsquic_packno_t prev_low;
173b62ec17fSDmitri Tikhonov    enum received_st st;
174b62ec17fSDmitri Tikhonov    unsigned i;
175b62ec17fSDmitri Tikhonov
176b62ec17fSDmitri Tikhonov    lsquic_rechist_init(&rechist, 1);
177b62ec17fSDmitri Tikhonov    srand(seed);
178b62ec17fSDmitri Tikhonov
179b62ec17fSDmitri Tikhonov    for (i = 0; i < 10000; ++i)
180b62ec17fSDmitri Tikhonov    {
181b62ec17fSDmitri Tikhonov        st = lsquic_rechist_received(&rechist, (unsigned) rand(), 0);
182b62ec17fSDmitri Tikhonov        assert(st == REC_ST_OK || st == REC_ST_DUP);
183b62ec17fSDmitri Tikhonov    }
184b62ec17fSDmitri Tikhonov
185b62ec17fSDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
186b62ec17fSDmitri Tikhonov    assert(range);
187b62ec17fSDmitri Tikhonov    assert(range->high >= range->low);
188b62ec17fSDmitri Tikhonov    prev_low = range->low;
189b62ec17fSDmitri Tikhonov
190b62ec17fSDmitri Tikhonov    while (range = lsquic_rechist_next(&rechist), range != NULL)
191b62ec17fSDmitri Tikhonov    {
192b62ec17fSDmitri Tikhonov        assert(range->high >= range->low);
193b62ec17fSDmitri Tikhonov        assert(range->high < prev_low);
194b62ec17fSDmitri Tikhonov        prev_low = range->low;
195b62ec17fSDmitri Tikhonov    }
196b62ec17fSDmitri Tikhonov
197b62ec17fSDmitri Tikhonov    lsquic_rechist_cleanup(&rechist);
198b62ec17fSDmitri Tikhonov}
199b62ec17fSDmitri Tikhonov
200b62ec17fSDmitri Tikhonov
201b62ec17fSDmitri Tikhonovstruct shuffle_elem {
202b62ec17fSDmitri Tikhonov    unsigned    packno;
203b62ec17fSDmitri Tikhonov    int         rand;
204b62ec17fSDmitri Tikhonov};
205b62ec17fSDmitri Tikhonov
206b62ec17fSDmitri Tikhonov
207b62ec17fSDmitri Tikhonovstatic int
208b62ec17fSDmitri Tikhonovcomp_els (const void *a_p, const void *b_p)
209b62ec17fSDmitri Tikhonov{
210b62ec17fSDmitri Tikhonov    const struct shuffle_elem *a = a_p, *b = b_p;
211b62ec17fSDmitri Tikhonov    if (a->rand < b->rand)
212b62ec17fSDmitri Tikhonov        return -1;
213b62ec17fSDmitri Tikhonov    if (a->rand > b->rand)
214b62ec17fSDmitri Tikhonov        return 1;
215b62ec17fSDmitri Tikhonov    return (a->packno > b->packno) - (b->packno > a->packno);
216b62ec17fSDmitri Tikhonov}
217b62ec17fSDmitri Tikhonov
218b62ec17fSDmitri Tikhonov
219b62ec17fSDmitri Tikhonovstatic void
220b62ec17fSDmitri Tikhonovtest_shuffle_1000 (unsigned seed)
221b62ec17fSDmitri Tikhonov{
222b62ec17fSDmitri Tikhonov    struct lsquic_rechist rechist;
223b62ec17fSDmitri Tikhonov    const struct lsquic_packno_range *range;
224b62ec17fSDmitri Tikhonov    enum received_st st;
225b62ec17fSDmitri Tikhonov    unsigned i;
226b62ec17fSDmitri Tikhonov    struct shuffle_elem *els;
227b62ec17fSDmitri Tikhonov
228b62ec17fSDmitri Tikhonov    els = malloc(sizeof(els[0]) * 10000);
229b62ec17fSDmitri Tikhonov    lsquic_rechist_init(&rechist, 1);
230b62ec17fSDmitri Tikhonov    srand(seed);
231b62ec17fSDmitri Tikhonov
232b62ec17fSDmitri Tikhonov    for (i = 0; i < 10000; ++i)
233b62ec17fSDmitri Tikhonov    {
234b62ec17fSDmitri Tikhonov        els[i].packno = i;
235b62ec17fSDmitri Tikhonov        els[i].rand   = rand();
236b62ec17fSDmitri Tikhonov    }
237b62ec17fSDmitri Tikhonov
238b62ec17fSDmitri Tikhonov    qsort(els, 10000, sizeof(els[0]), comp_els);
239b62ec17fSDmitri Tikhonov
240b62ec17fSDmitri Tikhonov    for (i = 0; i < 10000; ++i)
241b62ec17fSDmitri Tikhonov    {
242b62ec17fSDmitri Tikhonov        st = lsquic_rechist_received(&rechist, els[i].packno, 0);
243b62ec17fSDmitri Tikhonov        assert(st == REC_ST_OK || st == REC_ST_DUP);
244b62ec17fSDmitri Tikhonov    }
245b62ec17fSDmitri Tikhonov
246b62ec17fSDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
247b62ec17fSDmitri Tikhonov    assert(range);
248b62ec17fSDmitri Tikhonov    assert(range->high == 9999);
249b62ec17fSDmitri Tikhonov    assert(range->low == 0);
250b62ec17fSDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
251b62ec17fSDmitri Tikhonov    assert(!range);
252b62ec17fSDmitri Tikhonov
253b62ec17fSDmitri Tikhonov    lsquic_rechist_cleanup(&rechist);
254b62ec17fSDmitri Tikhonov    free(els);
255b62ec17fSDmitri Tikhonov}
256b62ec17fSDmitri Tikhonov
257b62ec17fSDmitri Tikhonov
25850aadb33SDmitri Tikhonovint
25950aadb33SDmitri Tikhonovmain (void)
26050aadb33SDmitri Tikhonov{
26150aadb33SDmitri Tikhonov    enum received_st st;
26250aadb33SDmitri Tikhonov    lsquic_rechist_t rechist;
26350aadb33SDmitri Tikhonov    unsigned i;
26450aadb33SDmitri Tikhonov    const struct lsquic_packno_range *range;
26550aadb33SDmitri Tikhonov
266b62ec17fSDmitri Tikhonov    lsquic_rechist_init(&rechist, 0);
26750aadb33SDmitri Tikhonov
268b62ec17fSDmitri Tikhonov    lsquic_time_t now = 1234;
26950aadb33SDmitri Tikhonov    st = lsquic_rechist_received(&rechist, 0, now);
27050aadb33SDmitri Tikhonov    assert(("inserting packet number zero results in error", st == REC_ST_ERR));
27150aadb33SDmitri Tikhonov
27250aadb33SDmitri Tikhonov    st = lsquic_rechist_received(&rechist, 1, now);
27350aadb33SDmitri Tikhonov    assert(("inserting packet number one is successful", st == REC_ST_OK));
27450aadb33SDmitri Tikhonov
27550aadb33SDmitri Tikhonov    st = lsquic_rechist_received(&rechist, 1, now);
27650aadb33SDmitri Tikhonov    assert(("inserting packet number one again results in duplicate error",
27750aadb33SDmitri Tikhonov                                                            st == REC_ST_DUP));
27850aadb33SDmitri Tikhonov
27950aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
28050aadb33SDmitri Tikhonov    assert(("first range returned correctly", range));
28150aadb33SDmitri Tikhonov    assert(("first range low value checks out", range->low == 1));
28250aadb33SDmitri Tikhonov    assert(("first range high value checks out", range->high == 1));
28350aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
28450aadb33SDmitri Tikhonov    assert(("second range does not exist", !range));
28550aadb33SDmitri Tikhonov
28650aadb33SDmitri Tikhonov    for (i = 3; i <= 5; ++i)
28750aadb33SDmitri Tikhonov    {
28850aadb33SDmitri Tikhonov        st = lsquic_rechist_received(&rechist, i, now);
28950aadb33SDmitri Tikhonov        assert(("inserting packet", st == REC_ST_OK));
29050aadb33SDmitri Tikhonov    }
29150aadb33SDmitri Tikhonov
29250aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
29350aadb33SDmitri Tikhonov    assert(("first range returned correctly", range));
29450aadb33SDmitri Tikhonov    assert(("first range low value checks out", range->low == 3));
29550aadb33SDmitri Tikhonov    assert(("first range high value checks out", range->high == 5));
29650aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
29750aadb33SDmitri Tikhonov    assert(("second range returned correctly", range));
29850aadb33SDmitri Tikhonov    assert(("second range low value checks out", range->low == 1));
29950aadb33SDmitri Tikhonov    assert(("second range high value checks out", range->high == 1));
30050aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
30150aadb33SDmitri Tikhonov    assert(("third range does not exist", !range));
30250aadb33SDmitri Tikhonov
30350aadb33SDmitri Tikhonov    lsquic_rechist_stop_wait(&rechist, 3);
30450aadb33SDmitri Tikhonov
30550aadb33SDmitri Tikhonov    st = lsquic_rechist_received(&rechist, 1, now);
30650aadb33SDmitri Tikhonov    assert(("inserting packet number one is unsuccessful after cutoff 3",
30750aadb33SDmitri Tikhonov                                                            st == REC_ST_DUP));
30850aadb33SDmitri Tikhonov
30950aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
31050aadb33SDmitri Tikhonov    assert(("first range returned correctly", range));
31150aadb33SDmitri Tikhonov    assert(("first range low value checks out", range->low == 3));
31250aadb33SDmitri Tikhonov    assert(("first range high value checks out", range->high == 5));
31350aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
31450aadb33SDmitri Tikhonov    assert(("second range does not exist", !range));
31550aadb33SDmitri Tikhonov
31650aadb33SDmitri Tikhonov    for (i = 9; i >= 7; --i)
31750aadb33SDmitri Tikhonov    {
31850aadb33SDmitri Tikhonov        st = lsquic_rechist_received(&rechist, i, now);
31950aadb33SDmitri Tikhonov        assert(("inserting packet", st == REC_ST_OK));
32050aadb33SDmitri Tikhonov    }
32150aadb33SDmitri Tikhonov
32250aadb33SDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
32350aadb33SDmitri Tikhonov    assert(("first range returned correctly", range));
32450aadb33SDmitri Tikhonov    assert(("first range low value checks out", range->low == 7));
32550aadb33SDmitri Tikhonov    assert(("first range high value checks out", range->high == 9));
32650aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
32750aadb33SDmitri Tikhonov    assert(("second range returned correctly", range));
32850aadb33SDmitri Tikhonov    assert(("second range low value checks out", range->low == 3));
32950aadb33SDmitri Tikhonov    assert(("second range high value checks out", range->high == 5));
33050aadb33SDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
33150aadb33SDmitri Tikhonov    assert(("third range does not exist", !range));
33250aadb33SDmitri Tikhonov
333b62ec17fSDmitri Tikhonov    lsquic_rechist_stop_wait(&rechist, 5);
334b62ec17fSDmitri Tikhonov
335b62ec17fSDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
336b62ec17fSDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
337b62ec17fSDmitri Tikhonov    assert(("second range returned correctly", range));
338b62ec17fSDmitri Tikhonov    assert(("second range low value checks out", range->low == 5));
339b62ec17fSDmitri Tikhonov    assert(("second range high value checks out", range->high == 5));
340b62ec17fSDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
341b62ec17fSDmitri Tikhonov    assert(("third range does not exist", !range));
342b62ec17fSDmitri Tikhonov
343b62ec17fSDmitri Tikhonov    lsquic_rechist_stop_wait(&rechist, 8);
344b62ec17fSDmitri Tikhonov
345b62ec17fSDmitri Tikhonov    range = lsquic_rechist_first(&rechist);
346b62ec17fSDmitri Tikhonov    assert(("first range returned correctly", range));
347b62ec17fSDmitri Tikhonov    assert(("first range low value checks out", range->low == 8));
348b62ec17fSDmitri Tikhonov    assert(("first range high value checks out", range->high == 9));
349b62ec17fSDmitri Tikhonov    range = lsquic_rechist_next(&rechist);
350b62ec17fSDmitri Tikhonov    assert(("second range does not exist", !range));
351b62ec17fSDmitri Tikhonov
35250aadb33SDmitri Tikhonov    lsquic_rechist_cleanup(&rechist);
35350aadb33SDmitri Tikhonov
35450aadb33SDmitri Tikhonov    test4();
35550aadb33SDmitri Tikhonov
35650aadb33SDmitri Tikhonov    test5();
35750aadb33SDmitri Tikhonov
358b62ec17fSDmitri Tikhonov    for (i = 0; i < 10; ++i)
359b62ec17fSDmitri Tikhonov        test_rand_sequence(i);
360b62ec17fSDmitri Tikhonov
361b62ec17fSDmitri Tikhonov    for (i = 0; i < 10; ++i)
362b62ec17fSDmitri Tikhonov        test_shuffle_1000(i);
363b62ec17fSDmitri Tikhonov
36450aadb33SDmitri Tikhonov    return 0;
36550aadb33SDmitri Tikhonov}
366