Debian Codegraph @

test/rist/unit/logging_init_order.c

raw symbols SCIP
1 /* librist. SPDX-License-Identifier: BSD-2-Clause */
2
3 /*
4 * Regression test for issue #208 (rist/librist).
5 *
6 * On Windows 11 (and any caller that uses the remote-log socket path
7 * before any rist_*_create), rist_logging_set with a non-NULL `address`
8 * argument used to fail because WSAStartup had not been called yet.
9 * The bug was specifically reachable when the public logging API ran
10 * before rist_sender_create / rist_receiver_create.
11 *
12 * This test reproduces that exact call ordering with a `udp://` remote
13 * address. On POSIX it serves as a baseline / smoke test; on Windows
14 * (run under wine in CI, see .gitlab-ci.yml build-win64) it will fail
15 * with WSANOTINITIALISED if winsock initialisation ever regresses.
16 *
17 * The test does NOT exercise any rist_*_create call and does NOT
18 * require the remote log endpoint to actually exist - we only assert
19 * that the UDP socket can be opened.
20 */
21
22 #include "librist/librist.h"
23 #include "librist/logging.h"
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 int main(void)
29 {
30 struct rist_logging_settings *settings = NULL;
31 char address[] = "127.0.0.1:65530"; /* unprivileged + unlikely to clash */
32
33 int ret = rist_logging_set(&settings, RIST_LOG_DEBUG,
34 NULL, NULL, address, NULL);
35 if (ret != 0) {
36 fprintf(stderr,
37 "FAIL: rist_logging_set with remote address returned %d\n",
38 ret);
39 return 1;
40 }
41 if (settings == NULL) {
42 fprintf(stderr,
43 "FAIL: rist_logging_set returned 0 but settings is NULL\n");
44 return 1;
45 }
46
47 rist_logging_settings_free2(&settings);
48 printf("OK\n");
49 return 0;
50 }