tests/unit/test_build: Quiet unused return value
[urcu.git] / tests / unit / test_build.c
1 // SPDX-FileCopyrightText: 2021 Simon Marchi <simon.marchi@efficios.com>
2 //
3 // SPDX-License-Identifier: GPL-2.0-or-later
4
5 /*
6 * This file is meant to verify that headers are compatible with both C and
7 * C++. It includes all exported headers and is compiled as C and C++ source.
8 */
9
10 #ifndef DYNAMIC_LINK_TEST
11 # define _LGPL_SOURCE
12 #endif
13
14 #include <urcu/arch.h>
15 #include <urcu/call-rcu.h>
16 #include <urcu/cds.h>
17 #include <urcu/compiler.h>
18 #include <urcu/debug.h>
19 #include <urcu/defer.h>
20 #include <urcu/flavor.h>
21 #include <urcu/futex.h>
22 #include <urcu/hlist.h>
23 #include <urcu/lfstack.h>
24 #include <urcu/list.h>
25 #include <urcu/pointer.h>
26 #include <urcu/rcuhlist.h>
27 #include <urcu/rculfhash.h>
28 #include <urcu/rculfqueue.h>
29 #include <urcu/rculfstack.h>
30 #include <urcu/rculist.h>
31 #include <urcu/ref.h>
32 #include <urcu/syscall-compat.h>
33 #include <urcu/system.h>
34 #include <urcu/tls-compat.h>
35 #include <urcu/uatomic.h>
36 #include <urcu/urcu-bp.h>
37 #include <urcu/urcu.h>
38 #include <urcu/urcu-mb.h>
39 #include <urcu/urcu-memb.h>
40 #include <urcu/urcu-qsbr.h>
41 #include <urcu/urcu-signal.h>
42 #include <urcu/wfcqueue.h>
43 #include <urcu/wfqueue.h>
44 #include <urcu/wfstack.h>
45
46 #include "tap.h"
47
48 struct my_tls_struct {
49 int int1;
50 char char1;
51 void *void1;
52 };
53
54 static DEFINE_URCU_TLS(int, my_tls_int);
55 static DEFINE_URCU_TLS(struct my_tls_struct, my_tls_struct);
56
57 static void test_lfstack(void)
58 {
59 struct cds_lfs_stack s;
60
61 cds_lfs_init(&s);
62 ok(cds_lfs_empty(&s), "cds_lfs_empty");
63 }
64
65 static void test_wfstack(void)
66 {
67 struct cds_wfs_stack s;
68
69 cds_wfs_init(&s);
70 ok(cds_wfs_empty(&s), "cds_lfs_empty");
71 }
72
73 static void test_wfcqueue(void)
74 {
75 struct cds_wfcq_head head;
76 struct cds_wfcq_tail tail;
77
78 cds_wfcq_init(&head, &tail);
79 ok(cds_wfcq_empty(&head, &tail), "cds_wfcq_empty");
80 }
81
82 static
83 void test_build_cds_list_head_init(void)
84 {
85 /* Test that the CDS_LIST_HEAD_INIT macro builds correctly. */
86 struct struct_with_list {
87 struct cds_list_head head;
88 };
89
90 struct struct_with_list list = {
91 .head = CDS_LIST_HEAD_INIT(list.head),
92 };
93 }
94
95 static
96 void test_urcu_tls(void)
97 {
98 URCU_TLS(my_tls_int) = 1;
99 URCU_TLS(my_tls_struct).int1 = 1;
100 URCU_TLS(my_tls_struct).char1 = 'a';
101 URCU_TLS(my_tls_struct).void1 = NULL;
102 }
103
104 struct an_opaque_struct;
105 struct a_clear_struct
106 {
107 int x;
108 };
109
110 static
111 void test_build_rcu_dereference(void)
112 {
113 static struct an_opaque_struct *opaque = NULL;
114 static struct an_opaque_struct *const opaque_const = NULL;
115 static struct a_clear_struct *clear = NULL;
116 static struct a_clear_struct *const clear_const = NULL;
117
118 (void) rcu_dereference(opaque);
119 (void) rcu_dereference(opaque_const);
120 (void) rcu_dereference(clear);
121 (void) rcu_dereference(clear_const);
122 }
123
124 int main(void)
125 {
126 plan_tests(3);
127
128 test_lfstack();
129 test_wfstack();
130 test_wfcqueue();
131 test_build_cds_list_head_init();
132 test_urcu_tls();
133 test_build_rcu_dereference();
134
135 return exit_status();
136 }
This page took 0.032794 seconds and 5 git commands to generate.