Debian Codegraph @

test/rist/unit/test_retx_seq_domain.c

raw symbols SCIP
1 /* librist. SPDX-License-Identifier: BSD-2-Clause
2 *
3 * Unit test for the retransmission sequence-domain predicate
4 * (rist_retx_use_rtp_domain). Regression guard for the mixed-profile
5 * ARQ defect: an Advanced head-end serving a peer that negotiated down
6 * to Main must resolve/verify/frame that peer's retransmits in the
7 * 16-bit RTP sequence domain, not the 32-bit advanced domain, or the
8 * Main peer's NACKs never resolve and nothing is retransmitted
9 * (recovered_packets_total stays 0). No library link or threads. */
10
11 #include "../../../src/rist-retx-domain.h"
12
13 #include <stdio.h>
14
15 static int check(const char *name, enum rist_profile profile,
16 bool remote_adv, bool want)
17 {
18 bool got = rist_retx_use_rtp_domain(profile, remote_adv);
19 if (got != want) {
20 fprintf(stderr, "FAIL: %s -> %d (want %d)\n", name, got, want);
21 return 1;
22 }
23 return 0;
24 }
25
26 int main(void)
27 {
28 int failures = 0;
29
30 /* The bug case: Advanced context, peer has NOT advertised Advanced
31 * (negotiated down to Main) -> must use the 16-bit RTP domain. */
32 failures += check("advanced_ctx_main_peer",
33 RIST_PROFILE_ADVANCED, false, true);
34
35 /* Production Advanced<->Advanced: peer advertised Advanced -> keep
36 * the 32-bit advanced domain (unchanged behaviour). */
37 failures += check("advanced_ctx_advanced_peer",
38 RIST_PROFILE_ADVANCED, true, false);
39
40 /* Main context: its primary index is already the RTP domain, so the
41 * predicate must not divert (regardless of the peer flag). */
42 failures += check("main_ctx_main_peer",
43 RIST_PROFILE_MAIN, false, false);
44 failures += check("main_ctx_adv_flag",
45 RIST_PROFILE_MAIN, true, false);
46
47 /* Simple context likewise. */
48 failures += check("simple_ctx",
49 RIST_PROFILE_SIMPLE, false, false);
50
51 if (failures == 0) {
52 printf("OK\n");
53 return 0;
54 }
55 fprintf(stderr, "Total failures: %d\n", failures);
56 return 1;
57 }