Commit | Line | Data |
---|---|---|
f611d0c3 MD |
1 | // SPDX-License-Identifier: MIT |
2 | /* | |
3 | * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | */ | |
5 | ||
6 | #include <stdint.h> | |
7 | #include <inttypes.h> | |
8 | #include <stdlib.h> | |
9 | #include <stdio.h> | |
4f40d951 | 10 | #include <stdbool.h> |
f611d0c3 MD |
11 | |
12 | #include <side/trace.h> | |
13 | #include "tracer.h" | |
14 | ||
15 | /* User code example */ | |
16 | ||
17 | static side_define_event(my_provider_event, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG, | |
18 | side_field_list( | |
91d140a6 MD |
19 | side_field("abc", SIDE_TYPE_U32), |
20 | side_field("def", SIDE_TYPE_S64), | |
21 | side_field("dynamic", SIDE_TYPE_DYNAMIC), | |
f611d0c3 MD |
22 | ) |
23 | ); | |
24 | ||
25 | static | |
26 | void test_fields(void) | |
27 | { | |
28 | uint32_t uw = 42; | |
29 | int64_t sdw = -500; | |
30 | ||
31 | my_provider_event.enabled = 1; | |
a2e2357e MD |
32 | side_event(&my_provider_event, side_arg_list(side_arg_u32(uw), side_arg_s64(sdw), |
33 | side_arg_dynamic(side_arg_dynamic_string("zzz")))); | |
f611d0c3 MD |
34 | } |
35 | ||
36 | static side_define_event(my_provider_event2, "myprovider", "myevent2", SIDE_LOGLEVEL_DEBUG, | |
37 | side_field_list( | |
38 | side_field_struct("structfield", | |
39 | side_field_list( | |
91d140a6 MD |
40 | side_field("x", SIDE_TYPE_U32), |
41 | side_field("y", SIDE_TYPE_S64), | |
f611d0c3 MD |
42 | ) |
43 | ), | |
91d140a6 | 44 | side_field("z", SIDE_TYPE_U8), |
f611d0c3 MD |
45 | ) |
46 | ); | |
47 | ||
48 | static | |
49 | void test_struct(void) | |
50 | { | |
51 | my_provider_event2.enabled = 1; | |
52 | side_event_cond(&my_provider_event2) { | |
53 | side_arg_define_vec(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); | |
54 | side_event_call(&my_provider_event2, side_arg_list(side_arg_struct(&mystruct), side_arg_u8(55))); | |
55 | } | |
56 | } | |
57 | ||
58 | static side_define_event(my_provider_event_array, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG, | |
59 | side_field_list( | |
cdd6e858 | 60 | side_field_array("arr", side_elem_type(SIDE_TYPE_U32), 3), |
91d140a6 | 61 | side_field("v", SIDE_TYPE_S64), |
f611d0c3 MD |
62 | ) |
63 | ); | |
64 | ||
65 | static | |
66 | void test_array(void) | |
67 | { | |
68 | my_provider_event_array.enabled = 1; | |
69 | side_event_cond(&my_provider_event_array) { | |
70 | side_arg_define_vec(myarray, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); | |
71 | side_event_call(&my_provider_event_array, side_arg_list(side_arg_array(&myarray), side_arg_s64(42))); | |
72 | } | |
73 | } | |
74 | ||
75 | static side_define_event(my_provider_event_vla, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG, | |
76 | side_field_list( | |
cdd6e858 | 77 | side_field_vla("vla", side_elem_type(SIDE_TYPE_U32)), |
91d140a6 | 78 | side_field("v", SIDE_TYPE_S64), |
f611d0c3 MD |
79 | ) |
80 | ); | |
81 | ||
82 | static | |
83 | void test_vla(void) | |
84 | { | |
85 | my_provider_event_vla.enabled = 1; | |
86 | side_event_cond(&my_provider_event_vla) { | |
87 | side_arg_define_vec(myvla, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); | |
88 | side_event_call(&my_provider_event_vla, side_arg_list(side_arg_vla(&myvla), side_arg_s64(42))); | |
89 | } | |
90 | } | |
91 | ||
cdd6e858 MD |
92 | /* 1D array visitor */ |
93 | ||
f611d0c3 MD |
94 | struct app_visitor_ctx { |
95 | const uint32_t *ptr; | |
352a4b77 | 96 | uint32_t length; |
f611d0c3 MD |
97 | }; |
98 | ||
352a4b77 MD |
99 | static |
100 | enum side_visitor_status test_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) | |
f611d0c3 MD |
101 | { |
102 | struct app_visitor_ctx *ctx = (struct app_visitor_ctx *) _ctx; | |
352a4b77 MD |
103 | uint32_t length = ctx->length, i; |
104 | ||
105 | for (i = 0; i < length; i++) { | |
106 | const struct side_arg_vec elem = { | |
107 | .type = SIDE_TYPE_U32, | |
108 | .u = { | |
109 | .side_u32 = ctx->ptr[i], | |
110 | }, | |
111 | }; | |
db6ecef9 MD |
112 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
113 | return SIDE_VISITOR_STATUS_ERROR; | |
352a4b77 | 114 | } |
f611d0c3 MD |
115 | return SIDE_VISITOR_STATUS_OK; |
116 | } | |
117 | ||
118 | static uint32_t testarray[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | |
119 | ||
120 | static side_define_event(my_provider_event_vla_visitor, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG, | |
121 | side_field_list( | |
cdd6e858 | 122 | side_field_vla_visitor("vlavisit", side_elem_type(SIDE_TYPE_U32), test_visitor), |
91d140a6 | 123 | side_field("v", SIDE_TYPE_S64), |
f611d0c3 MD |
124 | ) |
125 | ); | |
126 | ||
127 | static | |
128 | void test_vla_visitor(void) | |
129 | { | |
130 | my_provider_event_vla_visitor.enabled = 1; | |
131 | side_event_cond(&my_provider_event_vla_visitor) { | |
132 | struct app_visitor_ctx ctx = { | |
133 | .ptr = testarray, | |
352a4b77 | 134 | .length = SIDE_ARRAY_SIZE(testarray), |
f611d0c3 MD |
135 | }; |
136 | side_event_call(&my_provider_event_vla_visitor, side_arg_list(side_arg_vla_visitor(&ctx), side_arg_s64(42))); | |
137 | } | |
138 | } | |
139 | ||
cdd6e858 MD |
140 | /* 2D array visitor */ |
141 | ||
142 | struct app_visitor_2d_inner_ctx { | |
143 | const uint32_t *ptr; | |
144 | uint32_t length; | |
145 | }; | |
146 | ||
147 | static | |
148 | enum side_visitor_status test_inner_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) | |
149 | { | |
150 | struct app_visitor_2d_inner_ctx *ctx = (struct app_visitor_2d_inner_ctx *) _ctx; | |
151 | uint32_t length = ctx->length, i; | |
152 | ||
153 | for (i = 0; i < length; i++) { | |
154 | const struct side_arg_vec elem = { | |
155 | .type = SIDE_TYPE_U32, | |
156 | .u = { | |
157 | .side_u32 = ctx->ptr[i], | |
158 | }, | |
159 | }; | |
db6ecef9 MD |
160 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
161 | return SIDE_VISITOR_STATUS_ERROR; | |
cdd6e858 MD |
162 | } |
163 | return SIDE_VISITOR_STATUS_OK; | |
164 | } | |
165 | ||
166 | struct app_visitor_2d_outer_ctx { | |
167 | const uint32_t (*ptr)[2]; | |
168 | uint32_t length; | |
169 | }; | |
170 | ||
171 | static | |
172 | enum side_visitor_status test_outer_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) | |
173 | { | |
174 | struct app_visitor_2d_outer_ctx *ctx = (struct app_visitor_2d_outer_ctx *) _ctx; | |
175 | uint32_t length = ctx->length, i; | |
176 | ||
177 | for (i = 0; i < length; i++) { | |
178 | struct app_visitor_2d_inner_ctx inner_ctx = { | |
179 | .ptr = ctx->ptr[i], | |
180 | .length = 2, | |
181 | }; | |
182 | const struct side_arg_vec elem = side_arg_vla_visitor(&inner_ctx); | |
db6ecef9 MD |
183 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
184 | return SIDE_VISITOR_STATUS_ERROR; | |
cdd6e858 MD |
185 | } |
186 | return SIDE_VISITOR_STATUS_OK; | |
187 | } | |
188 | ||
189 | static uint32_t testarray2d[][2] = { | |
190 | { 1, 2 }, | |
191 | { 33, 44 }, | |
192 | { 55, 66 }, | |
193 | }; | |
194 | ||
195 | static side_define_event(my_provider_event_vla_visitor2d, "myprovider", "myvlavisit2d", SIDE_LOGLEVEL_DEBUG, | |
196 | side_field_list( | |
197 | side_field_vla_visitor("vlavisit2d", | |
198 | side_elem(side_type_vla_visitor_decl(side_elem_type(SIDE_TYPE_U32), test_inner_visitor)), test_outer_visitor), | |
91d140a6 | 199 | side_field("v", SIDE_TYPE_S64), |
cdd6e858 MD |
200 | ) |
201 | ); | |
202 | ||
203 | static | |
204 | void test_vla_visitor_2d(void) | |
205 | { | |
206 | my_provider_event_vla_visitor2d.enabled = 1; | |
207 | side_event_cond(&my_provider_event_vla_visitor2d) { | |
208 | struct app_visitor_2d_outer_ctx ctx = { | |
209 | .ptr = testarray2d, | |
210 | .length = SIDE_ARRAY_SIZE(testarray2d), | |
211 | }; | |
212 | side_event_call(&my_provider_event_vla_visitor2d, side_arg_list(side_arg_vla_visitor(&ctx), side_arg_s64(42))); | |
213 | } | |
214 | } | |
215 | ||
ba845af5 MD |
216 | static int64_t array_fixint[] = { -444, 555, 123, 2897432587 }; |
217 | ||
218 | static side_define_event(my_provider_event_array_fixint, "myprovider", "myarrayfixint", SIDE_LOGLEVEL_DEBUG, | |
219 | side_field_list( | |
cdd6e858 | 220 | side_field_array("arrfixint", side_elem_type(SIDE_TYPE_S64), SIDE_ARRAY_SIZE(array_fixint)), |
91d140a6 | 221 | side_field("v", SIDE_TYPE_S64), |
ba845af5 MD |
222 | ) |
223 | ); | |
224 | ||
225 | static | |
226 | void test_array_fixint(void) | |
227 | { | |
228 | my_provider_event_array_fixint.enabled = 1; | |
1533629f MD |
229 | side_event(&my_provider_event_array_fixint, |
230 | side_arg_list(side_arg_array_s64(array_fixint), side_arg_s64(42))); | |
231 | } | |
232 | ||
233 | static int64_t vla_fixint[] = { -444, 555, 123, 2897432587 }; | |
234 | ||
235 | static side_define_event(my_provider_event_vla_fixint, "myprovider", "myvlafixint", SIDE_LOGLEVEL_DEBUG, | |
236 | side_field_list( | |
cdd6e858 | 237 | side_field_vla("vlafixint", side_elem_type(SIDE_TYPE_S64)), |
91d140a6 | 238 | side_field("v", SIDE_TYPE_S64), |
1533629f MD |
239 | ) |
240 | ); | |
241 | ||
242 | static | |
243 | void test_vla_fixint(void) | |
244 | { | |
245 | my_provider_event_vla_fixint.enabled = 1; | |
246 | side_event(&my_provider_event_vla_fixint, | |
247 | side_arg_list(side_arg_vla_s64(vla_fixint, SIDE_ARRAY_SIZE(vla_fixint)), side_arg_s64(42))); | |
ba845af5 MD |
248 | } |
249 | ||
a2e2357e MD |
250 | static side_define_event(my_provider_event_dynamic_basic, |
251 | "myprovider", "mydynamicbasic", SIDE_LOGLEVEL_DEBUG, | |
252 | side_field_list( | |
91d140a6 | 253 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
a2e2357e MD |
254 | ) |
255 | ); | |
256 | ||
257 | static | |
258 | void test_dynamic_basic_type(void) | |
259 | { | |
260 | my_provider_event_dynamic_basic.enabled = 1; | |
261 | side_event(&my_provider_event_dynamic_basic, | |
262 | side_arg_list(side_arg_dynamic(side_arg_dynamic_s16(-33)))); | |
263 | } | |
264 | ||
265 | static side_define_event(my_provider_event_dynamic_vla, | |
266 | "myprovider", "mydynamicvla", SIDE_LOGLEVEL_DEBUG, | |
267 | side_field_list( | |
91d140a6 | 268 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
a2e2357e MD |
269 | ) |
270 | ); | |
271 | ||
272 | static | |
273 | void test_dynamic_vla(void) | |
274 | { | |
948e3e72 MD |
275 | side_arg_dynamic_define_vec(myvla, |
276 | side_arg_list( | |
df075fa5 MD |
277 | side_arg_dynamic_u32(1), side_arg_dynamic_u32(2), side_arg_dynamic_u32(3), |
278 | ) | |
279 | ); | |
a2e2357e MD |
280 | my_provider_event_dynamic_vla.enabled = 1; |
281 | side_event(&my_provider_event_dynamic_vla, | |
282 | side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla)))); | |
283 | } | |
284 | ||
465e5e7e MD |
285 | static side_define_event(my_provider_event_dynamic_null, |
286 | "myprovider", "mydynamicnull", SIDE_LOGLEVEL_DEBUG, | |
287 | side_field_list( | |
91d140a6 | 288 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
465e5e7e MD |
289 | ) |
290 | ); | |
291 | ||
292 | static | |
293 | void test_dynamic_null(void) | |
294 | { | |
295 | my_provider_event_dynamic_null.enabled = 1; | |
296 | side_event(&my_provider_event_dynamic_null, | |
297 | side_arg_list(side_arg_dynamic(side_arg_dynamic_null()))); | |
298 | } | |
299 | ||
c208889e MD |
300 | static side_define_event(my_provider_event_dynamic_struct, |
301 | "myprovider", "mydynamicstruct", SIDE_LOGLEVEL_DEBUG, | |
465e5e7e | 302 | side_field_list( |
91d140a6 | 303 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
465e5e7e MD |
304 | ) |
305 | ); | |
306 | ||
307 | static | |
c208889e | 308 | void test_dynamic_struct(void) |
465e5e7e | 309 | { |
c208889e | 310 | side_arg_dynamic_define_struct(mystruct, |
465e5e7e MD |
311 | side_arg_list( |
312 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43)), | |
313 | side_arg_dynamic_field("b", side_arg_dynamic_string("zzz")), | |
10c126ee | 314 | side_arg_dynamic_field("c", side_arg_dynamic_null()), |
465e5e7e MD |
315 | ) |
316 | ); | |
317 | ||
c208889e MD |
318 | my_provider_event_dynamic_struct.enabled = 1; |
319 | side_event(&my_provider_event_dynamic_struct, | |
320 | side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct)))); | |
465e5e7e MD |
321 | } |
322 | ||
c208889e MD |
323 | static side_define_event(my_provider_event_dynamic_nested_struct, |
324 | "myprovider", "mydynamicnestedstruct", SIDE_LOGLEVEL_DEBUG, | |
3222d397 | 325 | side_field_list( |
91d140a6 | 326 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
3222d397 MD |
327 | ) |
328 | ); | |
329 | ||
330 | static | |
c208889e | 331 | void test_dynamic_nested_struct(void) |
3222d397 | 332 | { |
c208889e | 333 | side_arg_dynamic_define_struct(nested, |
3222d397 MD |
334 | side_arg_list( |
335 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43)), | |
336 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55)), | |
337 | ) | |
338 | ); | |
c208889e | 339 | side_arg_dynamic_define_struct(nested2, |
3222d397 MD |
340 | side_arg_list( |
341 | side_arg_dynamic_field("aa", side_arg_dynamic_u64(128)), | |
342 | side_arg_dynamic_field("bb", side_arg_dynamic_u16(1)), | |
343 | ) | |
344 | ); | |
c208889e | 345 | side_arg_dynamic_define_struct(mystruct, |
3222d397 | 346 | side_arg_list( |
c208889e MD |
347 | side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested)), |
348 | side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2)), | |
3222d397 MD |
349 | ) |
350 | ); | |
c208889e MD |
351 | my_provider_event_dynamic_nested_struct.enabled = 1; |
352 | side_event(&my_provider_event_dynamic_nested_struct, | |
353 | side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct)))); | |
3222d397 MD |
354 | } |
355 | ||
c208889e MD |
356 | static side_define_event(my_provider_event_dynamic_vla_struct, |
357 | "myprovider", "mydynamicvlastruct", SIDE_LOGLEVEL_DEBUG, | |
7ce1b78f | 358 | side_field_list( |
91d140a6 | 359 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
7ce1b78f MD |
360 | ) |
361 | ); | |
362 | ||
363 | static | |
c208889e | 364 | void test_dynamic_vla_struct(void) |
7ce1b78f | 365 | { |
c208889e | 366 | side_arg_dynamic_define_struct(nested, |
7ce1b78f MD |
367 | side_arg_list( |
368 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43)), | |
369 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55)), | |
370 | ) | |
371 | ); | |
372 | side_arg_dynamic_define_vec(myvla, | |
373 | side_arg_list( | |
c208889e MD |
374 | side_arg_dynamic_struct(&nested), |
375 | side_arg_dynamic_struct(&nested), | |
376 | side_arg_dynamic_struct(&nested), | |
377 | side_arg_dynamic_struct(&nested), | |
7ce1b78f MD |
378 | ) |
379 | ); | |
c208889e MD |
380 | my_provider_event_dynamic_vla_struct.enabled = 1; |
381 | side_event(&my_provider_event_dynamic_vla_struct, | |
7ce1b78f MD |
382 | side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla)))); |
383 | } | |
384 | ||
c208889e MD |
385 | static side_define_event(my_provider_event_dynamic_struct_vla, |
386 | "myprovider", "mydynamicstructvla", SIDE_LOGLEVEL_DEBUG, | |
980bfdc4 | 387 | side_field_list( |
91d140a6 | 388 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
980bfdc4 MD |
389 | ) |
390 | ); | |
391 | ||
392 | static | |
c208889e | 393 | void test_dynamic_struct_vla(void) |
980bfdc4 MD |
394 | { |
395 | side_arg_dynamic_define_vec(myvla, | |
948e3e72 | 396 | side_arg_list( |
df075fa5 MD |
397 | side_arg_dynamic_u32(1), side_arg_dynamic_u32(2), side_arg_dynamic_u32(3), |
398 | ) | |
399 | ); | |
980bfdc4 | 400 | side_arg_dynamic_define_vec(myvla2, |
948e3e72 | 401 | side_arg_list( |
df075fa5 MD |
402 | side_arg_dynamic_u32(4), side_arg_dynamic_u64(5), side_arg_dynamic_u32(6), |
403 | ) | |
404 | ); | |
c208889e | 405 | side_arg_dynamic_define_struct(mystruct, |
980bfdc4 MD |
406 | side_arg_list( |
407 | side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)), | |
408 | side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2)), | |
409 | ) | |
410 | ); | |
c208889e MD |
411 | my_provider_event_dynamic_struct_vla.enabled = 1; |
412 | side_event(&my_provider_event_dynamic_struct_vla, | |
413 | side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct)))); | |
980bfdc4 MD |
414 | } |
415 | ||
948e3e72 MD |
416 | static side_define_event(my_provider_event_dynamic_nested_vla, |
417 | "myprovider", "mydynamicnestedvla", SIDE_LOGLEVEL_DEBUG, | |
418 | side_field_list( | |
91d140a6 | 419 | side_field("dynamic", SIDE_TYPE_DYNAMIC), |
948e3e72 MD |
420 | ) |
421 | ); | |
422 | ||
423 | static | |
424 | void test_dynamic_nested_vla(void) | |
425 | { | |
426 | side_arg_dynamic_define_vec(nestedvla, | |
427 | side_arg_list( | |
428 | side_arg_dynamic_u32(1), side_arg_dynamic_u16(2), side_arg_dynamic_u32(3), | |
429 | ) | |
430 | ); | |
431 | side_arg_dynamic_define_vec(nestedvla2, | |
432 | side_arg_list( | |
433 | side_arg_dynamic_u8(4), side_arg_dynamic_u32(5), side_arg_dynamic_u32(6), | |
434 | ) | |
435 | ); | |
436 | side_arg_dynamic_define_vec(myvla, | |
437 | side_arg_list( | |
438 | side_arg_dynamic_vla(&nestedvla), | |
439 | side_arg_dynamic_vla(&nestedvla2), | |
440 | ) | |
441 | ); | |
442 | my_provider_event_dynamic_nested_vla.enabled = 1; | |
443 | side_event(&my_provider_event_dynamic_nested_vla, | |
444 | side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla)))); | |
445 | } | |
446 | ||
8a25ce77 | 447 | static side_define_event_variadic(my_provider_event_variadic, |
19fa6aa2 MD |
448 | "myprovider", "myvariadicevent", SIDE_LOGLEVEL_DEBUG, |
449 | side_field_list() | |
450 | ); | |
451 | ||
452 | static | |
453 | void test_variadic(void) | |
454 | { | |
455 | my_provider_event_variadic.enabled = 1; | |
456 | side_event_variadic(&my_provider_event_variadic, | |
457 | side_arg_list(), | |
458 | side_arg_list( | |
459 | side_arg_dynamic_field("a", side_arg_dynamic_u32(55)), | |
460 | side_arg_dynamic_field("b", side_arg_dynamic_s8(-4)), | |
461 | ) | |
462 | ); | |
463 | } | |
464 | ||
8a25ce77 | 465 | static side_define_event_variadic(my_provider_event_static_variadic, |
41c4d119 MD |
466 | "myprovider", "mystaticvariadicevent", SIDE_LOGLEVEL_DEBUG, |
467 | side_field_list( | |
468 | side_field("abc", SIDE_TYPE_U32), | |
469 | side_field("def", SIDE_TYPE_U16), | |
470 | ) | |
471 | ); | |
472 | ||
473 | static | |
474 | void test_static_variadic(void) | |
475 | { | |
476 | my_provider_event_static_variadic.enabled = 1; | |
477 | side_event_variadic(&my_provider_event_static_variadic, | |
478 | side_arg_list( | |
479 | side_arg_u32(1), | |
480 | side_arg_u16(2), | |
481 | ), | |
482 | side_arg_list( | |
483 | side_arg_dynamic_field("a", side_arg_dynamic_u32(55)), | |
484 | side_arg_dynamic_field("b", side_arg_dynamic_s8(-4)), | |
485 | ) | |
486 | ); | |
487 | } | |
488 | ||
4f40d951 MD |
489 | static side_define_event(my_provider_event_bool, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG, |
490 | side_field_list( | |
491 | side_field("a_false", SIDE_TYPE_BOOL), | |
492 | side_field("b_true", SIDE_TYPE_BOOL), | |
493 | side_field("c_true", SIDE_TYPE_BOOL), | |
494 | side_field("d_true", SIDE_TYPE_BOOL), | |
495 | side_field("e_true", SIDE_TYPE_BOOL), | |
496 | side_field("f_false", SIDE_TYPE_BOOL), | |
497 | side_field("g_true", SIDE_TYPE_BOOL), | |
498 | ) | |
499 | ); | |
500 | ||
501 | static | |
502 | void test_bool(void) | |
503 | { | |
504 | uint32_t a = 0; | |
505 | uint32_t b = 1; | |
506 | uint64_t c = 0x12345678; | |
507 | int16_t d = -32768; | |
508 | bool e = true; | |
509 | bool f = false; | |
510 | uint32_t g = 256; | |
511 | ||
512 | my_provider_event_bool.enabled = 1; | |
513 | side_event(&my_provider_event_bool, | |
514 | side_arg_list( | |
515 | side_arg_bool(a), | |
516 | side_arg_bool(b), | |
517 | side_arg_bool(c), | |
518 | side_arg_bool(d), | |
519 | side_arg_bool(e), | |
520 | side_arg_bool(f), | |
521 | side_arg_bool(g), | |
522 | ) | |
523 | ); | |
524 | } | |
525 | ||
8a25ce77 | 526 | static side_define_event_variadic(my_provider_event_dynamic_bool, |
4f40d951 MD |
527 | "myprovider", "mydynamicbool", SIDE_LOGLEVEL_DEBUG, |
528 | side_field_list() | |
529 | ); | |
530 | ||
531 | static | |
532 | void test_dynamic_bool(void) | |
533 | { | |
534 | my_provider_event_dynamic_bool.enabled = 1; | |
535 | side_event_variadic(&my_provider_event_dynamic_bool, | |
536 | side_arg_list(), | |
537 | side_arg_list( | |
538 | side_arg_dynamic_field("a_true", side_arg_dynamic_bool(55)), | |
539 | side_arg_dynamic_field("b_true", side_arg_dynamic_bool(-4)), | |
540 | side_arg_dynamic_field("c_false", side_arg_dynamic_bool(0)), | |
541 | side_arg_dynamic_field("d_true", side_arg_dynamic_bool(256)), | |
542 | ) | |
543 | ); | |
544 | } | |
545 | ||
f611d0c3 MD |
546 | int main() |
547 | { | |
548 | test_fields(); | |
549 | test_struct(); | |
550 | test_array(); | |
551 | test_vla(); | |
552 | test_vla_visitor(); | |
cdd6e858 | 553 | test_vla_visitor_2d(); |
ba845af5 | 554 | test_array_fixint(); |
1533629f | 555 | test_vla_fixint(); |
a2e2357e MD |
556 | test_dynamic_basic_type(); |
557 | test_dynamic_vla(); | |
465e5e7e | 558 | test_dynamic_null(); |
c208889e MD |
559 | test_dynamic_struct(); |
560 | test_dynamic_nested_struct(); | |
561 | test_dynamic_vla_struct(); | |
562 | test_dynamic_struct_vla(); | |
948e3e72 | 563 | test_dynamic_nested_vla(); |
19fa6aa2 | 564 | test_variadic(); |
41c4d119 | 565 | test_static_variadic(); |
4f40d951 MD |
566 | test_bool(); |
567 | test_dynamic_bool(); | |
f611d0c3 MD |
568 | return 0; |
569 | } |