2 * test_bt_ctf_field_type_validation.c
4 * Babeltrace CTF IR field type validation test
6 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; under version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <babeltrace/ctf-ir/field-types.h>
23 #include <babeltrace/ctf-ir/field-path.h>
24 #include <babeltrace/ctf-ir/event.h>
25 #include <babeltrace/ctf-ir/event-class.h>
26 #include <babeltrace/ctf-ir/stream-class.h>
27 #include <babeltrace/ctf-ir/trace.h>
35 struct bt_ctf_field_type
*get_good_packet_header_type(void)
38 Generated by bt-ctfirtg using the following input:
98 length: trace.packet.header.iron.dust
103 length: trace.packet.header.stream_id
112 struct bt_ctf_field_type
*root
= NULL
;
113 struct bt_ctf_field_type
*root_magic
= NULL
;
114 struct bt_ctf_field_type
*root_uuid
= NULL
;
115 struct bt_ctf_field_type
*root_uuid_elem
= NULL
;
116 struct bt_ctf_field_type
*root_stream_id
= NULL
;
117 struct bt_ctf_field_type
*root_iron
= NULL
;
118 struct bt_ctf_field_type
*root_iron_listen
= NULL
;
119 struct bt_ctf_field_type
*root_iron_dust
= NULL
;
120 struct bt_ctf_field_type
*root_iron_parallel
= NULL
;
121 struct bt_ctf_field_type
*root_iron_parallel_int
= NULL
;
122 struct bt_ctf_field_type
*root_iron_fire
= NULL
;
123 struct bt_ctf_field_type
*root_iron_fire_word
= NULL
;
124 struct bt_ctf_field_type
*root_iron_fire_rabbit
= NULL
;
125 struct bt_ctf_field_type
*root_iron_fire_keen
= NULL
;
126 struct bt_ctf_field_type
*root_iron_fire_keen_elem
= NULL
;
127 struct bt_ctf_field_type
*root_iron_fire_keen_elem_RED
= NULL
;
128 struct bt_ctf_field_type
*root_iron_fire_keen_elem_BLUE
= NULL
;
129 struct bt_ctf_field_type
*root_iron_fire_keen_elem_BLUE_elem
= NULL
;
130 struct bt_ctf_field_type
*root_iron_fire_keen_elem_YELLOW
= NULL
;
131 struct bt_ctf_field_type
*root_iron_report
= NULL
;
132 struct bt_ctf_field_type
*root_iron_report_elem
= NULL
;
133 struct bt_ctf_field_type
*root_iron_group
= NULL
;
134 struct bt_ctf_field_type
*root_iron_group_elem
= NULL
;
135 struct bt_ctf_field_type
*root_serious
= NULL
;
138 root
= bt_ctf_field_type_structure_create();
140 ret
= bt_ctf_field_type_set_alignment(root
, 8);
142 root_magic
= bt_ctf_field_type_integer_create(32);
144 ret
= bt_ctf_field_type_integer_set_signed(root_magic
, 0);
146 ret
= bt_ctf_field_type_integer_set_base(root_magic
, 10);
148 ret
= bt_ctf_field_type_integer_set_encoding(root_magic
, BT_CTF_STRING_ENCODING_NONE
);
150 ret
= bt_ctf_field_type_set_byte_order(root_magic
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
152 ret
= bt_ctf_field_type_set_alignment(root_magic
, 8);
154 ret
= bt_ctf_field_type_structure_add_field(root
, root_magic
, "magic");
156 root_uuid_elem
= bt_ctf_field_type_integer_create(8);
157 assert(root_uuid_elem
);
158 ret
= bt_ctf_field_type_integer_set_signed(root_uuid_elem
, 0);
160 ret
= bt_ctf_field_type_integer_set_base(root_uuid_elem
, 10);
162 ret
= bt_ctf_field_type_integer_set_encoding(root_uuid_elem
, BT_CTF_STRING_ENCODING_NONE
);
164 ret
= bt_ctf_field_type_set_byte_order(root_uuid_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
166 ret
= bt_ctf_field_type_set_alignment(root_uuid_elem
, 8);
168 root_uuid
= bt_ctf_field_type_array_create(root_uuid_elem
, 16);
170 ret
= bt_ctf_field_type_structure_add_field(root
, root_uuid
, "uuid");
172 root_stream_id
= bt_ctf_field_type_integer_create(32);
173 assert(root_stream_id
);
174 ret
= bt_ctf_field_type_integer_set_signed(root_stream_id
, 0);
176 ret
= bt_ctf_field_type_integer_set_base(root_stream_id
, 10);
178 ret
= bt_ctf_field_type_integer_set_encoding(root_stream_id
, BT_CTF_STRING_ENCODING_NONE
);
180 ret
= bt_ctf_field_type_set_byte_order(root_stream_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
182 ret
= bt_ctf_field_type_set_alignment(root_stream_id
, 8);
184 ret
= bt_ctf_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
186 root_iron
= bt_ctf_field_type_structure_create();
188 ret
= bt_ctf_field_type_set_alignment(root_iron
, 8);
190 root_iron_listen
= bt_ctf_field_type_string_create();
191 assert(root_iron_listen
);
192 ret
= bt_ctf_field_type_string_set_encoding(root_iron_listen
, BT_CTF_STRING_ENCODING_UTF8
);
194 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_listen
, "listen");
196 root_iron_dust
= bt_ctf_field_type_integer_create(23);
197 assert(root_iron_dust
);
198 ret
= bt_ctf_field_type_integer_set_signed(root_iron_dust
, 0);
200 ret
= bt_ctf_field_type_integer_set_base(root_iron_dust
, 10);
202 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_dust
, BT_CTF_STRING_ENCODING_NONE
);
204 ret
= bt_ctf_field_type_set_byte_order(root_iron_dust
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
206 ret
= bt_ctf_field_type_set_alignment(root_iron_dust
, 1);
208 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_dust
, "dust");
210 root_iron_parallel_int
= bt_ctf_field_type_integer_create(10);
211 assert(root_iron_parallel_int
);
212 ret
= bt_ctf_field_type_integer_set_signed(root_iron_parallel_int
, 0);
214 ret
= bt_ctf_field_type_integer_set_base(root_iron_parallel_int
, 10);
216 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_parallel_int
, BT_CTF_STRING_ENCODING_NONE
);
218 ret
= bt_ctf_field_type_set_byte_order(root_iron_parallel_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
220 ret
= bt_ctf_field_type_set_alignment(root_iron_parallel_int
, 1);
222 root_iron_parallel
= bt_ctf_field_type_enumeration_create(root_iron_parallel_int
);
223 assert(root_iron_parallel
);
224 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "RED", 0, 0);
226 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "BLUE", 1, 1);
228 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "YELLOW", 2, 2);
230 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_parallel
, "parallel");
232 root_iron_fire
= bt_ctf_field_type_structure_create();
233 assert(root_iron_fire
);
234 ret
= bt_ctf_field_type_set_alignment(root_iron_fire
, 8);
236 root_iron_fire_word
= bt_ctf_field_type_integer_create(17);
237 assert(root_iron_fire_word
);
238 ret
= bt_ctf_field_type_integer_set_signed(root_iron_fire_word
, 0);
240 ret
= bt_ctf_field_type_integer_set_base(root_iron_fire_word
, 10);
242 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_fire_word
, BT_CTF_STRING_ENCODING_NONE
);
244 ret
= bt_ctf_field_type_set_byte_order(root_iron_fire_word
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
246 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_word
, 1);
248 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_word
, "word");
250 root_iron_fire_rabbit
= bt_ctf_field_type_string_create();
251 assert(root_iron_fire_rabbit
);
252 ret
= bt_ctf_field_type_string_set_encoding(root_iron_fire_rabbit
, BT_CTF_STRING_ENCODING_UTF8
);
254 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_rabbit
, "rabbit");
256 root_iron_fire_keen_elem
= bt_ctf_field_type_variant_create(NULL
, "iron.parallel");
257 assert(root_iron_fire_keen_elem
);
258 root_iron_fire_keen_elem_RED
= bt_ctf_field_type_string_create();
259 assert(root_iron_fire_keen_elem_RED
);
260 ret
= bt_ctf_field_type_string_set_encoding(root_iron_fire_keen_elem_RED
, BT_CTF_STRING_ENCODING_UTF8
);
262 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_RED
, "RED");
264 root_iron_fire_keen_elem_BLUE_elem
= bt_ctf_field_type_integer_create(5);
265 assert(root_iron_fire_keen_elem_BLUE_elem
);
266 ret
= bt_ctf_field_type_integer_set_signed(root_iron_fire_keen_elem_BLUE_elem
, 0);
268 ret
= bt_ctf_field_type_integer_set_base(root_iron_fire_keen_elem_BLUE_elem
, 10);
270 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_fire_keen_elem_BLUE_elem
, BT_CTF_STRING_ENCODING_NONE
);
272 ret
= bt_ctf_field_type_set_byte_order(root_iron_fire_keen_elem_BLUE_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
274 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_keen_elem_BLUE_elem
, 1);
276 root_iron_fire_keen_elem_BLUE
= bt_ctf_field_type_sequence_create(root_iron_fire_keen_elem_BLUE_elem
, "magic");
277 assert(root_iron_fire_keen_elem_BLUE
);
278 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_BLUE
, "BLUE");
280 root_iron_fire_keen_elem_YELLOW
= bt_ctf_field_type_structure_create();
281 assert(root_iron_fire_keen_elem_YELLOW
);
282 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_keen_elem_YELLOW
, 1);
284 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_YELLOW
, "YELLOW");
286 root_iron_fire_keen
= bt_ctf_field_type_sequence_create(root_iron_fire_keen_elem
, "word");
287 assert(root_iron_fire_keen
);
288 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_keen
, "keen");
290 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_fire
, "fire");
292 root_iron_report_elem
= bt_ctf_field_type_string_create();
293 assert(root_iron_report_elem
);
294 ret
= bt_ctf_field_type_string_set_encoding(root_iron_report_elem
, BT_CTF_STRING_ENCODING_UTF8
);
296 root_iron_report
= bt_ctf_field_type_sequence_create(root_iron_report_elem
, "trace.packet.header.iron.dust");
297 assert(root_iron_report
);
298 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_report
, "report");
300 root_iron_group_elem
= bt_ctf_field_type_string_create();
301 assert(root_iron_group_elem
);
302 ret
= bt_ctf_field_type_string_set_encoding(root_iron_group_elem
, BT_CTF_STRING_ENCODING_UTF8
);
304 root_iron_group
= bt_ctf_field_type_sequence_create(root_iron_group_elem
, "trace.packet.header.stream_id");
305 assert(root_iron_group
);
306 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_group
, "group");
308 ret
= bt_ctf_field_type_structure_add_field(root
, root_iron
, "iron");
310 root_serious
= bt_ctf_field_type_integer_create(1);
311 assert(root_serious
);
312 ret
= bt_ctf_field_type_integer_set_signed(root_serious
, 0);
314 ret
= bt_ctf_field_type_integer_set_base(root_serious
, 10);
316 ret
= bt_ctf_field_type_integer_set_encoding(root_serious
, BT_CTF_STRING_ENCODING_NONE
);
318 ret
= bt_ctf_field_type_set_byte_order(root_serious
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
320 ret
= bt_ctf_field_type_set_alignment(root_serious
, 1);
322 ret
= bt_ctf_field_type_structure_add_field(root
, root_serious
, "serious");
327 BT_PUT(root_uuid_elem
);
328 BT_PUT(root_stream_id
);
330 BT_PUT(root_iron_listen
);
331 BT_PUT(root_iron_dust
);
332 BT_PUT(root_iron_parallel
);
333 BT_PUT(root_iron_parallel_int
);
334 BT_PUT(root_iron_fire
);
335 BT_PUT(root_iron_fire_word
);
336 BT_PUT(root_iron_fire_rabbit
);
337 BT_PUT(root_iron_fire_keen
);
338 BT_PUT(root_iron_fire_keen_elem
);
339 BT_PUT(root_iron_fire_keen_elem_RED
);
340 BT_PUT(root_iron_fire_keen_elem_BLUE
);
341 BT_PUT(root_iron_fire_keen_elem_BLUE_elem
);
342 BT_PUT(root_iron_fire_keen_elem_YELLOW
);
343 BT_PUT(root_iron_report
);
344 BT_PUT(root_iron_report_elem
);
345 BT_PUT(root_iron_group
);
346 BT_PUT(root_iron_group_elem
);
347 BT_PUT(root_serious
);
353 struct bt_ctf_field_type
*get_good_packet_context_type(void)
356 Generated by bt-ctfirtg using the following input:
388 length: trace.packet.header.iron.fire.word
398 length: stream.packet.context.clover.oval
421 struct bt_ctf_field_type
*root
= NULL
;
422 struct bt_ctf_field_type
*root_placid
= NULL
;
423 struct bt_ctf_field_type
*root_meow
= NULL
;
424 struct bt_ctf_field_type
*root_serious
= NULL
;
425 struct bt_ctf_field_type
*root_naive
= NULL
;
426 struct bt_ctf_field_type
*root_naive_elem
= NULL
;
427 struct bt_ctf_field_type
*root_naive_elem_elem
= NULL
;
428 struct bt_ctf_field_type
*root_clover
= NULL
;
429 struct bt_ctf_field_type
*root_clover_oval
= NULL
;
430 struct bt_ctf_field_type
*root_clover_whole
= NULL
;
431 struct bt_ctf_field_type
*root_clover_whole_BLUE
= NULL
;
432 struct bt_ctf_field_type
*root_clover_whole_BLUE_elem
= NULL
;
433 struct bt_ctf_field_type
*root_clover_whole_RED
= NULL
;
434 struct bt_ctf_field_type
*root_clover_whole_YELLOW
= NULL
;
435 struct bt_ctf_field_type
*root_clover_egg
= NULL
;
436 struct bt_ctf_field_type
*root_clover_egg_elem
= NULL
;
437 struct bt_ctf_field_type
*root_clover_square
= NULL
;
438 struct bt_ctf_field_type
*root_clover_square_int
= NULL
;
439 struct bt_ctf_field_type
*root_clover_useful
= NULL
;
440 struct bt_ctf_field_type
*root_clover_useful_elem
= NULL
;
441 struct bt_ctf_field_type
*root_tart
= NULL
;
444 root
= bt_ctf_field_type_structure_create();
446 ret
= bt_ctf_field_type_set_alignment(root
, 8);
448 root_placid
= bt_ctf_field_type_integer_create(32);
450 ret
= bt_ctf_field_type_integer_set_signed(root_placid
, 0);
452 ret
= bt_ctf_field_type_integer_set_base(root_placid
, 10);
454 ret
= bt_ctf_field_type_integer_set_encoding(root_placid
, BT_CTF_STRING_ENCODING_NONE
);
456 ret
= bt_ctf_field_type_set_byte_order(root_placid
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
458 ret
= bt_ctf_field_type_set_alignment(root_placid
, 8);
460 ret
= bt_ctf_field_type_structure_add_field(root
, root_placid
, "placid");
462 root_meow
= bt_ctf_field_type_string_create();
464 ret
= bt_ctf_field_type_string_set_encoding(root_meow
, BT_CTF_STRING_ENCODING_UTF8
);
466 ret
= bt_ctf_field_type_structure_add_field(root
, root_meow
, "meow");
468 root_serious
= bt_ctf_field_type_integer_create(11);
469 assert(root_serious
);
470 ret
= bt_ctf_field_type_integer_set_signed(root_serious
, 0);
472 ret
= bt_ctf_field_type_integer_set_base(root_serious
, 10);
474 ret
= bt_ctf_field_type_integer_set_encoding(root_serious
, BT_CTF_STRING_ENCODING_NONE
);
476 ret
= bt_ctf_field_type_set_byte_order(root_serious
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
478 ret
= bt_ctf_field_type_set_alignment(root_serious
, 1);
480 ret
= bt_ctf_field_type_structure_add_field(root
, root_serious
, "serious");
482 root_naive_elem_elem
= bt_ctf_field_type_string_create();
483 assert(root_naive_elem_elem
);
484 ret
= bt_ctf_field_type_string_set_encoding(root_naive_elem_elem
, BT_CTF_STRING_ENCODING_UTF8
);
486 root_naive_elem
= bt_ctf_field_type_sequence_create(root_naive_elem_elem
, "placid");
487 assert(root_naive_elem
);
488 root_naive
= bt_ctf_field_type_array_create(root_naive_elem
, 17);
490 ret
= bt_ctf_field_type_structure_add_field(root
, root_naive
, "naive");
492 root_clover
= bt_ctf_field_type_structure_create();
494 ret
= bt_ctf_field_type_set_alignment(root_clover
, 1);
496 root_clover_oval
= bt_ctf_field_type_integer_create(17);
497 assert(root_clover_oval
);
498 ret
= bt_ctf_field_type_integer_set_signed(root_clover_oval
, 0);
500 ret
= bt_ctf_field_type_integer_set_base(root_clover_oval
, 10);
502 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_oval
, BT_CTF_STRING_ENCODING_NONE
);
504 ret
= bt_ctf_field_type_set_byte_order(root_clover_oval
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
506 ret
= bt_ctf_field_type_set_alignment(root_clover_oval
, 1);
508 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_oval
, "oval");
510 root_clover_whole
= bt_ctf_field_type_variant_create(NULL
, "iron.parallel");
511 assert(root_clover_whole
);
512 root_clover_whole_BLUE_elem
= bt_ctf_field_type_string_create();
513 assert(root_clover_whole_BLUE_elem
);
514 ret
= bt_ctf_field_type_string_set_encoding(root_clover_whole_BLUE_elem
, BT_CTF_STRING_ENCODING_UTF8
);
516 root_clover_whole_BLUE
= bt_ctf_field_type_sequence_create(root_clover_whole_BLUE_elem
, "trace.packet.header.iron.fire.word");
517 assert(root_clover_whole_BLUE
);
518 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_BLUE
, "BLUE");
520 root_clover_whole_RED
= bt_ctf_field_type_integer_create(44);
521 assert(root_clover_whole_RED
);
522 ret
= bt_ctf_field_type_integer_set_signed(root_clover_whole_RED
, 0);
524 ret
= bt_ctf_field_type_integer_set_base(root_clover_whole_RED
, 10);
526 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_whole_RED
, BT_CTF_STRING_ENCODING_NONE
);
528 ret
= bt_ctf_field_type_set_byte_order(root_clover_whole_RED
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
530 ret
= bt_ctf_field_type_set_alignment(root_clover_whole_RED
, 1);
532 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_RED
, "RED");
534 root_clover_whole_YELLOW
= bt_ctf_field_type_string_create();
535 assert(root_clover_whole_YELLOW
);
536 ret
= bt_ctf_field_type_string_set_encoding(root_clover_whole_YELLOW
, BT_CTF_STRING_ENCODING_UTF8
);
538 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_YELLOW
, "YELLOW");
540 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_whole
, "whole");
542 root_clover_egg_elem
= bt_ctf_field_type_integer_create(55);
543 assert(root_clover_egg_elem
);
544 ret
= bt_ctf_field_type_integer_set_signed(root_clover_egg_elem
, 0);
546 ret
= bt_ctf_field_type_integer_set_base(root_clover_egg_elem
, 10);
548 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_egg_elem
, BT_CTF_STRING_ENCODING_NONE
);
550 ret
= bt_ctf_field_type_set_byte_order(root_clover_egg_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
552 ret
= bt_ctf_field_type_set_alignment(root_clover_egg_elem
, 1);
554 root_clover_egg
= bt_ctf_field_type_sequence_create(root_clover_egg_elem
, "stream.packet.context.clover.oval");
555 assert(root_clover_egg
);
556 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_egg
, "egg");
558 root_clover_square_int
= bt_ctf_field_type_integer_create(12);
559 assert(root_clover_square_int
);
560 ret
= bt_ctf_field_type_integer_set_signed(root_clover_square_int
, 0);
562 ret
= bt_ctf_field_type_integer_set_base(root_clover_square_int
, 10);
564 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_square_int
, BT_CTF_STRING_ENCODING_NONE
);
566 ret
= bt_ctf_field_type_set_byte_order(root_clover_square_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
568 ret
= bt_ctf_field_type_set_alignment(root_clover_square_int
, 1);
570 root_clover_square
= bt_ctf_field_type_enumeration_create(root_clover_square_int
);
571 assert(root_clover_square
);
572 ret
= bt_ctf_field_type_enumeration_add_mapping(root_clover_square
, "YOUNG", 0, 0);
574 ret
= bt_ctf_field_type_enumeration_add_mapping(root_clover_square
, "OLD", 1, 1);
576 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_square
, "square");
578 root_clover_useful_elem
= bt_ctf_field_type_integer_create(2);
579 assert(root_clover_useful_elem
);
580 ret
= bt_ctf_field_type_integer_set_signed(root_clover_useful_elem
, 0);
582 ret
= bt_ctf_field_type_integer_set_base(root_clover_useful_elem
, 10);
584 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_useful_elem
, BT_CTF_STRING_ENCODING_NONE
);
586 ret
= bt_ctf_field_type_set_byte_order(root_clover_useful_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
588 ret
= bt_ctf_field_type_set_alignment(root_clover_useful_elem
, 1);
590 root_clover_useful
= bt_ctf_field_type_sequence_create(root_clover_useful_elem
, "serious");
591 assert(root_clover_useful
);
592 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_useful
, "useful");
594 ret
= bt_ctf_field_type_structure_add_field(root
, root_clover
, "clover");
596 root_tart
= bt_ctf_field_type_string_create();
598 ret
= bt_ctf_field_type_string_set_encoding(root_tart
, BT_CTF_STRING_ENCODING_UTF8
);
600 ret
= bt_ctf_field_type_structure_add_field(root
, root_tart
, "tart");
605 BT_PUT(root_serious
);
607 BT_PUT(root_naive_elem
);
608 BT_PUT(root_naive_elem_elem
);
610 BT_PUT(root_clover_oval
);
611 BT_PUT(root_clover_whole
);
612 BT_PUT(root_clover_whole_BLUE
);
613 BT_PUT(root_clover_whole_BLUE_elem
);
614 BT_PUT(root_clover_whole_RED
);
615 BT_PUT(root_clover_whole_YELLOW
);
616 BT_PUT(root_clover_egg
);
617 BT_PUT(root_clover_egg_elem
);
618 BT_PUT(root_clover_square
);
619 BT_PUT(root_clover_square_int
);
620 BT_PUT(root_clover_useful
);
621 BT_PUT(root_clover_useful_elem
);
629 struct bt_ctf_field_type
*get_good_event_header_type(void)
632 Generated by bt-ctfirtg using the following input:
650 length: stream.packet.context.placid
657 length: trace.packet.header.serious
663 length: clover.whole.RED
671 length: action.special
678 struct bt_ctf_field_type
*root
= NULL
;
679 struct bt_ctf_field_type
*root_id
= NULL
;
680 struct bt_ctf_field_type
*root_timestamp
= NULL
;
681 struct bt_ctf_field_type
*root_action
= NULL
;
682 struct bt_ctf_field_type
*root_action_special
= NULL
;
683 struct bt_ctf_field_type
*root_action_lucky
= NULL
;
684 struct bt_ctf_field_type
*root_action_lucky_elem
= NULL
;
685 struct bt_ctf_field_type
*root_action_dream
= NULL
;
686 struct bt_ctf_field_type
*root_action_grandiose
= NULL
;
687 struct bt_ctf_field_type
*root_action_grandiose_elem
= NULL
;
688 struct bt_ctf_field_type
*root_stiff
= NULL
;
689 struct bt_ctf_field_type
*root_stiff_elem
= NULL
;
690 struct bt_ctf_field_type
*root_fruit
= NULL
;
691 struct bt_ctf_field_type
*root_fruit_apple
= NULL
;
692 struct bt_ctf_field_type
*root_fruit_apple_elem
= NULL
;
695 root
= bt_ctf_field_type_structure_create();
697 ret
= bt_ctf_field_type_set_alignment(root
, 8);
699 root_id
= bt_ctf_field_type_integer_create(17);
701 ret
= bt_ctf_field_type_integer_set_signed(root_id
, 0);
703 ret
= bt_ctf_field_type_integer_set_base(root_id
, 10);
705 ret
= bt_ctf_field_type_integer_set_encoding(root_id
, BT_CTF_STRING_ENCODING_NONE
);
707 ret
= bt_ctf_field_type_set_byte_order(root_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
709 ret
= bt_ctf_field_type_set_alignment(root_id
, 1);
711 ret
= bt_ctf_field_type_structure_add_field(root
, root_id
, "id");
713 root_timestamp
= bt_ctf_field_type_integer_create(64);
714 assert(root_timestamp
);
715 ret
= bt_ctf_field_type_integer_set_signed(root_timestamp
, 0);
717 ret
= bt_ctf_field_type_integer_set_base(root_timestamp
, 10);
719 ret
= bt_ctf_field_type_integer_set_encoding(root_timestamp
, BT_CTF_STRING_ENCODING_NONE
);
721 ret
= bt_ctf_field_type_set_byte_order(root_timestamp
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
723 ret
= bt_ctf_field_type_set_alignment(root_timestamp
, 8);
725 ret
= bt_ctf_field_type_structure_add_field(root
, root_timestamp
, "timestamp");
727 root_action
= bt_ctf_field_type_structure_create();
729 ret
= bt_ctf_field_type_set_alignment(root_action
, 8);
731 root_action_special
= bt_ctf_field_type_integer_create(17);
732 assert(root_action_special
);
733 ret
= bt_ctf_field_type_integer_set_signed(root_action_special
, 0);
735 ret
= bt_ctf_field_type_integer_set_base(root_action_special
, 10);
737 ret
= bt_ctf_field_type_integer_set_encoding(root_action_special
, BT_CTF_STRING_ENCODING_NONE
);
739 ret
= bt_ctf_field_type_set_byte_order(root_action_special
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
741 ret
= bt_ctf_field_type_set_alignment(root_action_special
, 1);
743 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_special
, "special");
745 root_action_lucky_elem
= bt_ctf_field_type_string_create();
746 assert(root_action_lucky_elem
);
747 ret
= bt_ctf_field_type_string_set_encoding(root_action_lucky_elem
, BT_CTF_STRING_ENCODING_UTF8
);
749 root_action_lucky
= bt_ctf_field_type_sequence_create(root_action_lucky_elem
, "stream.packet.context.placid");
750 assert(root_action_lucky
);
751 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_lucky
, "lucky");
753 root_action_dream
= bt_ctf_field_type_string_create();
754 assert(root_action_dream
);
755 ret
= bt_ctf_field_type_string_set_encoding(root_action_dream
, BT_CTF_STRING_ENCODING_UTF8
);
757 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_dream
, "dream");
759 root_action_grandiose_elem
= bt_ctf_field_type_integer_create(3);
760 assert(root_action_grandiose_elem
);
761 ret
= bt_ctf_field_type_integer_set_signed(root_action_grandiose_elem
, 0);
763 ret
= bt_ctf_field_type_integer_set_base(root_action_grandiose_elem
, 10);
765 ret
= bt_ctf_field_type_integer_set_encoding(root_action_grandiose_elem
, BT_CTF_STRING_ENCODING_NONE
);
767 ret
= bt_ctf_field_type_set_byte_order(root_action_grandiose_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
769 ret
= bt_ctf_field_type_set_alignment(root_action_grandiose_elem
, 1);
771 root_action_grandiose
= bt_ctf_field_type_sequence_create(root_action_grandiose_elem
, "trace.packet.header.serious");
772 assert(root_action_grandiose
);
773 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_grandiose
, "grandiose");
775 ret
= bt_ctf_field_type_structure_add_field(root
, root_action
, "action");
777 root_stiff_elem
= bt_ctf_field_type_string_create();
778 assert(root_stiff_elem
);
779 ret
= bt_ctf_field_type_string_set_encoding(root_stiff_elem
, BT_CTF_STRING_ENCODING_UTF8
);
781 root_stiff
= bt_ctf_field_type_sequence_create(root_stiff_elem
, "clover.whole.RED");
783 ret
= bt_ctf_field_type_structure_add_field(root
, root_stiff
, "stiff");
785 root_fruit
= bt_ctf_field_type_structure_create();
787 ret
= bt_ctf_field_type_set_alignment(root_fruit
, 1);
789 root_fruit_apple_elem
= bt_ctf_field_type_integer_create(5);
790 assert(root_fruit_apple_elem
);
791 ret
= bt_ctf_field_type_integer_set_signed(root_fruit_apple_elem
, 0);
793 ret
= bt_ctf_field_type_integer_set_base(root_fruit_apple_elem
, 10);
795 ret
= bt_ctf_field_type_integer_set_encoding(root_fruit_apple_elem
, BT_CTF_STRING_ENCODING_NONE
);
797 ret
= bt_ctf_field_type_set_byte_order(root_fruit_apple_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
799 ret
= bt_ctf_field_type_set_alignment(root_fruit_apple_elem
, 1);
801 root_fruit_apple
= bt_ctf_field_type_sequence_create(root_fruit_apple_elem
, "action.special");
802 assert(root_fruit_apple
);
803 ret
= bt_ctf_field_type_structure_add_field(root_fruit
, root_fruit_apple
, "apple");
805 ret
= bt_ctf_field_type_structure_add_field(root
, root_fruit
, "fruit");
809 BT_PUT(root_timestamp
);
811 BT_PUT(root_action_special
);
812 BT_PUT(root_action_lucky
);
813 BT_PUT(root_action_lucky_elem
);
814 BT_PUT(root_action_dream
);
815 BT_PUT(root_action_grandiose
);
816 BT_PUT(root_action_grandiose_elem
);
818 BT_PUT(root_stiff_elem
);
820 BT_PUT(root_fruit_apple
);
821 BT_PUT(root_fruit_apple_elem
);
827 struct bt_ctf_field_type
*get_good_stream_event_context_type(void)
830 Generated by bt-ctfirtg using the following input:
860 length: stream.packet.context.placid
863 length: trace.packet.header.iron.dust
866 length: stream.event.context.face.magic
875 struct bt_ctf_field_type
*root
= NULL
;
876 struct bt_ctf_field_type
*root_face
= NULL
;
877 struct bt_ctf_field_type
*root_face_branch
= NULL
;
878 struct bt_ctf_field_type
*root_face_branch_elem
= NULL
;
879 struct bt_ctf_field_type
*root_face_income
= NULL
;
880 struct bt_ctf_field_type
*root_face_income_elem
= NULL
;
881 struct bt_ctf_field_type
*root_face_magic
= NULL
;
882 struct bt_ctf_field_type
*root_face_lucky
= NULL
;
883 struct bt_ctf_field_type
*root_face_lucky_elem
= NULL
;
884 struct bt_ctf_field_type
*root_cats
= NULL
;
885 struct bt_ctf_field_type
*root_dream
= NULL
;
886 struct bt_ctf_field_type
*root_dream_elem
= NULL
;
887 struct bt_ctf_field_type
*root_dream_elem_elem
= NULL
;
888 struct bt_ctf_field_type
*root_dream_elem_elem_elem
= NULL
;
889 struct bt_ctf_field_type
*root_stream_id
= NULL
;
892 root
= bt_ctf_field_type_structure_create();
894 ret
= bt_ctf_field_type_set_alignment(root
, 8);
896 root_face
= bt_ctf_field_type_structure_create();
898 ret
= bt_ctf_field_type_set_alignment(root_face
, 8);
900 root_face_branch_elem
= bt_ctf_field_type_string_create();
901 assert(root_face_branch_elem
);
902 ret
= bt_ctf_field_type_string_set_encoding(root_face_branch_elem
, BT_CTF_STRING_ENCODING_UTF8
);
904 root_face_branch
= bt_ctf_field_type_sequence_create(root_face_branch_elem
, "serious");
905 assert(root_face_branch
);
906 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_branch
, "branch");
908 root_face_income_elem
= bt_ctf_field_type_string_create();
909 assert(root_face_income_elem
);
910 ret
= bt_ctf_field_type_string_set_encoding(root_face_income_elem
, BT_CTF_STRING_ENCODING_UTF8
);
912 root_face_income
= bt_ctf_field_type_sequence_create(root_face_income_elem
, "magic");
913 assert(root_face_income
);
914 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_income
, "income");
916 root_face_magic
= bt_ctf_field_type_integer_create(23);
917 assert(root_face_magic
);
918 ret
= bt_ctf_field_type_integer_set_signed(root_face_magic
, 0);
920 ret
= bt_ctf_field_type_integer_set_base(root_face_magic
, 10);
922 ret
= bt_ctf_field_type_integer_set_encoding(root_face_magic
, BT_CTF_STRING_ENCODING_NONE
);
924 ret
= bt_ctf_field_type_set_byte_order(root_face_magic
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
926 ret
= bt_ctf_field_type_set_alignment(root_face_magic
, 1);
928 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_magic
, "magic");
930 root_face_lucky_elem
= bt_ctf_field_type_string_create();
931 assert(root_face_lucky_elem
);
932 ret
= bt_ctf_field_type_string_set_encoding(root_face_lucky_elem
, BT_CTF_STRING_ENCODING_UTF8
);
934 root_face_lucky
= bt_ctf_field_type_sequence_create(root_face_lucky_elem
, "magic");
935 assert(root_face_lucky
);
936 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_lucky
, "lucky");
938 ret
= bt_ctf_field_type_structure_add_field(root
, root_face
, "face");
940 root_cats
= bt_ctf_field_type_integer_create(5);
942 ret
= bt_ctf_field_type_integer_set_signed(root_cats
, 0);
944 ret
= bt_ctf_field_type_integer_set_base(root_cats
, 10);
946 ret
= bt_ctf_field_type_integer_set_encoding(root_cats
, BT_CTF_STRING_ENCODING_NONE
);
948 ret
= bt_ctf_field_type_set_byte_order(root_cats
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
950 ret
= bt_ctf_field_type_set_alignment(root_cats
, 1);
952 ret
= bt_ctf_field_type_structure_add_field(root
, root_cats
, "cats");
954 root_dream_elem_elem_elem
= bt_ctf_field_type_string_create();
955 assert(root_dream_elem_elem_elem
);
956 ret
= bt_ctf_field_type_string_set_encoding(root_dream_elem_elem_elem
, BT_CTF_STRING_ENCODING_UTF8
);
958 root_dream_elem_elem
= bt_ctf_field_type_sequence_create(root_dream_elem_elem_elem
, "stream.event.context.face.magic");
959 assert(root_dream_elem_elem
);
960 root_dream_elem
= bt_ctf_field_type_sequence_create(root_dream_elem_elem
, "trace.packet.header.iron.dust");
961 assert(root_dream_elem
);
962 root_dream
= bt_ctf_field_type_sequence_create(root_dream_elem
, "stream.packet.context.placid");
964 ret
= bt_ctf_field_type_structure_add_field(root
, root_dream
, "dream");
966 root_stream_id
= bt_ctf_field_type_integer_create(9);
967 assert(root_stream_id
);
968 ret
= bt_ctf_field_type_integer_set_signed(root_stream_id
, 0);
970 ret
= bt_ctf_field_type_integer_set_base(root_stream_id
, 10);
972 ret
= bt_ctf_field_type_integer_set_encoding(root_stream_id
, BT_CTF_STRING_ENCODING_NONE
);
974 ret
= bt_ctf_field_type_set_byte_order(root_stream_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
976 ret
= bt_ctf_field_type_set_alignment(root_stream_id
, 1);
978 ret
= bt_ctf_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
982 BT_PUT(root_face_branch
);
983 BT_PUT(root_face_branch_elem
);
984 BT_PUT(root_face_income
);
985 BT_PUT(root_face_income_elem
);
986 BT_PUT(root_face_magic
);
987 BT_PUT(root_face_lucky
);
988 BT_PUT(root_face_lucky_elem
);
991 BT_PUT(root_dream_elem
);
992 BT_PUT(root_dream_elem_elem
);
993 BT_PUT(root_dream_elem_elem_elem
);
994 BT_PUT(root_stream_id
);
1000 struct bt_ctf_field_type
*get_good_event_context_type(void)
1003 Generated by bt-ctfirtg using the following input:
1025 length: action.special
1038 length: iron.fire.word
1049 length: trace.packet.header.iron.fire.word
1054 length: stream.packet.context.clover.oval
1059 length: stream.event.header.action.special
1064 length: stream.event.context.face.magic
1074 length: event.context.film
1080 struct bt_ctf_field_type
*root
= NULL
;
1081 struct bt_ctf_field_type
*root_film
= NULL
;
1082 struct bt_ctf_field_type
*root_berry
= NULL
;
1083 struct bt_ctf_field_type
*root_berry_pine
= NULL
;
1084 struct bt_ctf_field_type
*root_berry_pine_elem
= NULL
;
1085 struct bt_ctf_field_type
*root_berry_porter
= NULL
;
1086 struct bt_ctf_field_type
*root_berry_porter_elem
= NULL
;
1087 struct bt_ctf_field_type
*root_berry_mice
= NULL
;
1088 struct bt_ctf_field_type
*root_berry_mice_elem
= NULL
;
1089 struct bt_ctf_field_type
*root_berry_third
= NULL
;
1090 struct bt_ctf_field_type
*root_berry_guard
= NULL
;
1091 struct bt_ctf_field_type
*root_berry_guard_elem
= NULL
;
1092 struct bt_ctf_field_type
*root_berry_one
= NULL
;
1093 struct bt_ctf_field_type
*root_berry_one_elem
= NULL
;
1094 struct bt_ctf_field_type
*root_cats
= NULL
;
1095 struct bt_ctf_field_type
*root_loud
= NULL
;
1096 struct bt_ctf_field_type
*root_loud_toys
= NULL
;
1097 struct bt_ctf_field_type
*root_loud_toys_elem
= NULL
;
1098 struct bt_ctf_field_type
*root_loud_spoon
= NULL
;
1099 struct bt_ctf_field_type
*root_loud_spoon_elem
= NULL
;
1100 struct bt_ctf_field_type
*root_loud_turkey
= NULL
;
1101 struct bt_ctf_field_type
*root_loud_turkey_elem
= NULL
;
1102 struct bt_ctf_field_type
*root_loud_inform
= NULL
;
1103 struct bt_ctf_field_type
*root_loud_inform_elem
= NULL
;
1104 struct bt_ctf_field_type
*root_loud_odd
= NULL
;
1105 struct bt_ctf_field_type
*root_loud_odd_elem
= NULL
;
1106 struct bt_ctf_field_type
*root_loud_amuck
= NULL
;
1107 struct bt_ctf_field_type
*root_loud_amuck_elem
= NULL
;
1110 root
= bt_ctf_field_type_structure_create();
1112 ret
= bt_ctf_field_type_set_alignment(root
, 8);
1114 root_film
= bt_ctf_field_type_integer_create(19);
1116 ret
= bt_ctf_field_type_integer_set_signed(root_film
, 0);
1118 ret
= bt_ctf_field_type_integer_set_base(root_film
, 10);
1120 ret
= bt_ctf_field_type_integer_set_encoding(root_film
, BT_CTF_STRING_ENCODING_NONE
);
1122 ret
= bt_ctf_field_type_set_byte_order(root_film
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1124 ret
= bt_ctf_field_type_set_alignment(root_film
, 1);
1126 ret
= bt_ctf_field_type_structure_add_field(root
, root_film
, "film");
1128 root_berry
= bt_ctf_field_type_structure_create();
1130 ret
= bt_ctf_field_type_set_alignment(root_berry
, 8);
1132 root_berry_pine_elem
= bt_ctf_field_type_string_create();
1133 assert(root_berry_pine_elem
);
1134 ret
= bt_ctf_field_type_string_set_encoding(root_berry_pine_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1136 root_berry_pine
= bt_ctf_field_type_sequence_create(root_berry_pine_elem
, "stream_id");
1137 assert(root_berry_pine
);
1138 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_pine
, "pine");
1140 root_berry_porter_elem
= bt_ctf_field_type_string_create();
1141 assert(root_berry_porter_elem
);
1142 ret
= bt_ctf_field_type_string_set_encoding(root_berry_porter_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1144 root_berry_porter
= bt_ctf_field_type_sequence_create(root_berry_porter_elem
, "face.magic");
1145 assert(root_berry_porter
);
1146 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_porter
, "porter");
1148 root_berry_mice_elem
= bt_ctf_field_type_string_create();
1149 assert(root_berry_mice_elem
);
1150 ret
= bt_ctf_field_type_string_set_encoding(root_berry_mice_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1152 root_berry_mice
= bt_ctf_field_type_sequence_create(root_berry_mice_elem
, "action.special");
1153 assert(root_berry_mice
);
1154 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_mice
, "mice");
1156 root_berry_third
= bt_ctf_field_type_integer_create(18);
1157 assert(root_berry_third
);
1158 ret
= bt_ctf_field_type_integer_set_signed(root_berry_third
, 0);
1160 ret
= bt_ctf_field_type_integer_set_base(root_berry_third
, 10);
1162 ret
= bt_ctf_field_type_integer_set_encoding(root_berry_third
, BT_CTF_STRING_ENCODING_NONE
);
1164 ret
= bt_ctf_field_type_set_byte_order(root_berry_third
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1166 ret
= bt_ctf_field_type_set_alignment(root_berry_third
, 1);
1168 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_third
, "third");
1170 root_berry_guard_elem
= bt_ctf_field_type_string_create();
1171 assert(root_berry_guard_elem
);
1172 ret
= bt_ctf_field_type_string_set_encoding(root_berry_guard_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1174 root_berry_guard
= bt_ctf_field_type_sequence_create(root_berry_guard_elem
, "clover.oval");
1175 assert(root_berry_guard
);
1176 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_guard
, "guard");
1178 root_berry_one_elem
= bt_ctf_field_type_string_create();
1179 assert(root_berry_one_elem
);
1180 ret
= bt_ctf_field_type_string_set_encoding(root_berry_one_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1182 root_berry_one
= bt_ctf_field_type_sequence_create(root_berry_one_elem
, "iron.fire.word");
1183 assert(root_berry_one
);
1184 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_one
, "one");
1186 ret
= bt_ctf_field_type_structure_add_field(root
, root_berry
, "berry");
1188 root_cats
= bt_ctf_field_type_integer_create(55);
1190 ret
= bt_ctf_field_type_integer_set_signed(root_cats
, 0);
1192 ret
= bt_ctf_field_type_integer_set_base(root_cats
, 10);
1194 ret
= bt_ctf_field_type_integer_set_encoding(root_cats
, BT_CTF_STRING_ENCODING_NONE
);
1196 ret
= bt_ctf_field_type_set_byte_order(root_cats
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1198 ret
= bt_ctf_field_type_set_alignment(root_cats
, 1);
1200 ret
= bt_ctf_field_type_structure_add_field(root
, root_cats
, "cats");
1202 root_loud
= bt_ctf_field_type_structure_create();
1204 ret
= bt_ctf_field_type_set_alignment(root_loud
, 8);
1206 root_loud_toys_elem
= bt_ctf_field_type_string_create();
1207 assert(root_loud_toys_elem
);
1208 ret
= bt_ctf_field_type_string_set_encoding(root_loud_toys_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1210 root_loud_toys
= bt_ctf_field_type_sequence_create(root_loud_toys_elem
, "trace.packet.header.iron.fire.word");
1211 assert(root_loud_toys
);
1212 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_toys
, "toys");
1214 root_loud_spoon_elem
= bt_ctf_field_type_string_create();
1215 assert(root_loud_spoon_elem
);
1216 ret
= bt_ctf_field_type_string_set_encoding(root_loud_spoon_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1218 root_loud_spoon
= bt_ctf_field_type_sequence_create(root_loud_spoon_elem
, "stream.packet.context.clover.oval");
1219 assert(root_loud_spoon
);
1220 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_spoon
, "spoon");
1222 root_loud_turkey_elem
= bt_ctf_field_type_string_create();
1223 assert(root_loud_turkey_elem
);
1224 ret
= bt_ctf_field_type_string_set_encoding(root_loud_turkey_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1226 root_loud_turkey
= bt_ctf_field_type_sequence_create(root_loud_turkey_elem
, "stream.event.header.action.special");
1227 assert(root_loud_turkey
);
1228 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_turkey
, "turkey");
1230 root_loud_inform_elem
= bt_ctf_field_type_string_create();
1231 assert(root_loud_inform_elem
);
1232 ret
= bt_ctf_field_type_string_set_encoding(root_loud_inform_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1234 root_loud_inform
= bt_ctf_field_type_sequence_create(root_loud_inform_elem
, "stream.event.context.face.magic");
1235 assert(root_loud_inform
);
1236 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_inform
, "inform");
1238 root_loud_odd_elem
= bt_ctf_field_type_string_create();
1239 assert(root_loud_odd_elem
);
1240 ret
= bt_ctf_field_type_string_set_encoding(root_loud_odd_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1242 root_loud_odd
= bt_ctf_field_type_sequence_create(root_loud_odd_elem
, "berry.third");
1243 assert(root_loud_odd
);
1244 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_odd
, "odd");
1246 root_loud_amuck_elem
= bt_ctf_field_type_string_create();
1247 assert(root_loud_amuck_elem
);
1248 ret
= bt_ctf_field_type_string_set_encoding(root_loud_amuck_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1250 root_loud_amuck
= bt_ctf_field_type_sequence_create(root_loud_amuck_elem
, "event.context.film");
1251 assert(root_loud_amuck
);
1252 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_amuck
, "amuck");
1254 ret
= bt_ctf_field_type_structure_add_field(root
, root_loud
, "loud");
1259 BT_PUT(root_berry_pine
);
1260 BT_PUT(root_berry_pine_elem
);
1261 BT_PUT(root_berry_porter
);
1262 BT_PUT(root_berry_porter_elem
);
1263 BT_PUT(root_berry_mice
);
1264 BT_PUT(root_berry_mice_elem
);
1265 BT_PUT(root_berry_third
);
1266 BT_PUT(root_berry_guard
);
1267 BT_PUT(root_berry_guard_elem
);
1268 BT_PUT(root_berry_one
);
1269 BT_PUT(root_berry_one_elem
);
1272 BT_PUT(root_loud_toys
);
1273 BT_PUT(root_loud_toys_elem
);
1274 BT_PUT(root_loud_spoon
);
1275 BT_PUT(root_loud_spoon_elem
);
1276 BT_PUT(root_loud_turkey
);
1277 BT_PUT(root_loud_turkey_elem
);
1278 BT_PUT(root_loud_inform
);
1279 BT_PUT(root_loud_inform_elem
);
1280 BT_PUT(root_loud_odd
);
1281 BT_PUT(root_loud_odd_elem
);
1282 BT_PUT(root_loud_amuck
);
1283 BT_PUT(root_loud_amuck_elem
);
1289 struct bt_ctf_field_type
*get_good_event_payload_type(void)
1292 Generated by bt-ctfirtg using the following input:
1342 length: event.fields.splendid
1347 length: event.context.cats
1352 length: event.context.berry.third
1357 length: stream.event.context.face.magic
1362 length: stream.event.header.id
1367 length: stream.packet.context.serious
1372 length: trace.packet.header.iron.dust
1378 struct bt_ctf_field_type
*root
= NULL
;
1379 struct bt_ctf_field_type
*root_splendid
= NULL
;
1380 struct bt_ctf_field_type
*root_relative
= NULL
;
1381 struct bt_ctf_field_type
*root_relative_equal
= NULL
;
1382 struct bt_ctf_field_type
*root_relative_equal_elem
= NULL
;
1383 struct bt_ctf_field_type
*root_relative_amuck
= NULL
;
1384 struct bt_ctf_field_type
*root_relative_amuck_elem
= NULL
;
1385 struct bt_ctf_field_type
*root_relative_push
= NULL
;
1386 struct bt_ctf_field_type
*root_relative_push_elem
= NULL
;
1387 struct bt_ctf_field_type
*root_relative_brick
= NULL
;
1388 struct bt_ctf_field_type
*root_relative_brick_elem
= NULL
;
1389 struct bt_ctf_field_type
*root_relative_crush
= NULL
;
1390 struct bt_ctf_field_type
*root_relative_crush_elem
= NULL
;
1391 struct bt_ctf_field_type
*root_relative_canvas
= NULL
;
1392 struct bt_ctf_field_type
*root_relative_canvas_elem
= NULL
;
1393 struct bt_ctf_field_type
*root_absolute
= NULL
;
1394 struct bt_ctf_field_type
*root_absolute_equal
= NULL
;
1395 struct bt_ctf_field_type
*root_absolute_equal_elem
= NULL
;
1396 struct bt_ctf_field_type
*root_absolute_amuck
= NULL
;
1397 struct bt_ctf_field_type
*root_absolute_amuck_elem
= NULL
;
1398 struct bt_ctf_field_type
*root_absolute_push
= NULL
;
1399 struct bt_ctf_field_type
*root_absolute_push_elem
= NULL
;
1400 struct bt_ctf_field_type
*root_absolute_brick
= NULL
;
1401 struct bt_ctf_field_type
*root_absolute_brick_elem
= NULL
;
1402 struct bt_ctf_field_type
*root_absolute_crush
= NULL
;
1403 struct bt_ctf_field_type
*root_absolute_crush_elem
= NULL
;
1404 struct bt_ctf_field_type
*root_absolute_canvas
= NULL
;
1405 struct bt_ctf_field_type
*root_absolute_canvas_elem
= NULL
;
1408 root
= bt_ctf_field_type_structure_create();
1410 ret
= bt_ctf_field_type_set_alignment(root
, 8);
1412 root_splendid
= bt_ctf_field_type_integer_create(12);
1413 assert(root_splendid
);
1414 ret
= bt_ctf_field_type_integer_set_signed(root_splendid
, 0);
1416 ret
= bt_ctf_field_type_integer_set_base(root_splendid
, 10);
1418 ret
= bt_ctf_field_type_integer_set_encoding(root_splendid
, BT_CTF_STRING_ENCODING_NONE
);
1420 ret
= bt_ctf_field_type_set_byte_order(root_splendid
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1422 ret
= bt_ctf_field_type_set_alignment(root_splendid
, 1);
1424 ret
= bt_ctf_field_type_structure_add_field(root
, root_splendid
, "splendid");
1426 root_relative
= bt_ctf_field_type_structure_create();
1427 assert(root_relative
);
1428 ret
= bt_ctf_field_type_set_alignment(root_relative
, 8);
1430 root_relative_equal_elem
= bt_ctf_field_type_string_create();
1431 assert(root_relative_equal_elem
);
1432 ret
= bt_ctf_field_type_string_set_encoding(root_relative_equal_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1434 root_relative_equal
= bt_ctf_field_type_sequence_create(root_relative_equal_elem
, "splendid");
1435 assert(root_relative_equal
);
1436 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_equal
, "equal");
1438 root_relative_amuck_elem
= bt_ctf_field_type_string_create();
1439 assert(root_relative_amuck_elem
);
1440 ret
= bt_ctf_field_type_string_set_encoding(root_relative_amuck_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1442 root_relative_amuck
= bt_ctf_field_type_sequence_create(root_relative_amuck_elem
, "id");
1443 assert(root_relative_amuck
);
1444 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_amuck
, "amuck");
1446 root_relative_push_elem
= bt_ctf_field_type_string_create();
1447 assert(root_relative_push_elem
);
1448 ret
= bt_ctf_field_type_string_set_encoding(root_relative_push_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1450 root_relative_push
= bt_ctf_field_type_sequence_create(root_relative_push_elem
, "berry.third");
1451 assert(root_relative_push
);
1452 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_push
, "push");
1454 root_relative_brick_elem
= bt_ctf_field_type_string_create();
1455 assert(root_relative_brick_elem
);
1456 ret
= bt_ctf_field_type_string_set_encoding(root_relative_brick_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1458 root_relative_brick
= bt_ctf_field_type_sequence_create(root_relative_brick_elem
, "face.magic");
1459 assert(root_relative_brick
);
1460 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_brick
, "brick");
1462 root_relative_crush_elem
= bt_ctf_field_type_string_create();
1463 assert(root_relative_crush_elem
);
1464 ret
= bt_ctf_field_type_string_set_encoding(root_relative_crush_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1466 root_relative_crush
= bt_ctf_field_type_sequence_create(root_relative_crush_elem
, "serious");
1467 assert(root_relative_crush
);
1468 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_crush
, "crush");
1470 root_relative_canvas_elem
= bt_ctf_field_type_string_create();
1471 assert(root_relative_canvas_elem
);
1472 ret
= bt_ctf_field_type_string_set_encoding(root_relative_canvas_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1474 root_relative_canvas
= bt_ctf_field_type_sequence_create(root_relative_canvas_elem
, "iron.dust");
1475 assert(root_relative_canvas
);
1476 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_canvas
, "canvas");
1478 ret
= bt_ctf_field_type_structure_add_field(root
, root_relative
, "relative");
1480 root_absolute
= bt_ctf_field_type_structure_create();
1481 assert(root_absolute
);
1482 ret
= bt_ctf_field_type_set_alignment(root_absolute
, 8);
1484 root_absolute_equal_elem
= bt_ctf_field_type_string_create();
1485 assert(root_absolute_equal_elem
);
1486 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_equal_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1488 root_absolute_equal
= bt_ctf_field_type_sequence_create(root_absolute_equal_elem
, "event.fields.splendid");
1489 assert(root_absolute_equal
);
1490 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_equal
, "equal");
1492 root_absolute_amuck_elem
= bt_ctf_field_type_string_create();
1493 assert(root_absolute_amuck_elem
);
1494 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_amuck_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1496 root_absolute_amuck
= bt_ctf_field_type_sequence_create(root_absolute_amuck_elem
, "stream.event.header.id");
1497 assert(root_absolute_amuck
);
1498 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_amuck
, "amuck");
1500 root_absolute_push_elem
= bt_ctf_field_type_string_create();
1501 assert(root_absolute_push_elem
);
1502 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_push_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1504 root_absolute_push
= bt_ctf_field_type_sequence_create(root_absolute_push_elem
, "event.context.berry.third");
1505 assert(root_absolute_push
);
1506 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_push
, "push");
1508 root_absolute_brick_elem
= bt_ctf_field_type_string_create();
1509 assert(root_absolute_brick_elem
);
1510 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_brick_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1512 root_absolute_brick
= bt_ctf_field_type_sequence_create(root_absolute_brick_elem
, "stream.event.context.face.magic");
1513 assert(root_absolute_brick
);
1514 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_brick
, "brick");
1516 root_absolute_crush_elem
= bt_ctf_field_type_string_create();
1517 assert(root_absolute_crush_elem
);
1518 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_crush_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1520 root_absolute_crush
= bt_ctf_field_type_sequence_create(root_absolute_crush_elem
, "stream.packet.context.serious");
1521 assert(root_absolute_crush
);
1522 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_crush
, "crush");
1524 root_absolute_canvas_elem
= bt_ctf_field_type_string_create();
1525 assert(root_absolute_canvas_elem
);
1526 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_canvas_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1528 root_absolute_canvas
= bt_ctf_field_type_sequence_create(root_absolute_canvas_elem
, "trace.packet.header.iron.dust");
1529 assert(root_absolute_canvas
);
1530 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_canvas
, "canvas");
1532 ret
= bt_ctf_field_type_structure_add_field(root
, root_absolute
, "absolute");
1535 BT_PUT(root_splendid
);
1536 BT_PUT(root_relative
);
1537 BT_PUT(root_relative_equal
);
1538 BT_PUT(root_relative_equal_elem
);
1539 BT_PUT(root_relative_amuck
);
1540 BT_PUT(root_relative_amuck_elem
);
1541 BT_PUT(root_relative_push
);
1542 BT_PUT(root_relative_push_elem
);
1543 BT_PUT(root_relative_brick
);
1544 BT_PUT(root_relative_brick_elem
);
1545 BT_PUT(root_relative_crush
);
1546 BT_PUT(root_relative_crush_elem
);
1547 BT_PUT(root_relative_canvas
);
1548 BT_PUT(root_relative_canvas_elem
);
1549 BT_PUT(root_absolute
);
1550 BT_PUT(root_absolute_equal
);
1551 BT_PUT(root_absolute_equal_elem
);
1552 BT_PUT(root_absolute_amuck
);
1553 BT_PUT(root_absolute_amuck_elem
);
1554 BT_PUT(root_absolute_push
);
1555 BT_PUT(root_absolute_push_elem
);
1556 BT_PUT(root_absolute_brick
);
1557 BT_PUT(root_absolute_brick_elem
);
1558 BT_PUT(root_absolute_crush
);
1559 BT_PUT(root_absolute_crush_elem
);
1560 BT_PUT(root_absolute_canvas
);
1561 BT_PUT(root_absolute_canvas_elem
);
1567 struct bt_ctf_field_type
*get_child_ft(struct bt_ctf_field_type
*parent_ft
,
1570 struct bt_ctf_field_type
*ft
= NULL
;
1572 switch (bt_ctf_field_type_get_type_id(parent_ft
)) {
1573 case CTF_TYPE_STRUCT
:
1574 ft
= bt_ctf_field_type_structure_get_field_type_by_name(
1578 case CTF_TYPE_VARIANT
:
1579 ft
= bt_ctf_field_type_variant_get_field_type_by_name(
1583 case CTF_TYPE_ARRAY
:
1584 ft
= bt_ctf_field_type_array_get_element_type(parent_ft
);
1587 case CTF_TYPE_SEQUENCE
:
1588 ft
= bt_ctf_field_type_sequence_get_element_type(parent_ft
);
1592 ft
= bt_ctf_field_type_enumeration_get_container_type(
1606 struct bt_ctf_field_type
*get_ft(struct bt_ctf_field_type
*root_ft
, ...)
1608 struct bt_ctf_field_type
*child_ft
= NULL
;
1609 struct bt_ctf_field_type
*ft
= root_ft
;
1612 va_start(ap
, root_ft
);
1616 const char *field_name
= va_arg(ap
, const char *);
1618 if (field_name
== NULL
) {
1622 child_ft
= get_child_ft(ft
, field_name
);
1629 BT_MOVE(ft
, child_ft
);
1638 #define FIELD_PATH_END -2
1641 int validate_field_path(struct bt_ctf_field_type
*field_type
, int int_root
, ...)
1643 enum bt_ctf_scope root
= int_root
;
1649 struct bt_ctf_field_path
*field_path
= NULL
;
1652 va_start(ap
, int_root
);
1653 if (bt_ctf_field_type_is_sequence(field_type
)) {
1654 field_path
= bt_ctf_field_type_sequence_get_length_field_path(
1656 } else if (bt_ctf_field_type_is_variant(field_type
)) {
1657 field_path
= bt_ctf_field_type_variant_get_tag_field_path(
1666 if (bt_ctf_field_path_get_root_scope(field_path
) != root
) {
1671 len
= bt_ctf_field_path_get_index_count(field_path
);
1674 expected_index
= va_arg(ap
, int);
1676 if (expected_index
== FIELD_PATH_END
) {
1684 actual_index
= bt_ctf_field_path_get_index(field_path
, i
);
1686 if (actual_index
== INT_MIN
) {
1694 if (i
!= len
|| expected_index
!= FIELD_PATH_END
) {
1706 void validate_test_pass(struct bt_ctf_trace
*trace
)
1708 struct bt_ctf_stream_class
*sc
;
1709 struct bt_ctf_event_class
*ec
;
1710 struct bt_ctf_field_type
*ph
;
1711 struct bt_ctf_field_type
*pc
;
1712 struct bt_ctf_field_type
*eh
;
1713 struct bt_ctf_field_type
*sec
;
1714 struct bt_ctf_field_type
*ectx
;
1715 struct bt_ctf_field_type
*ep
;
1716 struct bt_ctf_field_type
*ft_src
= NULL
;
1717 struct bt_ctf_field_type
*ft_target
= NULL
;
1718 struct bt_ctf_field_type
*ft_tag
= NULL
;
1720 sc
= bt_ctf_trace_get_stream_class_by_index(trace
, 0);
1722 ec
= bt_ctf_stream_class_get_event_class_by_index(sc
, 0);
1725 ph
= bt_ctf_trace_get_packet_header_type(trace
);
1726 ok(ph
, "Trace packet header still exists after successful validation");
1727 pc
= bt_ctf_stream_class_get_packet_context_type(sc
);
1728 ok(pc
, "Stream packet context still exists after successful validation");
1729 eh
= bt_ctf_stream_class_get_event_header_type(sc
);
1730 ok(eh
, "Stream event header still exists after successful validation");
1731 sec
= bt_ctf_stream_class_get_event_context_type(sc
);
1732 ok(sec
, "Stream event context still exists after successful validation");
1733 ectx
= bt_ctf_event_class_get_context_type(ec
);
1734 ok(ectx
, "Event context still exists after successful validation");
1735 ep
= bt_ctf_event_class_get_payload_type(ec
);
1736 ok(ep
, "Event payload still exists after successful validation");
1738 /* trace.packet.header.iron.fire.keen */
1739 ft_src
= get_ft(ph
, "iron", "fire", "keen", NULL
);
1740 ok(!validate_field_path(ft_src
, BT_CTF_SCOPE_TRACE_PACKET_HEADER
,
1741 3, 3, 0, FIELD_PATH_END
),
1742 "trace.packet.header.iron.fire.keen has the correct field path");
1745 /* trace.packet.header.iron.fire.keen.[element] */
1746 ft_src
= get_ft(ph
, "iron", "fire", "keen", "", NULL
);
1747 ok(!validate_field_path(ft_src
,
1748 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 2, FIELD_PATH_END
),
1749 "trace.packet.header.iron.fire.keen.[element] has the correct field path");
1750 ft_target
= get_ft(ph
, "iron", "parallel", NULL
);
1751 ft_tag
= bt_ctf_field_type_variant_get_tag_type(ft_src
);
1752 ok(ft_tag
== ft_target
,
1753 "trace.packet.header.iron.fire.keen.[element] has the correct tag type");
1758 /* trace.packet.header.iron.fire.keen.[element].BLUE */
1759 ft_src
= get_ft(ph
, "iron", "fire", "keen", "", "BLUE", NULL
);
1760 ok(!validate_field_path(ft_src
,
1761 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 0, FIELD_PATH_END
),
1762 "trace.packet.header.iron.fire.keen.[element].BLUE has the correct field path");
1765 /* trace.packet.header.iron.report */
1766 ft_src
= get_ft(ph
, "iron", "report", NULL
);
1767 ok(!validate_field_path(ft_src
,
1768 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
1769 "trace.packet.header.iron.report has the correct field path");
1772 /* trace.packet.header.iron.group */
1773 ft_src
= get_ft(ph
, "iron", "group", NULL
);
1774 ok(!validate_field_path(ft_src
,
1775 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 2, FIELD_PATH_END
),
1776 "trace.packet.header.iron.group has the correct field path");
1779 /* stream.packet.context.naive.[element] */
1780 ft_src
= get_ft(pc
, "naive", "", NULL
);
1781 ok(!validate_field_path(ft_src
,
1782 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1783 "stream.packet.context.naive.[element] has the correct field path");
1786 /* stream.packet.context.clover.whole */
1787 ft_src
= get_ft(pc
, "clover", "whole", NULL
);
1788 ok(!validate_field_path(ft_src
,
1789 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 2, FIELD_PATH_END
),
1790 "stream.packet.context.clover.whole has the correct field path");
1791 ft_target
= get_ft(ph
, "iron", "parallel", NULL
);
1792 ft_tag
= bt_ctf_field_type_variant_get_tag_type(ft_src
);
1793 ok(ft_tag
== ft_target
,
1794 "stream.packet.context.clover.whole has the correct tag type");
1799 /* stream.packet.context.clover.whole.BLUE */
1800 ft_src
= get_ft(pc
, "clover", "whole", "BLUE", NULL
);
1801 ok(!validate_field_path(ft_src
,
1802 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1803 "stream.packet.context.clover.whole.BLUE has the correct field path");
1806 /* stream.packet.context.clover.egg */
1807 ft_src
= get_ft(pc
, "clover", "egg", NULL
);
1808 ok(!validate_field_path(ft_src
,
1809 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1810 "stream.packet.context.clover.egg has the correct field path");
1813 /* stream.packet.context.clover.useful */
1814 ft_src
= get_ft(pc
, "clover", "useful", NULL
);
1815 ok(!validate_field_path(ft_src
,
1816 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1817 "stream.packet.context.clover.useful has the correct field path");
1820 /* stream.event.header.action.lucky */
1821 ft_src
= get_ft(eh
, "action", "lucky", NULL
);
1822 ok(!validate_field_path(ft_src
,
1823 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1824 "stream.event.header.action.lucky has the correct field path");
1827 /* stream.event.header.stiff */
1828 ft_src
= get_ft(eh
, "stiff", NULL
);
1829 ok(!validate_field_path(ft_src
,
1830 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 1, 1, FIELD_PATH_END
),
1831 "stream.event.header.stiff has the correct field path");
1834 /* stream.event.header.fruit.apple */
1835 ft_src
= get_ft(eh
, "fruit", "apple", NULL
);
1836 ok(!validate_field_path(ft_src
,
1837 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1838 "stream.event.header.fruit.apple has the correct field path");
1841 /* stream.event.context.face.branch */
1842 ft_src
= get_ft(sec
, "face", "branch", NULL
);
1843 ok(!validate_field_path(ft_src
,
1844 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1845 "stream.event.context.face.branch has the correct field path");
1848 /* stream.event.context.face.income */
1849 ft_src
= get_ft(sec
, "face", "income", NULL
);
1850 ok(!validate_field_path(ft_src
,
1851 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 0, FIELD_PATH_END
),
1852 "stream.event.context.face.income has the correct field path");
1855 /* stream.event.context.face.lucky */
1856 ft_src
= get_ft(sec
, "face", "lucky", NULL
);
1857 ok(!validate_field_path(ft_src
,
1858 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1859 "stream.event.context.face.lucky has the correct field path");
1862 /* stream.event.context.dream */
1863 ft_src
= get_ft(sec
, "dream", NULL
);
1864 ok(!validate_field_path(ft_src
,
1865 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1866 "stream.event.context.dream has the correct field path");
1869 /* stream.event.context.dream.[element] */
1870 ft_src
= get_ft(sec
, "dream", "", NULL
);
1871 ok(!validate_field_path(ft_src
,
1872 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
1873 "stream.event.context.dream.[element] has the correct field path");
1876 /* stream.event.context.dream.[element].[element] */
1877 ft_src
= get_ft(sec
, "dream", "", "", NULL
);
1878 ok(!validate_field_path(ft_src
,
1879 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1880 "stream.event.context.dream.[element].[element] has the correct field path");
1883 /* event.context.berry.porter */
1884 ft_src
= get_ft(ectx
, "berry", "porter", NULL
);
1885 ok(!validate_field_path(ft_src
,
1886 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1887 "event.context.berry.porter has the correct field path");
1890 /* event.context.berry.porter */
1891 ft_src
= get_ft(ectx
, "berry", "porter", NULL
);
1892 ok(!validate_field_path(ft_src
,
1893 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1894 "event.context.berry.porter has the correct field path");
1897 /* event.context.berry.mice */
1898 ft_src
= get_ft(ectx
, "berry", "mice", NULL
);
1899 ok(!validate_field_path(ft_src
,
1900 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1901 "event.context.berry.mice has the correct field path");
1904 /* event.context.berry.guard */
1905 ft_src
= get_ft(ectx
, "berry", "guard", NULL
);
1906 ok(!validate_field_path(ft_src
,
1907 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1908 "event.context.berry.guard has the correct field path");
1911 /* event.context.berry.one */
1912 ft_src
= get_ft(ectx
, "berry", "one", NULL
);
1913 ok(!validate_field_path(ft_src
,
1914 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1915 "event.context.berry.one has the correct field path");
1918 /* event.context.loud.toys */
1919 ft_src
= get_ft(ectx
, "loud", "toys", NULL
);
1920 ok(!validate_field_path(ft_src
,
1921 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1922 "event.context.loud.toys has the correct field path");
1925 /* event.context.loud.spoon */
1926 ft_src
= get_ft(ectx
, "loud", "spoon", NULL
);
1927 ok(!validate_field_path(ft_src
,
1928 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1929 "event.context.loud.spoon has the correct field path");
1932 /* event.context.loud.turkey */
1933 ft_src
= get_ft(ectx
, "loud", "turkey", NULL
);
1934 ok(!validate_field_path(ft_src
,
1935 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1936 "event.context.loud.turkey has the correct field path");
1939 /* event.context.loud.inform */
1940 ft_src
= get_ft(ectx
, "loud", "inform", NULL
);
1941 ok(!validate_field_path(ft_src
,
1942 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1943 "event.context.loud.inform has the correct field path");
1946 /* event.context.loud.odd */
1947 ft_src
= get_ft(ectx
, "loud", "odd", NULL
);
1948 ok(!validate_field_path(ft_src
,
1949 BT_CTF_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
1950 "event.context.loud.odd has the correct field path");
1953 /* event.context.loud.amuck */
1954 ft_src
= get_ft(ectx
, "loud", "amuck", NULL
);
1955 ok(!validate_field_path(ft_src
,
1956 BT_CTF_SCOPE_EVENT_CONTEXT
, 0, FIELD_PATH_END
),
1957 "event.context.loud.amuck has the correct field path");
1960 /* event.fields.relative.equal */
1961 ft_src
= get_ft(ep
, "relative", "equal", NULL
);
1962 ok(!validate_field_path(ft_src
,
1963 BT_CTF_SCOPE_EVENT_FIELDS
, 0, FIELD_PATH_END
),
1964 "event.fields.relative.equal has the correct field path");
1967 /* event.fields.relative.amuck */
1968 ft_src
= get_ft(ep
, "relative", "amuck", NULL
);
1969 ok(!validate_field_path(ft_src
,
1970 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 0, FIELD_PATH_END
),
1971 "event.fields.relative.amuck has the correct field path");
1974 /* event.fields.relative.push */
1975 ft_src
= get_ft(ep
, "relative", "push", NULL
);
1976 ok(!validate_field_path(ft_src
,
1977 BT_CTF_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
1978 "event.fields.relative.push has the correct field path");
1981 /* event.fields.relative.brick */
1982 ft_src
= get_ft(ep
, "relative", "brick", NULL
);
1983 ok(!validate_field_path(ft_src
,
1984 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1985 "event.fields.relative.brick has the correct field path");
1988 /* event.fields.relative.crush */
1989 ft_src
= get_ft(ep
, "relative", "crush", NULL
);
1990 ok(!validate_field_path(ft_src
,
1991 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1992 "event.fields.relative.crush has the correct field path");
1995 /* event.fields.relative.canvas */
1996 ft_src
= get_ft(ep
, "relative", "canvas", NULL
);
1997 ok(!validate_field_path(ft_src
,
1998 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
1999 "event.fields.relative.canvas has the correct field path");
2002 /* event.fields.absolute.equal */
2003 ft_src
= get_ft(ep
, "absolute", "equal", NULL
);
2004 ok(!validate_field_path(ft_src
,
2005 BT_CTF_SCOPE_EVENT_FIELDS
, 0, FIELD_PATH_END
),
2006 "event.fields.absolute.equal has the correct field path");
2009 /* event.fields.absolute.amuck */
2010 ft_src
= get_ft(ep
, "absolute", "amuck", NULL
);
2011 ok(!validate_field_path(ft_src
,
2012 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 0, FIELD_PATH_END
),
2013 "event.fields.absolute.amuck has the correct field path");
2016 /* event.fields.absolute.push */
2017 ft_src
= get_ft(ep
, "absolute", "push", NULL
);
2018 ok(!validate_field_path(ft_src
,
2019 BT_CTF_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
2020 "event.fields.absolute.push has the correct field path");
2023 /* event.fields.absolute.brick */
2024 ft_src
= get_ft(ep
, "absolute", "brick", NULL
);
2025 ok(!validate_field_path(ft_src
,
2026 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
2027 "event.fields.absolute.brick has the correct field path");
2030 /* event.fields.absolute.crush */
2031 ft_src
= get_ft(ep
, "absolute", "crush", NULL
);
2032 ok(!validate_field_path(ft_src
,
2033 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
2034 "event.fields.absolute.crush has the correct field path");
2037 /* event.fields.absolute.canvas */
2038 ft_src
= get_ft(ep
, "absolute", "canvas", NULL
);
2039 ok(!validate_field_path(ft_src
,
2040 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
2041 "event.fields.absolute.canvas has the correct field path");
2057 void test_pass(void)
2060 struct bt_ctf_trace
*trace
;
2061 struct bt_ctf_stream_class
*sc
;
2062 struct bt_ctf_event_class
*ec
;
2063 struct bt_ctf_field_type
*ph
;
2064 struct bt_ctf_field_type
*pc
;
2065 struct bt_ctf_field_type
*eh
;
2066 struct bt_ctf_field_type
*sec
;
2067 struct bt_ctf_field_type
*ectx
;
2068 struct bt_ctf_field_type
*ep
;
2070 trace
= bt_ctf_trace_create();
2072 ret
= bt_ctf_trace_set_native_byte_order(trace
,
2073 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2075 sc
= bt_ctf_stream_class_create("nice_piece_of_stream_class");
2077 ec
= bt_ctf_event_class_create("oh_what_an_event_class");
2080 ph
= get_good_packet_header_type();
2082 pc
= get_good_packet_context_type();
2084 eh
= get_good_event_header_type();
2086 sec
= get_good_stream_event_context_type();
2088 ectx
= get_good_event_context_type();
2090 ep
= get_good_event_payload_type();
2093 ret
= bt_ctf_trace_set_packet_header_type(trace
, ph
);
2095 ret
= bt_ctf_stream_class_set_packet_context_type(sc
, pc
);
2097 ret
= bt_ctf_stream_class_set_event_header_type(sc
, eh
);
2099 ret
= bt_ctf_stream_class_set_event_context_type(sc
, sec
);
2101 ret
= bt_ctf_event_class_set_context_type(ec
, ectx
);
2103 ret
= bt_ctf_event_class_set_payload_type(ec
, ep
);
2106 ret
= bt_ctf_stream_class_add_event_class(sc
, ec
);
2109 /* Validation happens here */
2110 ret
= bt_ctf_trace_add_stream_class(trace
, sc
);
2111 ok(ret
== 0, "Valid type system is considered valid");
2113 validate_test_pass(trace
);
2127 struct bt_ctf_event
*create_event_with_context_and_payload(
2128 struct bt_ctf_field_type
*ectx
, struct bt_ctf_field_type
*ep
)
2131 struct bt_ctf_stream_class
*sc
;
2132 struct bt_ctf_event_class
*ec
;
2133 struct bt_ctf_event
*event
;
2135 sc
= bt_ctf_stream_class_create("sc");
2137 ec
= bt_ctf_event_class_create("ec");
2141 ret
= bt_ctf_event_class_set_context_type(ec
, ectx
);
2146 ret
= bt_ctf_event_class_set_payload_type(ec
, ep
);
2150 ret
= bt_ctf_stream_class_add_event_class(sc
, ec
);
2153 /* Validation happens here */
2154 event
= bt_ctf_event_create(ec
);
2164 struct bt_ctf_field_type
*test_fail_unavailable_root_get_event_payload(void)
2167 Generated by bt-ctfirtg using the following input:
2176 length: stream.event.context.lol
2184 struct bt_ctf_field_type
*root
= NULL
;
2185 struct bt_ctf_field_type
*root_a
= NULL
;
2186 struct bt_ctf_field_type
*root_b
= NULL
;
2187 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2188 struct bt_ctf_field_type
*root_c
= NULL
;
2191 root
= bt_ctf_field_type_structure_create();
2193 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2195 root_a
= bt_ctf_field_type_integer_create(32);
2197 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2199 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2201 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2203 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2205 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2207 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2209 root_b_elem
= bt_ctf_field_type_string_create();
2210 assert(root_b_elem
);
2211 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2213 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "stream.event.context.lol");
2215 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2217 root_c
= bt_ctf_field_type_string_create();
2219 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2221 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2226 BT_PUT(root_b_elem
);
2233 void test_fail_unavailable_root(void)
2235 struct bt_ctf_field_type
*ep
;
2236 struct bt_ctf_event
*event
;
2238 ep
= test_fail_unavailable_root_get_event_payload();
2240 event
= create_event_with_context_and_payload(NULL
, ep
);
2241 ok(!event
, "Sequence FT with length in unavailable root is invalid");
2248 struct bt_ctf_field_type
*test_fail_target_is_root_get_event_payload(void)
2251 Generated by bt-ctfirtg using the following input:
2260 length: event.fields
2268 struct bt_ctf_field_type
*root
= NULL
;
2269 struct bt_ctf_field_type
*root_a
= NULL
;
2270 struct bt_ctf_field_type
*root_b
= NULL
;
2271 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2272 struct bt_ctf_field_type
*root_c
= NULL
;
2275 root
= bt_ctf_field_type_structure_create();
2277 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2279 root_a
= bt_ctf_field_type_integer_create(32);
2281 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2283 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2285 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2287 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2289 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2291 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2293 root_b_elem
= bt_ctf_field_type_string_create();
2294 assert(root_b_elem
);
2295 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2297 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "event.fields");
2299 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2301 root_c
= bt_ctf_field_type_string_create();
2303 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2305 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2310 BT_PUT(root_b_elem
);
2317 void test_fail_target_is_root(void)
2319 struct bt_ctf_field_type
*ep
;
2320 struct bt_ctf_event
*event
;
2322 ep
= test_fail_target_is_root_get_event_payload();
2324 event
= create_event_with_context_and_payload(NULL
, ep
);
2325 ok(!event
, "Sequence FT with root as its length is invalid");
2332 struct bt_ctf_field_type
*test_fail_target_is_after_source_get_ep(void)
2335 Generated by bt-ctfirtg using the following input:
2355 struct bt_ctf_field_type
*root
= NULL
;
2356 struct bt_ctf_field_type
*root_a
= NULL
;
2357 struct bt_ctf_field_type
*root_b
= NULL
;
2358 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2359 struct bt_ctf_field_type
*root_c
= NULL
;
2360 struct bt_ctf_field_type
*root_d
= NULL
;
2363 root
= bt_ctf_field_type_structure_create();
2365 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2367 root_a
= bt_ctf_field_type_integer_create(32);
2369 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2371 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2373 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2375 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2377 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2379 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2381 root_b_elem
= bt_ctf_field_type_string_create();
2382 assert(root_b_elem
);
2383 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2385 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "d");
2387 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2389 root_c
= bt_ctf_field_type_string_create();
2391 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2393 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2395 root_d
= bt_ctf_field_type_integer_create(17);
2397 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2399 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2401 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2403 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2405 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2407 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2412 BT_PUT(root_b_elem
);
2420 void test_fail_target_is_after_source(void)
2422 struct bt_ctf_field_type
*ep
;
2423 struct bt_ctf_event
*event
;
2425 ep
= test_fail_target_is_after_source_get_ep();
2427 event
= create_event_with_context_and_payload(NULL
, ep
);
2428 ok(!event
, "Sequence FT with length after it is invalid");
2435 struct bt_ctf_field_type
*test_fail_target_is_ancestor_of_source_get_ep(void)
2438 Generated by bt-ctfirtg using the following input:
2461 struct bt_ctf_field_type
*root
= NULL
;
2462 struct bt_ctf_field_type
*root_a
= NULL
;
2463 struct bt_ctf_field_type
*root_z
= NULL
;
2464 struct bt_ctf_field_type
*root_z_b
= NULL
;
2465 struct bt_ctf_field_type
*root_z_b_elem
= NULL
;
2466 struct bt_ctf_field_type
*root_c
= NULL
;
2467 struct bt_ctf_field_type
*root_d
= NULL
;
2470 root
= bt_ctf_field_type_structure_create();
2472 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2474 root_a
= bt_ctf_field_type_integer_create(32);
2476 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2478 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2480 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2482 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2484 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2486 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2488 root_z
= bt_ctf_field_type_structure_create();
2490 ret
= bt_ctf_field_type_set_alignment(root_z
, 8);
2492 root_z_b_elem
= bt_ctf_field_type_string_create();
2493 assert(root_z_b_elem
);
2494 ret
= bt_ctf_field_type_string_set_encoding(root_z_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2496 root_z_b
= bt_ctf_field_type_sequence_create(root_z_b_elem
, "z");
2498 ret
= bt_ctf_field_type_structure_add_field(root_z
, root_z_b
, "b");
2500 ret
= bt_ctf_field_type_structure_add_field(root
, root_z
, "z");
2502 root_c
= bt_ctf_field_type_string_create();
2504 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2506 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2508 root_d
= bt_ctf_field_type_integer_create(17);
2510 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2512 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2514 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2516 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2518 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2520 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2526 BT_PUT(root_z_b_elem
);
2534 void test_fail_target_is_ancestor_of_source(void)
2536 struct bt_ctf_field_type
*ep
;
2537 struct bt_ctf_event
*event
;
2539 ep
= test_fail_target_is_ancestor_of_source_get_ep();
2541 event
= create_event_with_context_and_payload(NULL
, ep
);
2542 ok(!event
, "Sequence FT with ancestor as its length is invalid");
2549 struct bt_ctf_field_type
*test_fail_target_is_source_get_event_payload(void)
2552 Generated by bt-ctfirtg using the following input:
2561 length: event.fields.b
2572 struct bt_ctf_field_type
*root
= NULL
;
2573 struct bt_ctf_field_type
*root_a
= NULL
;
2574 struct bt_ctf_field_type
*root_b
= NULL
;
2575 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2576 struct bt_ctf_field_type
*root_c
= NULL
;
2577 struct bt_ctf_field_type
*root_d
= NULL
;
2580 root
= bt_ctf_field_type_structure_create();
2582 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2584 root_a
= bt_ctf_field_type_integer_create(32);
2586 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2588 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2590 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2592 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2594 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2596 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2598 root_b_elem
= bt_ctf_field_type_string_create();
2599 assert(root_b_elem
);
2600 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2602 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "event.fields.b");
2604 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2606 root_c
= bt_ctf_field_type_string_create();
2608 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2610 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2612 root_d
= bt_ctf_field_type_integer_create(17);
2614 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2616 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2618 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2620 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2622 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2624 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2629 BT_PUT(root_b_elem
);
2637 void test_fail_target_is_source(void)
2639 struct bt_ctf_field_type
*ep
;
2640 struct bt_ctf_event
*event
;
2642 ep
= test_fail_target_is_source_get_event_payload();
2644 event
= create_event_with_context_and_payload(NULL
, ep
);
2645 ok(!event
, "Sequence FT with itself as its length is invalid");
2652 struct bt_ctf_field_type
*test_fail_variant_tag_is_not_enum_get_ep(void)
2655 Generated by bt-ctfirtg using the following input:
2676 struct bt_ctf_field_type
*root
= NULL
;
2677 struct bt_ctf_field_type
*root_a
= NULL
;
2678 struct bt_ctf_field_type
*root_b
= NULL
;
2679 struct bt_ctf_field_type
*root_b_HELLO
= NULL
;
2680 struct bt_ctf_field_type
*root_c
= NULL
;
2681 struct bt_ctf_field_type
*root_d
= NULL
;
2684 root
= bt_ctf_field_type_structure_create();
2686 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2688 root_a
= bt_ctf_field_type_integer_create(32);
2690 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2692 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2694 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2696 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2698 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2700 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2702 root_b
= bt_ctf_field_type_variant_create(NULL
, "a");
2704 root_b_HELLO
= bt_ctf_field_type_string_create();
2705 assert(root_b_HELLO
);
2706 ret
= bt_ctf_field_type_string_set_encoding(root_b_HELLO
, BT_CTF_STRING_ENCODING_UTF8
);
2708 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_HELLO
, "HELLO");
2710 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2712 root_c
= bt_ctf_field_type_string_create();
2714 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2716 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2718 root_d
= bt_ctf_field_type_integer_create(17);
2720 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2722 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2724 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2726 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2728 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2730 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2735 BT_PUT(root_b_HELLO
);
2743 void test_fail_variant_tag_is_not_enum(void)
2745 struct bt_ctf_field_type
*ep
;
2746 struct bt_ctf_event
*event
;
2748 ep
= test_fail_variant_tag_is_not_enum_get_ep();
2750 event
= create_event_with_context_and_payload(NULL
, ep
);
2751 ok(!event
, "Variant FT with non-enum FT as its tag FT is invalid");
2758 struct bt_ctf_field_type
*test_fail_variant_tag_mismatch_mappings_get_ep(void)
2761 Generated by bt-ctfirtg using the following input:
2788 struct bt_ctf_field_type
*root
= NULL
;
2789 struct bt_ctf_field_type
*root_a
= NULL
;
2790 struct bt_ctf_field_type
*root_a_int
= NULL
;
2791 struct bt_ctf_field_type
*root_b
= NULL
;
2792 struct bt_ctf_field_type
*root_b_GLASS
= NULL
;
2793 struct bt_ctf_field_type
*root_b_OF
= NULL
;
2794 struct bt_ctf_field_type
*root_c
= NULL
;
2797 root
= bt_ctf_field_type_structure_create();
2799 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2801 root_a_int
= bt_ctf_field_type_integer_create(16);
2803 ret
= bt_ctf_field_type_integer_set_signed(root_a_int
, 0);
2805 ret
= bt_ctf_field_type_integer_set_base(root_a_int
, 10);
2807 ret
= bt_ctf_field_type_integer_set_encoding(root_a_int
, BT_CTF_STRING_ENCODING_NONE
);
2809 ret
= bt_ctf_field_type_set_byte_order(root_a_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2811 ret
= bt_ctf_field_type_set_alignment(root_a_int
, 8);
2813 root_a
= bt_ctf_field_type_enumeration_create(root_a_int
);
2815 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "GLASS", 0, 0);
2817 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "OF", 1, 1);
2819 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "WATER", 2, 2);
2821 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2823 root_b
= bt_ctf_field_type_variant_create(NULL
, "a");
2825 root_b_GLASS
= bt_ctf_field_type_string_create();
2826 assert(root_b_GLASS
);
2827 ret
= bt_ctf_field_type_string_set_encoding(root_b_GLASS
, BT_CTF_STRING_ENCODING_UTF8
);
2829 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_GLASS
, "GLASS");
2831 root_b_OF
= bt_ctf_field_type_integer_create(2);
2833 ret
= bt_ctf_field_type_integer_set_signed(root_b_OF
, 0);
2835 ret
= bt_ctf_field_type_integer_set_base(root_b_OF
, 10);
2837 ret
= bt_ctf_field_type_integer_set_encoding(root_b_OF
, BT_CTF_STRING_ENCODING_NONE
);
2839 ret
= bt_ctf_field_type_set_byte_order(root_b_OF
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2841 ret
= bt_ctf_field_type_set_alignment(root_b_OF
, 1);
2843 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_OF
, "OF");
2845 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2847 root_c
= bt_ctf_field_type_string_create();
2849 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2851 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2857 BT_PUT(root_b_GLASS
);
2865 void test_fail_variant_tag_mismatch_mappings(void)
2867 struct bt_ctf_field_type
*ep
;
2868 struct bt_ctf_event
*event
;
2870 ep
= test_fail_variant_tag_mismatch_mappings_get_ep();
2872 event
= create_event_with_context_and_payload(NULL
, ep
);
2873 ok(!event
, "Variant FT with mismatching tag FT is invalid");
2880 struct bt_ctf_field_type
*test_fail_sequence_tag_is_not_int_get_ep(void)
2883 Generated by bt-ctfirtg using the following input:
2899 struct bt_ctf_field_type
*root
= NULL
;
2900 struct bt_ctf_field_type
*root_a
= NULL
;
2901 struct bt_ctf_field_type
*root_b
= NULL
;
2902 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2903 struct bt_ctf_field_type
*root_c
= NULL
;
2906 root
= bt_ctf_field_type_structure_create();
2908 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2910 root_a
= bt_ctf_field_type_string_create();
2912 ret
= bt_ctf_field_type_string_set_encoding(root_a
, BT_CTF_STRING_ENCODING_UTF8
);
2914 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2916 root_b_elem
= bt_ctf_field_type_string_create();
2917 assert(root_b_elem
);
2918 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2920 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "a");
2922 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2924 root_c
= bt_ctf_field_type_string_create();
2926 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2928 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2933 BT_PUT(root_b_elem
);
2940 void test_fail_sequence_tag_is_not_int(void)
2942 struct bt_ctf_field_type
*ep
;
2943 struct bt_ctf_event
*event
;
2945 ep
= test_fail_sequence_tag_is_not_int_get_ep();
2947 event
= create_event_with_context_and_payload(NULL
, ep
);
2948 ok(!event
, "Sequence FT with non-enum length FT is invalid");
2955 void test_fail(void)
2957 test_fail_unavailable_root();
2958 test_fail_target_is_root();
2959 test_fail_target_is_after_source();
2960 test_fail_target_is_ancestor_of_source();
2961 test_fail_target_is_source();
2962 test_fail_variant_tag_is_not_enum();
2963 test_fail_variant_tag_mismatch_mappings();
2964 test_fail_sequence_tag_is_not_int();