2 * test_bt_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/ref.h>
23 #include <babeltrace/ctf-ir/field-types.h>
24 #include <babeltrace/ctf-ir/field-path.h>
25 #include <babeltrace/ctf-ir/event.h>
26 #include <babeltrace/ctf-ir/event-class.h>
27 #include <babeltrace/ctf-ir/stream-class.h>
28 #include <babeltrace/ctf-ir/trace.h>
37 struct bt_field_type
*get_good_packet_header_field_type(void)
40 Generated by bt-ctfirtg using the following input:
100 length: trace.packet.header.iron.dust
105 length: trace.packet.header.stream_id
114 struct bt_field_type
*root
= NULL
;
115 struct bt_field_type
*root_magic
= NULL
;
116 struct bt_field_type
*root_uuid
= NULL
;
117 struct bt_field_type
*root_uuid_elem
= NULL
;
118 struct bt_field_type
*root_stream_id
= NULL
;
119 struct bt_field_type
*root_iron
= NULL
;
120 struct bt_field_type
*root_iron_listen
= NULL
;
121 struct bt_field_type
*root_iron_dust
= NULL
;
122 struct bt_field_type
*root_iron_parallel
= NULL
;
123 struct bt_field_type
*root_iron_parallel_int
= NULL
;
124 struct bt_field_type
*root_iron_fire
= NULL
;
125 struct bt_field_type
*root_iron_fire_word
= NULL
;
126 struct bt_field_type
*root_iron_fire_rabbit
= NULL
;
127 struct bt_field_type
*root_iron_fire_keen
= NULL
;
128 struct bt_field_type
*root_iron_fire_keen_elem
= NULL
;
129 struct bt_field_type
*root_iron_fire_keen_elem_RED
= NULL
;
130 struct bt_field_type
*root_iron_fire_keen_elem_BLUE
= NULL
;
131 struct bt_field_type
*root_iron_fire_keen_elem_BLUE_elem
= NULL
;
132 struct bt_field_type
*root_iron_fire_keen_elem_YELLOW
= NULL
;
133 struct bt_field_type
*root_iron_report
= NULL
;
134 struct bt_field_type
*root_iron_report_elem
= NULL
;
135 struct bt_field_type
*root_iron_group
= NULL
;
136 struct bt_field_type
*root_iron_group_elem
= NULL
;
137 struct bt_field_type
*root_serious
= NULL
;
140 root
= bt_field_type_structure_create();
142 ret
= bt_field_type_set_alignment(root
, 8);
144 root_magic
= bt_field_type_integer_create(32);
146 ret
= bt_field_type_integer_set_is_signed(root_magic
, 0);
148 ret
= bt_field_type_integer_set_base(root_magic
, 10);
150 ret
= bt_field_type_integer_set_encoding(root_magic
, BT_STRING_ENCODING_NONE
);
152 ret
= bt_field_type_set_byte_order(root_magic
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
154 ret
= bt_field_type_set_alignment(root_magic
, 8);
156 ret
= bt_field_type_structure_add_field(root
, root_magic
, "magic");
158 root_uuid_elem
= bt_field_type_integer_create(8);
159 assert(root_uuid_elem
);
160 ret
= bt_field_type_integer_set_is_signed(root_uuid_elem
, 0);
162 ret
= bt_field_type_integer_set_base(root_uuid_elem
, 10);
164 ret
= bt_field_type_integer_set_encoding(root_uuid_elem
, BT_STRING_ENCODING_NONE
);
166 ret
= bt_field_type_set_byte_order(root_uuid_elem
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
168 ret
= bt_field_type_set_alignment(root_uuid_elem
, 8);
170 root_uuid
= bt_field_type_array_create(root_uuid_elem
, 16);
172 ret
= bt_field_type_structure_add_field(root
, root_uuid
, "uuid");
174 root_stream_id
= bt_field_type_integer_create(32);
175 assert(root_stream_id
);
176 ret
= bt_field_type_integer_set_is_signed(root_stream_id
, 0);
178 ret
= bt_field_type_integer_set_base(root_stream_id
, 10);
180 ret
= bt_field_type_integer_set_encoding(root_stream_id
, BT_STRING_ENCODING_NONE
);
182 ret
= bt_field_type_set_byte_order(root_stream_id
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
184 ret
= bt_field_type_set_alignment(root_stream_id
, 8);
186 ret
= bt_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
188 root_iron
= bt_field_type_structure_create();
190 ret
= bt_field_type_set_alignment(root_iron
, 8);
192 root_iron_listen
= bt_field_type_string_create();
193 assert(root_iron_listen
);
194 ret
= bt_field_type_string_set_encoding(root_iron_listen
, BT_STRING_ENCODING_UTF8
);
196 ret
= bt_field_type_structure_add_field(root_iron
, root_iron_listen
, "listen");
198 root_iron_dust
= bt_field_type_integer_create(23);
199 assert(root_iron_dust
);
200 ret
= bt_field_type_integer_set_is_signed(root_iron_dust
, 0);
202 ret
= bt_field_type_integer_set_base(root_iron_dust
, 10);
204 ret
= bt_field_type_integer_set_encoding(root_iron_dust
, BT_STRING_ENCODING_NONE
);
206 ret
= bt_field_type_set_byte_order(root_iron_dust
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
208 ret
= bt_field_type_set_alignment(root_iron_dust
, 1);
210 ret
= bt_field_type_structure_add_field(root_iron
, root_iron_dust
, "dust");
212 root_iron_parallel_int
= bt_field_type_integer_create(10);
213 assert(root_iron_parallel_int
);
214 ret
= bt_field_type_integer_set_is_signed(root_iron_parallel_int
, 0);
216 ret
= bt_field_type_integer_set_base(root_iron_parallel_int
, 10);
218 ret
= bt_field_type_integer_set_encoding(root_iron_parallel_int
, BT_STRING_ENCODING_NONE
);
220 ret
= bt_field_type_set_byte_order(root_iron_parallel_int
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
222 ret
= bt_field_type_set_alignment(root_iron_parallel_int
, 1);
224 root_iron_parallel
= bt_field_type_enumeration_create(root_iron_parallel_int
);
225 assert(root_iron_parallel
);
226 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_iron_parallel
, "RED", 0, 0);
228 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_iron_parallel
, "BLUE", 1, 1);
230 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_iron_parallel
, "YELLOW", 2, 2);
232 ret
= bt_field_type_structure_add_field(root_iron
, root_iron_parallel
, "parallel");
234 root_iron_fire
= bt_field_type_structure_create();
235 assert(root_iron_fire
);
236 ret
= bt_field_type_set_alignment(root_iron_fire
, 8);
238 root_iron_fire_word
= bt_field_type_integer_create(17);
239 assert(root_iron_fire_word
);
240 ret
= bt_field_type_integer_set_is_signed(root_iron_fire_word
, 0);
242 ret
= bt_field_type_integer_set_base(root_iron_fire_word
, 10);
244 ret
= bt_field_type_integer_set_encoding(root_iron_fire_word
, BT_STRING_ENCODING_NONE
);
246 ret
= bt_field_type_set_byte_order(root_iron_fire_word
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
248 ret
= bt_field_type_set_alignment(root_iron_fire_word
, 1);
250 ret
= bt_field_type_structure_add_field(root_iron_fire
, root_iron_fire_word
, "word");
252 root_iron_fire_rabbit
= bt_field_type_string_create();
253 assert(root_iron_fire_rabbit
);
254 ret
= bt_field_type_string_set_encoding(root_iron_fire_rabbit
, BT_STRING_ENCODING_UTF8
);
256 ret
= bt_field_type_structure_add_field(root_iron_fire
, root_iron_fire_rabbit
, "rabbit");
258 root_iron_fire_keen_elem
= bt_field_type_variant_create(NULL
, "iron.parallel");
259 assert(root_iron_fire_keen_elem
);
260 root_iron_fire_keen_elem_RED
= bt_field_type_string_create();
261 assert(root_iron_fire_keen_elem_RED
);
262 ret
= bt_field_type_string_set_encoding(root_iron_fire_keen_elem_RED
, BT_STRING_ENCODING_UTF8
);
264 ret
= bt_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_RED
, "RED");
266 root_iron_fire_keen_elem_BLUE_elem
= bt_field_type_integer_create(5);
267 assert(root_iron_fire_keen_elem_BLUE_elem
);
268 ret
= bt_field_type_integer_set_is_signed(root_iron_fire_keen_elem_BLUE_elem
, 0);
270 ret
= bt_field_type_integer_set_base(root_iron_fire_keen_elem_BLUE_elem
, 10);
272 ret
= bt_field_type_integer_set_encoding(root_iron_fire_keen_elem_BLUE_elem
, BT_STRING_ENCODING_NONE
);
274 ret
= bt_field_type_set_byte_order(root_iron_fire_keen_elem_BLUE_elem
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
276 ret
= bt_field_type_set_alignment(root_iron_fire_keen_elem_BLUE_elem
, 1);
278 root_iron_fire_keen_elem_BLUE
= bt_field_type_sequence_create(root_iron_fire_keen_elem_BLUE_elem
, "magic");
279 assert(root_iron_fire_keen_elem_BLUE
);
280 ret
= bt_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_BLUE
, "BLUE");
282 root_iron_fire_keen_elem_YELLOW
= bt_field_type_structure_create();
283 assert(root_iron_fire_keen_elem_YELLOW
);
284 ret
= bt_field_type_set_alignment(root_iron_fire_keen_elem_YELLOW
, 1);
286 ret
= bt_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_YELLOW
, "YELLOW");
288 root_iron_fire_keen
= bt_field_type_sequence_create(root_iron_fire_keen_elem
, "word");
289 assert(root_iron_fire_keen
);
290 ret
= bt_field_type_structure_add_field(root_iron_fire
, root_iron_fire_keen
, "keen");
292 ret
= bt_field_type_structure_add_field(root_iron
, root_iron_fire
, "fire");
294 root_iron_report_elem
= bt_field_type_string_create();
295 assert(root_iron_report_elem
);
296 ret
= bt_field_type_string_set_encoding(root_iron_report_elem
, BT_STRING_ENCODING_UTF8
);
298 root_iron_report
= bt_field_type_sequence_create(root_iron_report_elem
, "trace.packet.header.iron.dust");
299 assert(root_iron_report
);
300 ret
= bt_field_type_structure_add_field(root_iron
, root_iron_report
, "report");
302 root_iron_group_elem
= bt_field_type_string_create();
303 assert(root_iron_group_elem
);
304 ret
= bt_field_type_string_set_encoding(root_iron_group_elem
, BT_STRING_ENCODING_UTF8
);
306 root_iron_group
= bt_field_type_sequence_create(root_iron_group_elem
, "trace.packet.header.stream_id");
307 assert(root_iron_group
);
308 ret
= bt_field_type_structure_add_field(root_iron
, root_iron_group
, "group");
310 ret
= bt_field_type_structure_add_field(root
, root_iron
, "iron");
312 root_serious
= bt_field_type_integer_create(1);
313 assert(root_serious
);
314 ret
= bt_field_type_integer_set_is_signed(root_serious
, 0);
316 ret
= bt_field_type_integer_set_base(root_serious
, 10);
318 ret
= bt_field_type_integer_set_encoding(root_serious
, BT_STRING_ENCODING_NONE
);
320 ret
= bt_field_type_set_byte_order(root_serious
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
322 ret
= bt_field_type_set_alignment(root_serious
, 1);
324 ret
= bt_field_type_structure_add_field(root
, root_serious
, "serious");
329 BT_PUT(root_uuid_elem
);
330 BT_PUT(root_stream_id
);
332 BT_PUT(root_iron_listen
);
333 BT_PUT(root_iron_dust
);
334 BT_PUT(root_iron_parallel
);
335 BT_PUT(root_iron_parallel_int
);
336 BT_PUT(root_iron_fire
);
337 BT_PUT(root_iron_fire_word
);
338 BT_PUT(root_iron_fire_rabbit
);
339 BT_PUT(root_iron_fire_keen
);
340 BT_PUT(root_iron_fire_keen_elem
);
341 BT_PUT(root_iron_fire_keen_elem_RED
);
342 BT_PUT(root_iron_fire_keen_elem_BLUE
);
343 BT_PUT(root_iron_fire_keen_elem_BLUE_elem
);
344 BT_PUT(root_iron_fire_keen_elem_YELLOW
);
345 BT_PUT(root_iron_report
);
346 BT_PUT(root_iron_report_elem
);
347 BT_PUT(root_iron_group
);
348 BT_PUT(root_iron_group_elem
);
349 BT_PUT(root_serious
);
355 struct bt_field_type
*get_good_packet_context_field_type(void)
358 Generated by bt-ctfirtg using the following input:
390 length: trace.packet.header.iron.fire.word
400 length: stream.packet.context.clover.oval
423 struct bt_field_type
*root
= NULL
;
424 struct bt_field_type
*root_placid
= NULL
;
425 struct bt_field_type
*root_meow
= NULL
;
426 struct bt_field_type
*root_serious
= NULL
;
427 struct bt_field_type
*root_naive
= NULL
;
428 struct bt_field_type
*root_naive_elem
= NULL
;
429 struct bt_field_type
*root_naive_elem_elem
= NULL
;
430 struct bt_field_type
*root_clover
= NULL
;
431 struct bt_field_type
*root_clover_oval
= NULL
;
432 struct bt_field_type
*root_clover_whole
= NULL
;
433 struct bt_field_type
*root_clover_whole_BLUE
= NULL
;
434 struct bt_field_type
*root_clover_whole_BLUE_elem
= NULL
;
435 struct bt_field_type
*root_clover_whole_RED
= NULL
;
436 struct bt_field_type
*root_clover_whole_YELLOW
= NULL
;
437 struct bt_field_type
*root_clover_egg
= NULL
;
438 struct bt_field_type
*root_clover_egg_elem
= NULL
;
439 struct bt_field_type
*root_clover_square
= NULL
;
440 struct bt_field_type
*root_clover_square_int
= NULL
;
441 struct bt_field_type
*root_clover_useful
= NULL
;
442 struct bt_field_type
*root_clover_useful_elem
= NULL
;
443 struct bt_field_type
*root_tart
= NULL
;
446 root
= bt_field_type_structure_create();
448 ret
= bt_field_type_set_alignment(root
, 8);
450 root_placid
= bt_field_type_integer_create(32);
452 ret
= bt_field_type_integer_set_is_signed(root_placid
, 0);
454 ret
= bt_field_type_integer_set_base(root_placid
, 10);
456 ret
= bt_field_type_integer_set_encoding(root_placid
, BT_STRING_ENCODING_NONE
);
458 ret
= bt_field_type_set_byte_order(root_placid
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
460 ret
= bt_field_type_set_alignment(root_placid
, 8);
462 ret
= bt_field_type_structure_add_field(root
, root_placid
, "placid");
464 root_meow
= bt_field_type_string_create();
466 ret
= bt_field_type_string_set_encoding(root_meow
, BT_STRING_ENCODING_UTF8
);
468 ret
= bt_field_type_structure_add_field(root
, root_meow
, "meow");
470 root_serious
= bt_field_type_integer_create(11);
471 assert(root_serious
);
472 ret
= bt_field_type_integer_set_is_signed(root_serious
, 0);
474 ret
= bt_field_type_integer_set_base(root_serious
, 10);
476 ret
= bt_field_type_integer_set_encoding(root_serious
, BT_STRING_ENCODING_NONE
);
478 ret
= bt_field_type_set_byte_order(root_serious
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
480 ret
= bt_field_type_set_alignment(root_serious
, 1);
482 ret
= bt_field_type_structure_add_field(root
, root_serious
, "serious");
484 root_naive_elem_elem
= bt_field_type_string_create();
485 assert(root_naive_elem_elem
);
486 ret
= bt_field_type_string_set_encoding(root_naive_elem_elem
, BT_STRING_ENCODING_UTF8
);
488 root_naive_elem
= bt_field_type_sequence_create(root_naive_elem_elem
, "placid");
489 assert(root_naive_elem
);
490 root_naive
= bt_field_type_array_create(root_naive_elem
, 17);
492 ret
= bt_field_type_structure_add_field(root
, root_naive
, "naive");
494 root_clover
= bt_field_type_structure_create();
496 ret
= bt_field_type_set_alignment(root_clover
, 1);
498 root_clover_oval
= bt_field_type_integer_create(17);
499 assert(root_clover_oval
);
500 ret
= bt_field_type_integer_set_is_signed(root_clover_oval
, 0);
502 ret
= bt_field_type_integer_set_base(root_clover_oval
, 10);
504 ret
= bt_field_type_integer_set_encoding(root_clover_oval
, BT_STRING_ENCODING_NONE
);
506 ret
= bt_field_type_set_byte_order(root_clover_oval
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
508 ret
= bt_field_type_set_alignment(root_clover_oval
, 1);
510 ret
= bt_field_type_structure_add_field(root_clover
, root_clover_oval
, "oval");
512 root_clover_whole
= bt_field_type_variant_create(NULL
, "iron.parallel");
513 assert(root_clover_whole
);
514 root_clover_whole_BLUE_elem
= bt_field_type_string_create();
515 assert(root_clover_whole_BLUE_elem
);
516 ret
= bt_field_type_string_set_encoding(root_clover_whole_BLUE_elem
, BT_STRING_ENCODING_UTF8
);
518 root_clover_whole_BLUE
= bt_field_type_sequence_create(root_clover_whole_BLUE_elem
, "trace.packet.header.iron.fire.word");
519 assert(root_clover_whole_BLUE
);
520 ret
= bt_field_type_variant_add_field(root_clover_whole
, root_clover_whole_BLUE
, "BLUE");
522 root_clover_whole_RED
= bt_field_type_integer_create(44);
523 assert(root_clover_whole_RED
);
524 ret
= bt_field_type_integer_set_is_signed(root_clover_whole_RED
, 0);
526 ret
= bt_field_type_integer_set_base(root_clover_whole_RED
, 10);
528 ret
= bt_field_type_integer_set_encoding(root_clover_whole_RED
, BT_STRING_ENCODING_NONE
);
530 ret
= bt_field_type_set_byte_order(root_clover_whole_RED
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
532 ret
= bt_field_type_set_alignment(root_clover_whole_RED
, 1);
534 ret
= bt_field_type_variant_add_field(root_clover_whole
, root_clover_whole_RED
, "RED");
536 root_clover_whole_YELLOW
= bt_field_type_string_create();
537 assert(root_clover_whole_YELLOW
);
538 ret
= bt_field_type_string_set_encoding(root_clover_whole_YELLOW
, BT_STRING_ENCODING_UTF8
);
540 ret
= bt_field_type_variant_add_field(root_clover_whole
, root_clover_whole_YELLOW
, "YELLOW");
542 ret
= bt_field_type_structure_add_field(root_clover
, root_clover_whole
, "whole");
544 root_clover_egg_elem
= bt_field_type_integer_create(55);
545 assert(root_clover_egg_elem
);
546 ret
= bt_field_type_integer_set_is_signed(root_clover_egg_elem
, 0);
548 ret
= bt_field_type_integer_set_base(root_clover_egg_elem
, 10);
550 ret
= bt_field_type_integer_set_encoding(root_clover_egg_elem
, BT_STRING_ENCODING_NONE
);
552 ret
= bt_field_type_set_byte_order(root_clover_egg_elem
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
554 ret
= bt_field_type_set_alignment(root_clover_egg_elem
, 1);
556 root_clover_egg
= bt_field_type_sequence_create(root_clover_egg_elem
, "stream.packet.context.clover.oval");
557 assert(root_clover_egg
);
558 ret
= bt_field_type_structure_add_field(root_clover
, root_clover_egg
, "egg");
560 root_clover_square_int
= bt_field_type_integer_create(12);
561 assert(root_clover_square_int
);
562 ret
= bt_field_type_integer_set_is_signed(root_clover_square_int
, 0);
564 ret
= bt_field_type_integer_set_base(root_clover_square_int
, 10);
566 ret
= bt_field_type_integer_set_encoding(root_clover_square_int
, BT_STRING_ENCODING_NONE
);
568 ret
= bt_field_type_set_byte_order(root_clover_square_int
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
570 ret
= bt_field_type_set_alignment(root_clover_square_int
, 1);
572 root_clover_square
= bt_field_type_enumeration_create(root_clover_square_int
);
573 assert(root_clover_square
);
574 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_clover_square
, "YOUNG", 0, 0);
576 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_clover_square
, "OLD", 1, 1);
578 ret
= bt_field_type_structure_add_field(root_clover
, root_clover_square
, "square");
580 root_clover_useful_elem
= bt_field_type_integer_create(2);
581 assert(root_clover_useful_elem
);
582 ret
= bt_field_type_integer_set_is_signed(root_clover_useful_elem
, 0);
584 ret
= bt_field_type_integer_set_base(root_clover_useful_elem
, 10);
586 ret
= bt_field_type_integer_set_encoding(root_clover_useful_elem
, BT_STRING_ENCODING_NONE
);
588 ret
= bt_field_type_set_byte_order(root_clover_useful_elem
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
590 ret
= bt_field_type_set_alignment(root_clover_useful_elem
, 1);
592 root_clover_useful
= bt_field_type_sequence_create(root_clover_useful_elem
, "serious");
593 assert(root_clover_useful
);
594 ret
= bt_field_type_structure_add_field(root_clover
, root_clover_useful
, "useful");
596 ret
= bt_field_type_structure_add_field(root
, root_clover
, "clover");
598 root_tart
= bt_field_type_string_create();
600 ret
= bt_field_type_string_set_encoding(root_tart
, BT_STRING_ENCODING_UTF8
);
602 ret
= bt_field_type_structure_add_field(root
, root_tart
, "tart");
607 BT_PUT(root_serious
);
609 BT_PUT(root_naive_elem
);
610 BT_PUT(root_naive_elem_elem
);
612 BT_PUT(root_clover_oval
);
613 BT_PUT(root_clover_whole
);
614 BT_PUT(root_clover_whole_BLUE
);
615 BT_PUT(root_clover_whole_BLUE_elem
);
616 BT_PUT(root_clover_whole_RED
);
617 BT_PUT(root_clover_whole_YELLOW
);
618 BT_PUT(root_clover_egg
);
619 BT_PUT(root_clover_egg_elem
);
620 BT_PUT(root_clover_square
);
621 BT_PUT(root_clover_square_int
);
622 BT_PUT(root_clover_useful
);
623 BT_PUT(root_clover_useful_elem
);
631 struct bt_field_type
*get_good_event_header_field_type(void)
634 Generated by bt-ctfirtg using the following input:
652 length: stream.packet.context.placid
659 length: trace.packet.header.serious
665 length: clover.whole.RED
673 length: action.special
680 struct bt_field_type
*root
= NULL
;
681 struct bt_field_type
*root_id
= NULL
;
682 struct bt_field_type
*root_timestamp
= NULL
;
683 struct bt_field_type
*root_action
= NULL
;
684 struct bt_field_type
*root_action_special
= NULL
;
685 struct bt_field_type
*root_action_lucky
= NULL
;
686 struct bt_field_type
*root_action_lucky_elem
= NULL
;
687 struct bt_field_type
*root_action_dream
= NULL
;
688 struct bt_field_type
*root_action_grandiose
= NULL
;
689 struct bt_field_type
*root_action_grandiose_elem
= NULL
;
690 struct bt_field_type
*root_stiff
= NULL
;
691 struct bt_field_type
*root_stiff_elem
= NULL
;
692 struct bt_field_type
*root_fruit
= NULL
;
693 struct bt_field_type
*root_fruit_apple
= NULL
;
694 struct bt_field_type
*root_fruit_apple_elem
= NULL
;
697 root
= bt_field_type_structure_create();
699 ret
= bt_field_type_set_alignment(root
, 8);
701 root_id
= bt_field_type_integer_create(17);
703 ret
= bt_field_type_integer_set_is_signed(root_id
, 0);
705 ret
= bt_field_type_integer_set_base(root_id
, 10);
707 ret
= bt_field_type_integer_set_encoding(root_id
, BT_STRING_ENCODING_NONE
);
709 ret
= bt_field_type_set_byte_order(root_id
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
711 ret
= bt_field_type_set_alignment(root_id
, 1);
713 ret
= bt_field_type_structure_add_field(root
, root_id
, "id");
715 root_timestamp
= bt_field_type_integer_create(64);
716 assert(root_timestamp
);
717 ret
= bt_field_type_integer_set_is_signed(root_timestamp
, 0);
719 ret
= bt_field_type_integer_set_base(root_timestamp
, 10);
721 ret
= bt_field_type_integer_set_encoding(root_timestamp
, BT_STRING_ENCODING_NONE
);
723 ret
= bt_field_type_set_byte_order(root_timestamp
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
725 ret
= bt_field_type_set_alignment(root_timestamp
, 8);
727 ret
= bt_field_type_structure_add_field(root
, root_timestamp
, "timestamp");
729 root_action
= bt_field_type_structure_create();
731 ret
= bt_field_type_set_alignment(root_action
, 8);
733 root_action_special
= bt_field_type_integer_create(17);
734 assert(root_action_special
);
735 ret
= bt_field_type_integer_set_is_signed(root_action_special
, 0);
737 ret
= bt_field_type_integer_set_base(root_action_special
, 10);
739 ret
= bt_field_type_integer_set_encoding(root_action_special
, BT_STRING_ENCODING_NONE
);
741 ret
= bt_field_type_set_byte_order(root_action_special
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
743 ret
= bt_field_type_set_alignment(root_action_special
, 1);
745 ret
= bt_field_type_structure_add_field(root_action
, root_action_special
, "special");
747 root_action_lucky_elem
= bt_field_type_string_create();
748 assert(root_action_lucky_elem
);
749 ret
= bt_field_type_string_set_encoding(root_action_lucky_elem
, BT_STRING_ENCODING_UTF8
);
751 root_action_lucky
= bt_field_type_sequence_create(root_action_lucky_elem
, "stream.packet.context.placid");
752 assert(root_action_lucky
);
753 ret
= bt_field_type_structure_add_field(root_action
, root_action_lucky
, "lucky");
755 root_action_dream
= bt_field_type_string_create();
756 assert(root_action_dream
);
757 ret
= bt_field_type_string_set_encoding(root_action_dream
, BT_STRING_ENCODING_UTF8
);
759 ret
= bt_field_type_structure_add_field(root_action
, root_action_dream
, "dream");
761 root_action_grandiose_elem
= bt_field_type_integer_create(3);
762 assert(root_action_grandiose_elem
);
763 ret
= bt_field_type_integer_set_is_signed(root_action_grandiose_elem
, 0);
765 ret
= bt_field_type_integer_set_base(root_action_grandiose_elem
, 10);
767 ret
= bt_field_type_integer_set_encoding(root_action_grandiose_elem
, BT_STRING_ENCODING_NONE
);
769 ret
= bt_field_type_set_byte_order(root_action_grandiose_elem
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
771 ret
= bt_field_type_set_alignment(root_action_grandiose_elem
, 1);
773 root_action_grandiose
= bt_field_type_sequence_create(root_action_grandiose_elem
, "trace.packet.header.serious");
774 assert(root_action_grandiose
);
775 ret
= bt_field_type_structure_add_field(root_action
, root_action_grandiose
, "grandiose");
777 ret
= bt_field_type_structure_add_field(root
, root_action
, "action");
779 root_stiff_elem
= bt_field_type_string_create();
780 assert(root_stiff_elem
);
781 ret
= bt_field_type_string_set_encoding(root_stiff_elem
, BT_STRING_ENCODING_UTF8
);
783 root_stiff
= bt_field_type_sequence_create(root_stiff_elem
, "clover.whole.RED");
785 ret
= bt_field_type_structure_add_field(root
, root_stiff
, "stiff");
787 root_fruit
= bt_field_type_structure_create();
789 ret
= bt_field_type_set_alignment(root_fruit
, 1);
791 root_fruit_apple_elem
= bt_field_type_integer_create(5);
792 assert(root_fruit_apple_elem
);
793 ret
= bt_field_type_integer_set_is_signed(root_fruit_apple_elem
, 0);
795 ret
= bt_field_type_integer_set_base(root_fruit_apple_elem
, 10);
797 ret
= bt_field_type_integer_set_encoding(root_fruit_apple_elem
, BT_STRING_ENCODING_NONE
);
799 ret
= bt_field_type_set_byte_order(root_fruit_apple_elem
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
801 ret
= bt_field_type_set_alignment(root_fruit_apple_elem
, 1);
803 root_fruit_apple
= bt_field_type_sequence_create(root_fruit_apple_elem
, "action.special");
804 assert(root_fruit_apple
);
805 ret
= bt_field_type_structure_add_field(root_fruit
, root_fruit_apple
, "apple");
807 ret
= bt_field_type_structure_add_field(root
, root_fruit
, "fruit");
811 BT_PUT(root_timestamp
);
813 BT_PUT(root_action_special
);
814 BT_PUT(root_action_lucky
);
815 BT_PUT(root_action_lucky_elem
);
816 BT_PUT(root_action_dream
);
817 BT_PUT(root_action_grandiose
);
818 BT_PUT(root_action_grandiose_elem
);
820 BT_PUT(root_stiff_elem
);
822 BT_PUT(root_fruit_apple
);
823 BT_PUT(root_fruit_apple_elem
);
829 struct bt_field_type
*get_good_stream_event_context_field_type(void)
832 Generated by bt-ctfirtg using the following input:
862 length: stream.packet.context.placid
865 length: trace.packet.header.iron.dust
868 length: stream.event.context.face.magic
877 struct bt_field_type
*root
= NULL
;
878 struct bt_field_type
*root_face
= NULL
;
879 struct bt_field_type
*root_face_branch
= NULL
;
880 struct bt_field_type
*root_face_branch_elem
= NULL
;
881 struct bt_field_type
*root_face_income
= NULL
;
882 struct bt_field_type
*root_face_income_elem
= NULL
;
883 struct bt_field_type
*root_face_magic
= NULL
;
884 struct bt_field_type
*root_face_lucky
= NULL
;
885 struct bt_field_type
*root_face_lucky_elem
= NULL
;
886 struct bt_field_type
*root_cats
= NULL
;
887 struct bt_field_type
*root_dream
= NULL
;
888 struct bt_field_type
*root_dream_elem
= NULL
;
889 struct bt_field_type
*root_dream_elem_elem
= NULL
;
890 struct bt_field_type
*root_dream_elem_elem_elem
= NULL
;
891 struct bt_field_type
*root_stream_id
= NULL
;
894 root
= bt_field_type_structure_create();
896 ret
= bt_field_type_set_alignment(root
, 8);
898 root_face
= bt_field_type_structure_create();
900 ret
= bt_field_type_set_alignment(root_face
, 8);
902 root_face_branch_elem
= bt_field_type_string_create();
903 assert(root_face_branch_elem
);
904 ret
= bt_field_type_string_set_encoding(root_face_branch_elem
, BT_STRING_ENCODING_UTF8
);
906 root_face_branch
= bt_field_type_sequence_create(root_face_branch_elem
, "serious");
907 assert(root_face_branch
);
908 ret
= bt_field_type_structure_add_field(root_face
, root_face_branch
, "branch");
910 root_face_income_elem
= bt_field_type_string_create();
911 assert(root_face_income_elem
);
912 ret
= bt_field_type_string_set_encoding(root_face_income_elem
, BT_STRING_ENCODING_UTF8
);
914 root_face_income
= bt_field_type_sequence_create(root_face_income_elem
, "magic");
915 assert(root_face_income
);
916 ret
= bt_field_type_structure_add_field(root_face
, root_face_income
, "income");
918 root_face_magic
= bt_field_type_integer_create(23);
919 assert(root_face_magic
);
920 ret
= bt_field_type_integer_set_is_signed(root_face_magic
, 0);
922 ret
= bt_field_type_integer_set_base(root_face_magic
, 10);
924 ret
= bt_field_type_integer_set_encoding(root_face_magic
, BT_STRING_ENCODING_NONE
);
926 ret
= bt_field_type_set_byte_order(root_face_magic
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
928 ret
= bt_field_type_set_alignment(root_face_magic
, 1);
930 ret
= bt_field_type_structure_add_field(root_face
, root_face_magic
, "magic");
932 root_face_lucky_elem
= bt_field_type_string_create();
933 assert(root_face_lucky_elem
);
934 ret
= bt_field_type_string_set_encoding(root_face_lucky_elem
, BT_STRING_ENCODING_UTF8
);
936 root_face_lucky
= bt_field_type_sequence_create(root_face_lucky_elem
, "magic");
937 assert(root_face_lucky
);
938 ret
= bt_field_type_structure_add_field(root_face
, root_face_lucky
, "lucky");
940 ret
= bt_field_type_structure_add_field(root
, root_face
, "face");
942 root_cats
= bt_field_type_integer_create(5);
944 ret
= bt_field_type_integer_set_is_signed(root_cats
, 0);
946 ret
= bt_field_type_integer_set_base(root_cats
, 10);
948 ret
= bt_field_type_integer_set_encoding(root_cats
, BT_STRING_ENCODING_NONE
);
950 ret
= bt_field_type_set_byte_order(root_cats
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
952 ret
= bt_field_type_set_alignment(root_cats
, 1);
954 ret
= bt_field_type_structure_add_field(root
, root_cats
, "cats");
956 root_dream_elem_elem_elem
= bt_field_type_string_create();
957 assert(root_dream_elem_elem_elem
);
958 ret
= bt_field_type_string_set_encoding(root_dream_elem_elem_elem
, BT_STRING_ENCODING_UTF8
);
960 root_dream_elem_elem
= bt_field_type_sequence_create(root_dream_elem_elem_elem
, "stream.event.context.face.magic");
961 assert(root_dream_elem_elem
);
962 root_dream_elem
= bt_field_type_sequence_create(root_dream_elem_elem
, "trace.packet.header.iron.dust");
963 assert(root_dream_elem
);
964 root_dream
= bt_field_type_sequence_create(root_dream_elem
, "stream.packet.context.placid");
966 ret
= bt_field_type_structure_add_field(root
, root_dream
, "dream");
968 root_stream_id
= bt_field_type_integer_create(9);
969 assert(root_stream_id
);
970 ret
= bt_field_type_integer_set_is_signed(root_stream_id
, 0);
972 ret
= bt_field_type_integer_set_base(root_stream_id
, 10);
974 ret
= bt_field_type_integer_set_encoding(root_stream_id
, BT_STRING_ENCODING_NONE
);
976 ret
= bt_field_type_set_byte_order(root_stream_id
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
978 ret
= bt_field_type_set_alignment(root_stream_id
, 1);
980 ret
= bt_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
984 BT_PUT(root_face_branch
);
985 BT_PUT(root_face_branch_elem
);
986 BT_PUT(root_face_income
);
987 BT_PUT(root_face_income_elem
);
988 BT_PUT(root_face_magic
);
989 BT_PUT(root_face_lucky
);
990 BT_PUT(root_face_lucky_elem
);
993 BT_PUT(root_dream_elem
);
994 BT_PUT(root_dream_elem_elem
);
995 BT_PUT(root_dream_elem_elem_elem
);
996 BT_PUT(root_stream_id
);
1002 struct bt_field_type
*get_good_event_context_field_type(void)
1005 Generated by bt-ctfirtg using the following input:
1027 length: action.special
1040 length: iron.fire.word
1051 length: trace.packet.header.iron.fire.word
1056 length: stream.packet.context.clover.oval
1061 length: stream.event.header.action.special
1066 length: stream.event.context.face.magic
1076 length: event.context.film
1082 struct bt_field_type
*root
= NULL
;
1083 struct bt_field_type
*root_film
= NULL
;
1084 struct bt_field_type
*root_berry
= NULL
;
1085 struct bt_field_type
*root_berry_pine
= NULL
;
1086 struct bt_field_type
*root_berry_pine_elem
= NULL
;
1087 struct bt_field_type
*root_berry_porter
= NULL
;
1088 struct bt_field_type
*root_berry_porter_elem
= NULL
;
1089 struct bt_field_type
*root_berry_mice
= NULL
;
1090 struct bt_field_type
*root_berry_mice_elem
= NULL
;
1091 struct bt_field_type
*root_berry_third
= NULL
;
1092 struct bt_field_type
*root_berry_guard
= NULL
;
1093 struct bt_field_type
*root_berry_guard_elem
= NULL
;
1094 struct bt_field_type
*root_berry_one
= NULL
;
1095 struct bt_field_type
*root_berry_one_elem
= NULL
;
1096 struct bt_field_type
*root_cats
= NULL
;
1097 struct bt_field_type
*root_loud
= NULL
;
1098 struct bt_field_type
*root_loud_toys
= NULL
;
1099 struct bt_field_type
*root_loud_toys_elem
= NULL
;
1100 struct bt_field_type
*root_loud_spoon
= NULL
;
1101 struct bt_field_type
*root_loud_spoon_elem
= NULL
;
1102 struct bt_field_type
*root_loud_turkey
= NULL
;
1103 struct bt_field_type
*root_loud_turkey_elem
= NULL
;
1104 struct bt_field_type
*root_loud_inform
= NULL
;
1105 struct bt_field_type
*root_loud_inform_elem
= NULL
;
1106 struct bt_field_type
*root_loud_odd
= NULL
;
1107 struct bt_field_type
*root_loud_odd_elem
= NULL
;
1108 struct bt_field_type
*root_loud_amuck
= NULL
;
1109 struct bt_field_type
*root_loud_amuck_elem
= NULL
;
1112 root
= bt_field_type_structure_create();
1114 ret
= bt_field_type_set_alignment(root
, 8);
1116 root_film
= bt_field_type_integer_create(19);
1118 ret
= bt_field_type_integer_set_is_signed(root_film
, 0);
1120 ret
= bt_field_type_integer_set_base(root_film
, 10);
1122 ret
= bt_field_type_integer_set_encoding(root_film
, BT_STRING_ENCODING_NONE
);
1124 ret
= bt_field_type_set_byte_order(root_film
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
1126 ret
= bt_field_type_set_alignment(root_film
, 1);
1128 ret
= bt_field_type_structure_add_field(root
, root_film
, "film");
1130 root_berry
= bt_field_type_structure_create();
1132 ret
= bt_field_type_set_alignment(root_berry
, 8);
1134 root_berry_pine_elem
= bt_field_type_string_create();
1135 assert(root_berry_pine_elem
);
1136 ret
= bt_field_type_string_set_encoding(root_berry_pine_elem
, BT_STRING_ENCODING_UTF8
);
1138 root_berry_pine
= bt_field_type_sequence_create(root_berry_pine_elem
, "stream_id");
1139 assert(root_berry_pine
);
1140 ret
= bt_field_type_structure_add_field(root_berry
, root_berry_pine
, "pine");
1142 root_berry_porter_elem
= bt_field_type_string_create();
1143 assert(root_berry_porter_elem
);
1144 ret
= bt_field_type_string_set_encoding(root_berry_porter_elem
, BT_STRING_ENCODING_UTF8
);
1146 root_berry_porter
= bt_field_type_sequence_create(root_berry_porter_elem
, "face.magic");
1147 assert(root_berry_porter
);
1148 ret
= bt_field_type_structure_add_field(root_berry
, root_berry_porter
, "porter");
1150 root_berry_mice_elem
= bt_field_type_string_create();
1151 assert(root_berry_mice_elem
);
1152 ret
= bt_field_type_string_set_encoding(root_berry_mice_elem
, BT_STRING_ENCODING_UTF8
);
1154 root_berry_mice
= bt_field_type_sequence_create(root_berry_mice_elem
, "action.special");
1155 assert(root_berry_mice
);
1156 ret
= bt_field_type_structure_add_field(root_berry
, root_berry_mice
, "mice");
1158 root_berry_third
= bt_field_type_integer_create(18);
1159 assert(root_berry_third
);
1160 ret
= bt_field_type_integer_set_is_signed(root_berry_third
, 0);
1162 ret
= bt_field_type_integer_set_base(root_berry_third
, 10);
1164 ret
= bt_field_type_integer_set_encoding(root_berry_third
, BT_STRING_ENCODING_NONE
);
1166 ret
= bt_field_type_set_byte_order(root_berry_third
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
1168 ret
= bt_field_type_set_alignment(root_berry_third
, 1);
1170 ret
= bt_field_type_structure_add_field(root_berry
, root_berry_third
, "third");
1172 root_berry_guard_elem
= bt_field_type_string_create();
1173 assert(root_berry_guard_elem
);
1174 ret
= bt_field_type_string_set_encoding(root_berry_guard_elem
, BT_STRING_ENCODING_UTF8
);
1176 root_berry_guard
= bt_field_type_sequence_create(root_berry_guard_elem
, "clover.oval");
1177 assert(root_berry_guard
);
1178 ret
= bt_field_type_structure_add_field(root_berry
, root_berry_guard
, "guard");
1180 root_berry_one_elem
= bt_field_type_string_create();
1181 assert(root_berry_one_elem
);
1182 ret
= bt_field_type_string_set_encoding(root_berry_one_elem
, BT_STRING_ENCODING_UTF8
);
1184 root_berry_one
= bt_field_type_sequence_create(root_berry_one_elem
, "iron.fire.word");
1185 assert(root_berry_one
);
1186 ret
= bt_field_type_structure_add_field(root_berry
, root_berry_one
, "one");
1188 ret
= bt_field_type_structure_add_field(root
, root_berry
, "berry");
1190 root_cats
= bt_field_type_integer_create(55);
1192 ret
= bt_field_type_integer_set_is_signed(root_cats
, 0);
1194 ret
= bt_field_type_integer_set_base(root_cats
, 10);
1196 ret
= bt_field_type_integer_set_encoding(root_cats
, BT_STRING_ENCODING_NONE
);
1198 ret
= bt_field_type_set_byte_order(root_cats
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
1200 ret
= bt_field_type_set_alignment(root_cats
, 1);
1202 ret
= bt_field_type_structure_add_field(root
, root_cats
, "cats");
1204 root_loud
= bt_field_type_structure_create();
1206 ret
= bt_field_type_set_alignment(root_loud
, 8);
1208 root_loud_toys_elem
= bt_field_type_string_create();
1209 assert(root_loud_toys_elem
);
1210 ret
= bt_field_type_string_set_encoding(root_loud_toys_elem
, BT_STRING_ENCODING_UTF8
);
1212 root_loud_toys
= bt_field_type_sequence_create(root_loud_toys_elem
, "trace.packet.header.iron.fire.word");
1213 assert(root_loud_toys
);
1214 ret
= bt_field_type_structure_add_field(root_loud
, root_loud_toys
, "toys");
1216 root_loud_spoon_elem
= bt_field_type_string_create();
1217 assert(root_loud_spoon_elem
);
1218 ret
= bt_field_type_string_set_encoding(root_loud_spoon_elem
, BT_STRING_ENCODING_UTF8
);
1220 root_loud_spoon
= bt_field_type_sequence_create(root_loud_spoon_elem
, "stream.packet.context.clover.oval");
1221 assert(root_loud_spoon
);
1222 ret
= bt_field_type_structure_add_field(root_loud
, root_loud_spoon
, "spoon");
1224 root_loud_turkey_elem
= bt_field_type_string_create();
1225 assert(root_loud_turkey_elem
);
1226 ret
= bt_field_type_string_set_encoding(root_loud_turkey_elem
, BT_STRING_ENCODING_UTF8
);
1228 root_loud_turkey
= bt_field_type_sequence_create(root_loud_turkey_elem
, "stream.event.header.action.special");
1229 assert(root_loud_turkey
);
1230 ret
= bt_field_type_structure_add_field(root_loud
, root_loud_turkey
, "turkey");
1232 root_loud_inform_elem
= bt_field_type_string_create();
1233 assert(root_loud_inform_elem
);
1234 ret
= bt_field_type_string_set_encoding(root_loud_inform_elem
, BT_STRING_ENCODING_UTF8
);
1236 root_loud_inform
= bt_field_type_sequence_create(root_loud_inform_elem
, "stream.event.context.face.magic");
1237 assert(root_loud_inform
);
1238 ret
= bt_field_type_structure_add_field(root_loud
, root_loud_inform
, "inform");
1240 root_loud_odd_elem
= bt_field_type_string_create();
1241 assert(root_loud_odd_elem
);
1242 ret
= bt_field_type_string_set_encoding(root_loud_odd_elem
, BT_STRING_ENCODING_UTF8
);
1244 root_loud_odd
= bt_field_type_sequence_create(root_loud_odd_elem
, "berry.third");
1245 assert(root_loud_odd
);
1246 ret
= bt_field_type_structure_add_field(root_loud
, root_loud_odd
, "odd");
1248 root_loud_amuck_elem
= bt_field_type_string_create();
1249 assert(root_loud_amuck_elem
);
1250 ret
= bt_field_type_string_set_encoding(root_loud_amuck_elem
, BT_STRING_ENCODING_UTF8
);
1252 root_loud_amuck
= bt_field_type_sequence_create(root_loud_amuck_elem
, "event.context.film");
1253 assert(root_loud_amuck
);
1254 ret
= bt_field_type_structure_add_field(root_loud
, root_loud_amuck
, "amuck");
1256 ret
= bt_field_type_structure_add_field(root
, root_loud
, "loud");
1261 BT_PUT(root_berry_pine
);
1262 BT_PUT(root_berry_pine_elem
);
1263 BT_PUT(root_berry_porter
);
1264 BT_PUT(root_berry_porter_elem
);
1265 BT_PUT(root_berry_mice
);
1266 BT_PUT(root_berry_mice_elem
);
1267 BT_PUT(root_berry_third
);
1268 BT_PUT(root_berry_guard
);
1269 BT_PUT(root_berry_guard_elem
);
1270 BT_PUT(root_berry_one
);
1271 BT_PUT(root_berry_one_elem
);
1274 BT_PUT(root_loud_toys
);
1275 BT_PUT(root_loud_toys_elem
);
1276 BT_PUT(root_loud_spoon
);
1277 BT_PUT(root_loud_spoon_elem
);
1278 BT_PUT(root_loud_turkey
);
1279 BT_PUT(root_loud_turkey_elem
);
1280 BT_PUT(root_loud_inform
);
1281 BT_PUT(root_loud_inform_elem
);
1282 BT_PUT(root_loud_odd
);
1283 BT_PUT(root_loud_odd_elem
);
1284 BT_PUT(root_loud_amuck
);
1285 BT_PUT(root_loud_amuck_elem
);
1291 struct bt_field_type
*get_good_event_payload_field_type(void)
1294 Generated by bt-ctfirtg using the following input:
1344 length: event.fields.splendid
1349 length: event.context.cats
1354 length: event.context.berry.third
1359 length: stream.event.context.face.magic
1364 length: stream.event.header.id
1369 length: stream.packet.context.serious
1374 length: trace.packet.header.iron.dust
1380 struct bt_field_type
*root
= NULL
;
1381 struct bt_field_type
*root_splendid
= NULL
;
1382 struct bt_field_type
*root_relative
= NULL
;
1383 struct bt_field_type
*root_relative_equal
= NULL
;
1384 struct bt_field_type
*root_relative_equal_elem
= NULL
;
1385 struct bt_field_type
*root_relative_amuck
= NULL
;
1386 struct bt_field_type
*root_relative_amuck_elem
= NULL
;
1387 struct bt_field_type
*root_relative_push
= NULL
;
1388 struct bt_field_type
*root_relative_push_elem
= NULL
;
1389 struct bt_field_type
*root_relative_brick
= NULL
;
1390 struct bt_field_type
*root_relative_brick_elem
= NULL
;
1391 struct bt_field_type
*root_relative_crush
= NULL
;
1392 struct bt_field_type
*root_relative_crush_elem
= NULL
;
1393 struct bt_field_type
*root_relative_canvas
= NULL
;
1394 struct bt_field_type
*root_relative_canvas_elem
= NULL
;
1395 struct bt_field_type
*root_absolute
= NULL
;
1396 struct bt_field_type
*root_absolute_equal
= NULL
;
1397 struct bt_field_type
*root_absolute_equal_elem
= NULL
;
1398 struct bt_field_type
*root_absolute_amuck
= NULL
;
1399 struct bt_field_type
*root_absolute_amuck_elem
= NULL
;
1400 struct bt_field_type
*root_absolute_push
= NULL
;
1401 struct bt_field_type
*root_absolute_push_elem
= NULL
;
1402 struct bt_field_type
*root_absolute_brick
= NULL
;
1403 struct bt_field_type
*root_absolute_brick_elem
= NULL
;
1404 struct bt_field_type
*root_absolute_crush
= NULL
;
1405 struct bt_field_type
*root_absolute_crush_elem
= NULL
;
1406 struct bt_field_type
*root_absolute_canvas
= NULL
;
1407 struct bt_field_type
*root_absolute_canvas_elem
= NULL
;
1410 root
= bt_field_type_structure_create();
1412 ret
= bt_field_type_set_alignment(root
, 8);
1414 root_splendid
= bt_field_type_integer_create(12);
1415 assert(root_splendid
);
1416 ret
= bt_field_type_integer_set_is_signed(root_splendid
, 0);
1418 ret
= bt_field_type_integer_set_base(root_splendid
, 10);
1420 ret
= bt_field_type_integer_set_encoding(root_splendid
, BT_STRING_ENCODING_NONE
);
1422 ret
= bt_field_type_set_byte_order(root_splendid
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
1424 ret
= bt_field_type_set_alignment(root_splendid
, 1);
1426 ret
= bt_field_type_structure_add_field(root
, root_splendid
, "splendid");
1428 root_relative
= bt_field_type_structure_create();
1429 assert(root_relative
);
1430 ret
= bt_field_type_set_alignment(root_relative
, 8);
1432 root_relative_equal_elem
= bt_field_type_string_create();
1433 assert(root_relative_equal_elem
);
1434 ret
= bt_field_type_string_set_encoding(root_relative_equal_elem
, BT_STRING_ENCODING_UTF8
);
1436 root_relative_equal
= bt_field_type_sequence_create(root_relative_equal_elem
, "splendid");
1437 assert(root_relative_equal
);
1438 ret
= bt_field_type_structure_add_field(root_relative
, root_relative_equal
, "equal");
1440 root_relative_amuck_elem
= bt_field_type_string_create();
1441 assert(root_relative_amuck_elem
);
1442 ret
= bt_field_type_string_set_encoding(root_relative_amuck_elem
, BT_STRING_ENCODING_UTF8
);
1444 root_relative_amuck
= bt_field_type_sequence_create(root_relative_amuck_elem
, "id");
1445 assert(root_relative_amuck
);
1446 ret
= bt_field_type_structure_add_field(root_relative
, root_relative_amuck
, "amuck");
1448 root_relative_push_elem
= bt_field_type_string_create();
1449 assert(root_relative_push_elem
);
1450 ret
= bt_field_type_string_set_encoding(root_relative_push_elem
, BT_STRING_ENCODING_UTF8
);
1452 root_relative_push
= bt_field_type_sequence_create(root_relative_push_elem
, "berry.third");
1453 assert(root_relative_push
);
1454 ret
= bt_field_type_structure_add_field(root_relative
, root_relative_push
, "push");
1456 root_relative_brick_elem
= bt_field_type_string_create();
1457 assert(root_relative_brick_elem
);
1458 ret
= bt_field_type_string_set_encoding(root_relative_brick_elem
, BT_STRING_ENCODING_UTF8
);
1460 root_relative_brick
= bt_field_type_sequence_create(root_relative_brick_elem
, "face.magic");
1461 assert(root_relative_brick
);
1462 ret
= bt_field_type_structure_add_field(root_relative
, root_relative_brick
, "brick");
1464 root_relative_crush_elem
= bt_field_type_string_create();
1465 assert(root_relative_crush_elem
);
1466 ret
= bt_field_type_string_set_encoding(root_relative_crush_elem
, BT_STRING_ENCODING_UTF8
);
1468 root_relative_crush
= bt_field_type_sequence_create(root_relative_crush_elem
, "serious");
1469 assert(root_relative_crush
);
1470 ret
= bt_field_type_structure_add_field(root_relative
, root_relative_crush
, "crush");
1472 root_relative_canvas_elem
= bt_field_type_string_create();
1473 assert(root_relative_canvas_elem
);
1474 ret
= bt_field_type_string_set_encoding(root_relative_canvas_elem
, BT_STRING_ENCODING_UTF8
);
1476 root_relative_canvas
= bt_field_type_sequence_create(root_relative_canvas_elem
, "iron.dust");
1477 assert(root_relative_canvas
);
1478 ret
= bt_field_type_structure_add_field(root_relative
, root_relative_canvas
, "canvas");
1480 ret
= bt_field_type_structure_add_field(root
, root_relative
, "relative");
1482 root_absolute
= bt_field_type_structure_create();
1483 assert(root_absolute
);
1484 ret
= bt_field_type_set_alignment(root_absolute
, 8);
1486 root_absolute_equal_elem
= bt_field_type_string_create();
1487 assert(root_absolute_equal_elem
);
1488 ret
= bt_field_type_string_set_encoding(root_absolute_equal_elem
, BT_STRING_ENCODING_UTF8
);
1490 root_absolute_equal
= bt_field_type_sequence_create(root_absolute_equal_elem
, "event.fields.splendid");
1491 assert(root_absolute_equal
);
1492 ret
= bt_field_type_structure_add_field(root_absolute
, root_absolute_equal
, "equal");
1494 root_absolute_amuck_elem
= bt_field_type_string_create();
1495 assert(root_absolute_amuck_elem
);
1496 ret
= bt_field_type_string_set_encoding(root_absolute_amuck_elem
, BT_STRING_ENCODING_UTF8
);
1498 root_absolute_amuck
= bt_field_type_sequence_create(root_absolute_amuck_elem
, "stream.event.header.id");
1499 assert(root_absolute_amuck
);
1500 ret
= bt_field_type_structure_add_field(root_absolute
, root_absolute_amuck
, "amuck");
1502 root_absolute_push_elem
= bt_field_type_string_create();
1503 assert(root_absolute_push_elem
);
1504 ret
= bt_field_type_string_set_encoding(root_absolute_push_elem
, BT_STRING_ENCODING_UTF8
);
1506 root_absolute_push
= bt_field_type_sequence_create(root_absolute_push_elem
, "event.context.berry.third");
1507 assert(root_absolute_push
);
1508 ret
= bt_field_type_structure_add_field(root_absolute
, root_absolute_push
, "push");
1510 root_absolute_brick_elem
= bt_field_type_string_create();
1511 assert(root_absolute_brick_elem
);
1512 ret
= bt_field_type_string_set_encoding(root_absolute_brick_elem
, BT_STRING_ENCODING_UTF8
);
1514 root_absolute_brick
= bt_field_type_sequence_create(root_absolute_brick_elem
, "stream.event.context.face.magic");
1515 assert(root_absolute_brick
);
1516 ret
= bt_field_type_structure_add_field(root_absolute
, root_absolute_brick
, "brick");
1518 root_absolute_crush_elem
= bt_field_type_string_create();
1519 assert(root_absolute_crush_elem
);
1520 ret
= bt_field_type_string_set_encoding(root_absolute_crush_elem
, BT_STRING_ENCODING_UTF8
);
1522 root_absolute_crush
= bt_field_type_sequence_create(root_absolute_crush_elem
, "stream.packet.context.serious");
1523 assert(root_absolute_crush
);
1524 ret
= bt_field_type_structure_add_field(root_absolute
, root_absolute_crush
, "crush");
1526 root_absolute_canvas_elem
= bt_field_type_string_create();
1527 assert(root_absolute_canvas_elem
);
1528 ret
= bt_field_type_string_set_encoding(root_absolute_canvas_elem
, BT_STRING_ENCODING_UTF8
);
1530 root_absolute_canvas
= bt_field_type_sequence_create(root_absolute_canvas_elem
, "trace.packet.header.iron.dust");
1531 assert(root_absolute_canvas
);
1532 ret
= bt_field_type_structure_add_field(root_absolute
, root_absolute_canvas
, "canvas");
1534 ret
= bt_field_type_structure_add_field(root
, root_absolute
, "absolute");
1537 BT_PUT(root_splendid
);
1538 BT_PUT(root_relative
);
1539 BT_PUT(root_relative_equal
);
1540 BT_PUT(root_relative_equal_elem
);
1541 BT_PUT(root_relative_amuck
);
1542 BT_PUT(root_relative_amuck_elem
);
1543 BT_PUT(root_relative_push
);
1544 BT_PUT(root_relative_push_elem
);
1545 BT_PUT(root_relative_brick
);
1546 BT_PUT(root_relative_brick_elem
);
1547 BT_PUT(root_relative_crush
);
1548 BT_PUT(root_relative_crush_elem
);
1549 BT_PUT(root_relative_canvas
);
1550 BT_PUT(root_relative_canvas_elem
);
1551 BT_PUT(root_absolute
);
1552 BT_PUT(root_absolute_equal
);
1553 BT_PUT(root_absolute_equal_elem
);
1554 BT_PUT(root_absolute_amuck
);
1555 BT_PUT(root_absolute_amuck_elem
);
1556 BT_PUT(root_absolute_push
);
1557 BT_PUT(root_absolute_push_elem
);
1558 BT_PUT(root_absolute_brick
);
1559 BT_PUT(root_absolute_brick_elem
);
1560 BT_PUT(root_absolute_crush
);
1561 BT_PUT(root_absolute_crush_elem
);
1562 BT_PUT(root_absolute_canvas
);
1563 BT_PUT(root_absolute_canvas_elem
);
1569 struct bt_field_type
*get_child_ft(struct bt_field_type
*parent_ft
,
1572 struct bt_field_type
*ft
= NULL
;
1574 switch (bt_field_type_get_type_id(parent_ft
)) {
1575 case BT_FIELD_TYPE_ID_STRUCT
:
1576 ft
= bt_field_type_structure_get_field_type_by_name(
1580 case BT_FIELD_TYPE_ID_VARIANT
:
1581 ft
= bt_field_type_variant_get_field_type_by_name(
1585 case BT_FIELD_TYPE_ID_ARRAY
:
1586 ft
= bt_field_type_array_get_element_field_type(parent_ft
);
1589 case BT_FIELD_TYPE_ID_SEQUENCE
:
1590 ft
= bt_field_type_sequence_get_element_field_type(parent_ft
);
1593 case BT_FIELD_TYPE_ID_ENUM
:
1594 ft
= bt_field_type_enumeration_get_container_field_type(
1608 struct bt_field_type
*get_ft(struct bt_field_type
*root_ft
, ...)
1610 struct bt_field_type
*child_ft
= NULL
;
1611 struct bt_field_type
*ft
= root_ft
;
1614 va_start(ap
, root_ft
);
1618 const char *field_name
= va_arg(ap
, const char *);
1620 if (field_name
== NULL
) {
1624 child_ft
= get_child_ft(ft
, field_name
);
1631 BT_MOVE(ft
, child_ft
);
1640 #define FIELD_PATH_END -2
1643 int validate_field_path(struct bt_field_type
*field_type
, int int_root
, ...)
1645 enum bt_scope root
= int_root
;
1651 struct bt_field_path
*field_path
= NULL
;
1654 va_start(ap
, int_root
);
1655 if (bt_field_type_is_sequence(field_type
)) {
1656 field_path
= bt_field_type_sequence_get_length_field_path(
1658 } else if (bt_field_type_is_variant(field_type
)) {
1659 field_path
= bt_field_type_variant_get_tag_field_path(
1668 if (bt_field_path_get_root_scope(field_path
) != root
) {
1673 len
= bt_field_path_get_index_count(field_path
);
1676 expected_index
= va_arg(ap
, int);
1678 if (expected_index
== FIELD_PATH_END
) {
1686 actual_index
= bt_field_path_get_index(field_path
, i
);
1688 if (actual_index
== INT_MIN
) {
1696 if (i
!= len
|| expected_index
!= FIELD_PATH_END
) {
1708 void validate_test_pass(struct bt_trace
*trace
)
1710 struct bt_stream_class
*sc
;
1711 struct bt_event_class
*ec
;
1712 struct bt_field_type
*ph
;
1713 struct bt_field_type
*pc
;
1714 struct bt_field_type
*eh
;
1715 struct bt_field_type
*sec
;
1716 struct bt_field_type
*ectx
;
1717 struct bt_field_type
*ep
;
1718 struct bt_field_type
*ft_src
= NULL
;
1719 struct bt_field_type
*ft_target
= NULL
;
1720 struct bt_field_type
*ft_tag
= NULL
;
1722 sc
= bt_trace_get_stream_class_by_index(trace
, 0);
1724 ec
= bt_stream_class_get_event_class_by_index(sc
, 0);
1727 ph
= bt_trace_get_packet_header_field_type(trace
);
1728 ok(ph
, "Trace packet header still exists after successful validation");
1729 pc
= bt_stream_class_get_packet_context_field_type(sc
);
1730 ok(pc
, "Stream packet context still exists after successful validation");
1731 eh
= bt_stream_class_get_event_header_field_type(sc
);
1732 ok(eh
, "Stream event header still exists after successful validation");
1733 sec
= bt_stream_class_get_event_context_field_type(sc
);
1734 ok(sec
, "Stream event context still exists after successful validation");
1735 ectx
= bt_event_class_get_context_field_type(ec
);
1736 ok(ectx
, "Event context still exists after successful validation");
1737 ep
= bt_event_class_get_payload_field_type(ec
);
1738 ok(ep
, "Event payload still exists after successful validation");
1740 /* trace.packet.header.iron.fire.keen */
1741 ft_src
= get_ft(ph
, "iron", "fire", "keen", NULL
);
1742 ok(!validate_field_path(ft_src
, BT_SCOPE_TRACE_PACKET_HEADER
,
1743 3, 3, 0, FIELD_PATH_END
),
1744 "trace.packet.header.iron.fire.keen has the correct field path");
1747 /* trace.packet.header.iron.fire.keen.[element] */
1748 ft_src
= get_ft(ph
, "iron", "fire", "keen", "", NULL
);
1749 ok(!validate_field_path(ft_src
,
1750 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 2, FIELD_PATH_END
),
1751 "trace.packet.header.iron.fire.keen.[element] has the correct field path");
1752 ft_target
= get_ft(ph
, "iron", "parallel", NULL
);
1753 ft_tag
= bt_field_type_variant_get_tag_field_type(ft_src
);
1754 ok(ft_tag
== ft_target
,
1755 "trace.packet.header.iron.fire.keen.[element] has the correct tag type");
1760 /* trace.packet.header.iron.fire.keen.[element].BLUE */
1761 ft_src
= get_ft(ph
, "iron", "fire", "keen", "", "BLUE", NULL
);
1762 ok(!validate_field_path(ft_src
,
1763 BT_SCOPE_TRACE_PACKET_HEADER
, 0, FIELD_PATH_END
),
1764 "trace.packet.header.iron.fire.keen.[element].BLUE has the correct field path");
1767 /* trace.packet.header.iron.report */
1768 ft_src
= get_ft(ph
, "iron", "report", NULL
);
1769 ok(!validate_field_path(ft_src
,
1770 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
1771 "trace.packet.header.iron.report has the correct field path");
1774 /* trace.packet.header.iron.group */
1775 ft_src
= get_ft(ph
, "iron", "group", NULL
);
1776 ok(!validate_field_path(ft_src
,
1777 BT_SCOPE_TRACE_PACKET_HEADER
, 2, FIELD_PATH_END
),
1778 "trace.packet.header.iron.group has the correct field path");
1781 /* stream.packet.context.naive.[element] */
1782 ft_src
= get_ft(pc
, "naive", "", NULL
);
1783 ok(!validate_field_path(ft_src
,
1784 BT_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1785 "stream.packet.context.naive.[element] has the correct field path");
1788 /* stream.packet.context.clover.whole */
1789 ft_src
= get_ft(pc
, "clover", "whole", NULL
);
1790 ok(!validate_field_path(ft_src
,
1791 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 2, FIELD_PATH_END
),
1792 "stream.packet.context.clover.whole has the correct field path");
1793 ft_target
= get_ft(ph
, "iron", "parallel", NULL
);
1794 ft_tag
= bt_field_type_variant_get_tag_field_type(ft_src
);
1795 ok(ft_tag
== ft_target
,
1796 "stream.packet.context.clover.whole has the correct tag type");
1801 /* stream.packet.context.clover.whole.BLUE */
1802 ft_src
= get_ft(pc
, "clover", "whole", "BLUE", NULL
);
1803 ok(!validate_field_path(ft_src
,
1804 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1805 "stream.packet.context.clover.whole.BLUE has the correct field path");
1808 /* stream.packet.context.clover.egg */
1809 ft_src
= get_ft(pc
, "clover", "egg", NULL
);
1810 ok(!validate_field_path(ft_src
,
1811 BT_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1812 "stream.packet.context.clover.egg has the correct field path");
1815 /* stream.packet.context.clover.useful */
1816 ft_src
= get_ft(pc
, "clover", "useful", NULL
);
1817 ok(!validate_field_path(ft_src
,
1818 BT_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1819 "stream.packet.context.clover.useful has the correct field path");
1822 /* stream.event.header.action.lucky */
1823 ft_src
= get_ft(eh
, "action", "lucky", NULL
);
1824 ok(!validate_field_path(ft_src
,
1825 BT_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1826 "stream.event.header.action.lucky has the correct field path");
1829 /* stream.event.header.stiff */
1830 ft_src
= get_ft(eh
, "stiff", NULL
);
1831 ok(!validate_field_path(ft_src
,
1832 BT_SCOPE_STREAM_PACKET_CONTEXT
, 4, 1, 1, FIELD_PATH_END
),
1833 "stream.event.header.stiff has the correct field path");
1836 /* stream.event.header.fruit.apple */
1837 ft_src
= get_ft(eh
, "fruit", "apple", NULL
);
1838 ok(!validate_field_path(ft_src
,
1839 BT_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1840 "stream.event.header.fruit.apple has the correct field path");
1843 /* stream.event.context.face.branch */
1844 ft_src
= get_ft(sec
, "face", "branch", NULL
);
1845 ok(!validate_field_path(ft_src
,
1846 BT_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1847 "stream.event.context.face.branch has the correct field path");
1850 /* stream.event.context.face.income */
1851 ft_src
= get_ft(sec
, "face", "income", NULL
);
1852 ok(!validate_field_path(ft_src
,
1853 BT_SCOPE_TRACE_PACKET_HEADER
, 0, FIELD_PATH_END
),
1854 "stream.event.context.face.income has the correct field path");
1857 /* stream.event.context.face.lucky */
1858 ft_src
= get_ft(sec
, "face", "lucky", NULL
);
1859 ok(!validate_field_path(ft_src
,
1860 BT_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1861 "stream.event.context.face.lucky has the correct field path");
1864 /* stream.event.context.dream */
1865 ft_src
= get_ft(sec
, "dream", NULL
);
1866 ok(!validate_field_path(ft_src
,
1867 BT_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1868 "stream.event.context.dream has the correct field path");
1871 /* stream.event.context.dream.[element] */
1872 ft_src
= get_ft(sec
, "dream", "", NULL
);
1873 ok(!validate_field_path(ft_src
,
1874 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
1875 "stream.event.context.dream.[element] has the correct field path");
1878 /* stream.event.context.dream.[element].[element] */
1879 ft_src
= get_ft(sec
, "dream", "", "", NULL
);
1880 ok(!validate_field_path(ft_src
,
1881 BT_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1882 "stream.event.context.dream.[element].[element] has the correct field path");
1885 /* event.context.berry.porter */
1886 ft_src
= get_ft(ectx
, "berry", "porter", NULL
);
1887 ok(!validate_field_path(ft_src
,
1888 BT_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1889 "event.context.berry.porter has the correct field path");
1892 /* event.context.berry.porter */
1893 ft_src
= get_ft(ectx
, "berry", "porter", NULL
);
1894 ok(!validate_field_path(ft_src
,
1895 BT_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1896 "event.context.berry.porter has the correct field path");
1899 /* event.context.berry.mice */
1900 ft_src
= get_ft(ectx
, "berry", "mice", NULL
);
1901 ok(!validate_field_path(ft_src
,
1902 BT_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1903 "event.context.berry.mice has the correct field path");
1906 /* event.context.berry.guard */
1907 ft_src
= get_ft(ectx
, "berry", "guard", NULL
);
1908 ok(!validate_field_path(ft_src
,
1909 BT_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1910 "event.context.berry.guard has the correct field path");
1913 /* event.context.berry.one */
1914 ft_src
= get_ft(ectx
, "berry", "one", NULL
);
1915 ok(!validate_field_path(ft_src
,
1916 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1917 "event.context.berry.one has the correct field path");
1920 /* event.context.loud.toys */
1921 ft_src
= get_ft(ectx
, "loud", "toys", NULL
);
1922 ok(!validate_field_path(ft_src
,
1923 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1924 "event.context.loud.toys has the correct field path");
1927 /* event.context.loud.spoon */
1928 ft_src
= get_ft(ectx
, "loud", "spoon", NULL
);
1929 ok(!validate_field_path(ft_src
,
1930 BT_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1931 "event.context.loud.spoon has the correct field path");
1934 /* event.context.loud.turkey */
1935 ft_src
= get_ft(ectx
, "loud", "turkey", NULL
);
1936 ok(!validate_field_path(ft_src
,
1937 BT_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1938 "event.context.loud.turkey has the correct field path");
1941 /* event.context.loud.inform */
1942 ft_src
= get_ft(ectx
, "loud", "inform", NULL
);
1943 ok(!validate_field_path(ft_src
,
1944 BT_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1945 "event.context.loud.inform has the correct field path");
1948 /* event.context.loud.odd */
1949 ft_src
= get_ft(ectx
, "loud", "odd", NULL
);
1950 ok(!validate_field_path(ft_src
,
1951 BT_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
1952 "event.context.loud.odd has the correct field path");
1955 /* event.context.loud.amuck */
1956 ft_src
= get_ft(ectx
, "loud", "amuck", NULL
);
1957 ok(!validate_field_path(ft_src
,
1958 BT_SCOPE_EVENT_CONTEXT
, 0, FIELD_PATH_END
),
1959 "event.context.loud.amuck has the correct field path");
1962 /* event.fields.relative.equal */
1963 ft_src
= get_ft(ep
, "relative", "equal", NULL
);
1964 ok(!validate_field_path(ft_src
,
1965 BT_SCOPE_EVENT_FIELDS
, 0, FIELD_PATH_END
),
1966 "event.fields.relative.equal has the correct field path");
1969 /* event.fields.relative.amuck */
1970 ft_src
= get_ft(ep
, "relative", "amuck", NULL
);
1971 ok(!validate_field_path(ft_src
,
1972 BT_SCOPE_STREAM_EVENT_HEADER
, 0, FIELD_PATH_END
),
1973 "event.fields.relative.amuck has the correct field path");
1976 /* event.fields.relative.push */
1977 ft_src
= get_ft(ep
, "relative", "push", NULL
);
1978 ok(!validate_field_path(ft_src
,
1979 BT_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
1980 "event.fields.relative.push has the correct field path");
1983 /* event.fields.relative.brick */
1984 ft_src
= get_ft(ep
, "relative", "brick", NULL
);
1985 ok(!validate_field_path(ft_src
,
1986 BT_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1987 "event.fields.relative.brick has the correct field path");
1990 /* event.fields.relative.crush */
1991 ft_src
= get_ft(ep
, "relative", "crush", NULL
);
1992 ok(!validate_field_path(ft_src
,
1993 BT_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1994 "event.fields.relative.crush has the correct field path");
1997 /* event.fields.relative.canvas */
1998 ft_src
= get_ft(ep
, "relative", "canvas", NULL
);
1999 ok(!validate_field_path(ft_src
,
2000 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
2001 "event.fields.relative.canvas has the correct field path");
2004 /* event.fields.absolute.equal */
2005 ft_src
= get_ft(ep
, "absolute", "equal", NULL
);
2006 ok(!validate_field_path(ft_src
,
2007 BT_SCOPE_EVENT_FIELDS
, 0, FIELD_PATH_END
),
2008 "event.fields.absolute.equal has the correct field path");
2011 /* event.fields.absolute.amuck */
2012 ft_src
= get_ft(ep
, "absolute", "amuck", NULL
);
2013 ok(!validate_field_path(ft_src
,
2014 BT_SCOPE_STREAM_EVENT_HEADER
, 0, FIELD_PATH_END
),
2015 "event.fields.absolute.amuck has the correct field path");
2018 /* event.fields.absolute.push */
2019 ft_src
= get_ft(ep
, "absolute", "push", NULL
);
2020 ok(!validate_field_path(ft_src
,
2021 BT_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
2022 "event.fields.absolute.push has the correct field path");
2025 /* event.fields.absolute.brick */
2026 ft_src
= get_ft(ep
, "absolute", "brick", NULL
);
2027 ok(!validate_field_path(ft_src
,
2028 BT_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
2029 "event.fields.absolute.brick has the correct field path");
2032 /* event.fields.absolute.crush */
2033 ft_src
= get_ft(ep
, "absolute", "crush", NULL
);
2034 ok(!validate_field_path(ft_src
,
2035 BT_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
2036 "event.fields.absolute.crush has the correct field path");
2039 /* event.fields.absolute.canvas */
2040 ft_src
= get_ft(ep
, "absolute", "canvas", NULL
);
2041 ok(!validate_field_path(ft_src
,
2042 BT_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
2043 "event.fields.absolute.canvas has the correct field path");
2059 void test_pass(void)
2062 struct bt_trace
*trace
;
2063 struct bt_stream_class
*sc
;
2064 struct bt_event_class
*ec
;
2065 struct bt_field_type
*ph
;
2066 struct bt_field_type
*pc
;
2067 struct bt_field_type
*eh
;
2068 struct bt_field_type
*sec
;
2069 struct bt_field_type
*ectx
;
2070 struct bt_field_type
*ep
;
2072 trace
= bt_trace_create();
2074 sc
= bt_stream_class_create("nice_piece_of_stream_class");
2076 ec
= bt_event_class_create("oh_what_an_event_class");
2079 ph
= get_good_packet_header_field_type();
2081 pc
= get_good_packet_context_field_type();
2083 eh
= get_good_event_header_field_type();
2085 sec
= get_good_stream_event_context_field_type();
2087 ectx
= get_good_event_context_field_type();
2089 ep
= get_good_event_payload_field_type();
2092 ret
= bt_trace_set_packet_header_field_type(trace
, ph
);
2094 ret
= bt_stream_class_set_packet_context_field_type(sc
, pc
);
2096 ret
= bt_stream_class_set_event_header_field_type(sc
, eh
);
2098 ret
= bt_stream_class_set_event_context_field_type(sc
, sec
);
2100 ret
= bt_event_class_set_context_field_type(ec
, ectx
);
2102 ret
= bt_event_class_set_payload_field_type(ec
, ep
);
2105 ret
= bt_stream_class_add_event_class(sc
, ec
);
2108 /* Validation happens here */
2109 ret
= bt_trace_add_stream_class(trace
, sc
);
2110 ok(ret
== 0, "Valid type system is considered valid");
2112 validate_test_pass(trace
);
2126 int try_add_event_class_to_trace(struct bt_field_type
*ectx
,
2127 struct bt_field_type
*ep
)
2130 struct bt_trace
*trace
;
2131 struct bt_stream_class
*sc
;
2132 struct bt_event_class
*ec
;
2134 trace
= bt_trace_create();
2136 sc
= bt_stream_class_create("sc");
2138 ec
= bt_event_class_create("ec");
2142 ret
= bt_event_class_set_context_field_type(ec
, ectx
);
2147 ret
= bt_event_class_set_payload_field_type(ec
, ep
);
2151 ret
= bt_stream_class_add_event_class(sc
, ec
);
2153 ret
= bt_trace_add_stream_class(trace
, sc
);
2161 struct bt_field_type
*test_fail_unavailable_root_get_event_payload(void)
2164 Generated by bt-ctfirtg using the following input:
2173 length: stream.event.context.lol
2181 struct bt_field_type
*root
= NULL
;
2182 struct bt_field_type
*root_a
= NULL
;
2183 struct bt_field_type
*root_b
= NULL
;
2184 struct bt_field_type
*root_b_elem
= NULL
;
2185 struct bt_field_type
*root_c
= NULL
;
2188 root
= bt_field_type_structure_create();
2190 ret
= bt_field_type_set_alignment(root
, 8);
2192 root_a
= bt_field_type_integer_create(32);
2194 ret
= bt_field_type_integer_set_is_signed(root_a
, 0);
2196 ret
= bt_field_type_integer_set_base(root_a
, 10);
2198 ret
= bt_field_type_integer_set_encoding(root_a
, BT_STRING_ENCODING_NONE
);
2200 ret
= bt_field_type_set_byte_order(root_a
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2202 ret
= bt_field_type_set_alignment(root_a
, 8);
2204 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2206 root_b_elem
= bt_field_type_string_create();
2207 assert(root_b_elem
);
2208 ret
= bt_field_type_string_set_encoding(root_b_elem
, BT_STRING_ENCODING_UTF8
);
2210 root_b
= bt_field_type_sequence_create(root_b_elem
, "stream.event.context.lol");
2212 ret
= bt_field_type_structure_add_field(root
, root_b
, "b");
2214 root_c
= bt_field_type_string_create();
2216 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2218 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2223 BT_PUT(root_b_elem
);
2230 void test_fail_unavailable_root(void)
2232 struct bt_field_type
*ep
;
2234 ep
= test_fail_unavailable_root_get_event_payload();
2236 ok(try_add_event_class_to_trace(NULL
, ep
),
2237 "Sequence FT with length in unavailable root is invalid");
2243 struct bt_field_type
*test_fail_target_is_root_get_event_payload(void)
2246 Generated by bt-ctfirtg using the following input:
2255 length: event.fields
2263 struct bt_field_type
*root
= NULL
;
2264 struct bt_field_type
*root_a
= NULL
;
2265 struct bt_field_type
*root_b
= NULL
;
2266 struct bt_field_type
*root_b_elem
= NULL
;
2267 struct bt_field_type
*root_c
= NULL
;
2270 root
= bt_field_type_structure_create();
2272 ret
= bt_field_type_set_alignment(root
, 8);
2274 root_a
= bt_field_type_integer_create(32);
2276 ret
= bt_field_type_integer_set_is_signed(root_a
, 0);
2278 ret
= bt_field_type_integer_set_base(root_a
, 10);
2280 ret
= bt_field_type_integer_set_encoding(root_a
, BT_STRING_ENCODING_NONE
);
2282 ret
= bt_field_type_set_byte_order(root_a
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2284 ret
= bt_field_type_set_alignment(root_a
, 8);
2286 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2288 root_b_elem
= bt_field_type_string_create();
2289 assert(root_b_elem
);
2290 ret
= bt_field_type_string_set_encoding(root_b_elem
, BT_STRING_ENCODING_UTF8
);
2292 root_b
= bt_field_type_sequence_create(root_b_elem
, "event.fields");
2294 ret
= bt_field_type_structure_add_field(root
, root_b
, "b");
2296 root_c
= bt_field_type_string_create();
2298 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2300 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2305 BT_PUT(root_b_elem
);
2312 void test_fail_target_is_root(void)
2314 struct bt_field_type
*ep
;
2316 ep
= test_fail_target_is_root_get_event_payload();
2318 ok(try_add_event_class_to_trace(NULL
, ep
),
2319 "Sequence FT with root as its length is invalid");
2324 struct bt_field_type
*test_fail_target_is_after_source_get_ep(void)
2327 Generated by bt-ctfirtg using the following input:
2347 struct bt_field_type
*root
= NULL
;
2348 struct bt_field_type
*root_a
= NULL
;
2349 struct bt_field_type
*root_b
= NULL
;
2350 struct bt_field_type
*root_b_elem
= NULL
;
2351 struct bt_field_type
*root_c
= NULL
;
2352 struct bt_field_type
*root_d
= NULL
;
2355 root
= bt_field_type_structure_create();
2357 ret
= bt_field_type_set_alignment(root
, 8);
2359 root_a
= bt_field_type_integer_create(32);
2361 ret
= bt_field_type_integer_set_is_signed(root_a
, 0);
2363 ret
= bt_field_type_integer_set_base(root_a
, 10);
2365 ret
= bt_field_type_integer_set_encoding(root_a
, BT_STRING_ENCODING_NONE
);
2367 ret
= bt_field_type_set_byte_order(root_a
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2369 ret
= bt_field_type_set_alignment(root_a
, 8);
2371 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2373 root_b_elem
= bt_field_type_string_create();
2374 assert(root_b_elem
);
2375 ret
= bt_field_type_string_set_encoding(root_b_elem
, BT_STRING_ENCODING_UTF8
);
2377 root_b
= bt_field_type_sequence_create(root_b_elem
, "d");
2379 ret
= bt_field_type_structure_add_field(root
, root_b
, "b");
2381 root_c
= bt_field_type_string_create();
2383 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2385 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2387 root_d
= bt_field_type_integer_create(17);
2389 ret
= bt_field_type_integer_set_is_signed(root_d
, 0);
2391 ret
= bt_field_type_integer_set_base(root_d
, 10);
2393 ret
= bt_field_type_integer_set_encoding(root_d
, BT_STRING_ENCODING_NONE
);
2395 ret
= bt_field_type_set_byte_order(root_d
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2397 ret
= bt_field_type_set_alignment(root_d
, 1);
2399 ret
= bt_field_type_structure_add_field(root
, root_d
, "d");
2404 BT_PUT(root_b_elem
);
2412 void test_fail_target_is_after_source(void)
2414 struct bt_field_type
*ep
;
2416 ep
= test_fail_target_is_after_source_get_ep();
2418 ok(try_add_event_class_to_trace(NULL
, ep
),
2419 "Sequence FT with length after it is invalid");
2424 struct bt_field_type
*test_fail_target_is_ancestor_of_source_get_ep(void)
2427 Generated by bt-ctfirtg using the following input:
2450 struct bt_field_type
*root
= NULL
;
2451 struct bt_field_type
*root_a
= NULL
;
2452 struct bt_field_type
*root_z
= NULL
;
2453 struct bt_field_type
*root_z_b
= NULL
;
2454 struct bt_field_type
*root_z_b_elem
= NULL
;
2455 struct bt_field_type
*root_c
= NULL
;
2456 struct bt_field_type
*root_d
= NULL
;
2459 root
= bt_field_type_structure_create();
2461 ret
= bt_field_type_set_alignment(root
, 8);
2463 root_a
= bt_field_type_integer_create(32);
2465 ret
= bt_field_type_integer_set_is_signed(root_a
, 0);
2467 ret
= bt_field_type_integer_set_base(root_a
, 10);
2469 ret
= bt_field_type_integer_set_encoding(root_a
, BT_STRING_ENCODING_NONE
);
2471 ret
= bt_field_type_set_byte_order(root_a
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2473 ret
= bt_field_type_set_alignment(root_a
, 8);
2475 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2477 root_z
= bt_field_type_structure_create();
2479 ret
= bt_field_type_set_alignment(root_z
, 8);
2481 root_z_b_elem
= bt_field_type_string_create();
2482 assert(root_z_b_elem
);
2483 ret
= bt_field_type_string_set_encoding(root_z_b_elem
, BT_STRING_ENCODING_UTF8
);
2485 root_z_b
= bt_field_type_sequence_create(root_z_b_elem
, "z");
2487 ret
= bt_field_type_structure_add_field(root_z
, root_z_b
, "b");
2489 ret
= bt_field_type_structure_add_field(root
, root_z
, "z");
2491 root_c
= bt_field_type_string_create();
2493 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2495 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2497 root_d
= bt_field_type_integer_create(17);
2499 ret
= bt_field_type_integer_set_is_signed(root_d
, 0);
2501 ret
= bt_field_type_integer_set_base(root_d
, 10);
2503 ret
= bt_field_type_integer_set_encoding(root_d
, BT_STRING_ENCODING_NONE
);
2505 ret
= bt_field_type_set_byte_order(root_d
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2507 ret
= bt_field_type_set_alignment(root_d
, 1);
2509 ret
= bt_field_type_structure_add_field(root
, root_d
, "d");
2515 BT_PUT(root_z_b_elem
);
2523 void test_fail_target_is_ancestor_of_source(void)
2525 struct bt_field_type
*ep
;
2527 ep
= test_fail_target_is_ancestor_of_source_get_ep();
2529 ok(try_add_event_class_to_trace(NULL
, ep
),
2530 "Sequence FT with ancestor as its length is invalid");
2535 struct bt_field_type
*test_fail_target_is_source_get_event_payload(void)
2538 Generated by bt-ctfirtg using the following input:
2547 length: event.fields.b
2558 struct bt_field_type
*root
= NULL
;
2559 struct bt_field_type
*root_a
= NULL
;
2560 struct bt_field_type
*root_b
= NULL
;
2561 struct bt_field_type
*root_b_elem
= NULL
;
2562 struct bt_field_type
*root_c
= NULL
;
2563 struct bt_field_type
*root_d
= NULL
;
2566 root
= bt_field_type_structure_create();
2568 ret
= bt_field_type_set_alignment(root
, 8);
2570 root_a
= bt_field_type_integer_create(32);
2572 ret
= bt_field_type_integer_set_is_signed(root_a
, 0);
2574 ret
= bt_field_type_integer_set_base(root_a
, 10);
2576 ret
= bt_field_type_integer_set_encoding(root_a
, BT_STRING_ENCODING_NONE
);
2578 ret
= bt_field_type_set_byte_order(root_a
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2580 ret
= bt_field_type_set_alignment(root_a
, 8);
2582 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2584 root_b_elem
= bt_field_type_string_create();
2585 assert(root_b_elem
);
2586 ret
= bt_field_type_string_set_encoding(root_b_elem
, BT_STRING_ENCODING_UTF8
);
2588 root_b
= bt_field_type_sequence_create(root_b_elem
, "event.fields.b");
2590 ret
= bt_field_type_structure_add_field(root
, root_b
, "b");
2592 root_c
= bt_field_type_string_create();
2594 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2596 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2598 root_d
= bt_field_type_integer_create(17);
2600 ret
= bt_field_type_integer_set_is_signed(root_d
, 0);
2602 ret
= bt_field_type_integer_set_base(root_d
, 10);
2604 ret
= bt_field_type_integer_set_encoding(root_d
, BT_STRING_ENCODING_NONE
);
2606 ret
= bt_field_type_set_byte_order(root_d
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2608 ret
= bt_field_type_set_alignment(root_d
, 1);
2610 ret
= bt_field_type_structure_add_field(root
, root_d
, "d");
2615 BT_PUT(root_b_elem
);
2623 void test_fail_target_is_source(void)
2625 struct bt_field_type
*ep
;
2627 ep
= test_fail_target_is_source_get_event_payload();
2629 ok(try_add_event_class_to_trace(NULL
, ep
),
2630 "Sequence FT with itself as its length is invalid");
2635 struct bt_field_type
*test_fail_variant_tag_is_not_enum_get_ep(void)
2638 Generated by bt-ctfirtg using the following input:
2659 struct bt_field_type
*root
= NULL
;
2660 struct bt_field_type
*root_a
= NULL
;
2661 struct bt_field_type
*root_b
= NULL
;
2662 struct bt_field_type
*root_b_HELLO
= NULL
;
2663 struct bt_field_type
*root_c
= NULL
;
2664 struct bt_field_type
*root_d
= NULL
;
2667 root
= bt_field_type_structure_create();
2669 ret
= bt_field_type_set_alignment(root
, 8);
2671 root_a
= bt_field_type_integer_create(32);
2673 ret
= bt_field_type_integer_set_is_signed(root_a
, 0);
2675 ret
= bt_field_type_integer_set_base(root_a
, 10);
2677 ret
= bt_field_type_integer_set_encoding(root_a
, BT_STRING_ENCODING_NONE
);
2679 ret
= bt_field_type_set_byte_order(root_a
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2681 ret
= bt_field_type_set_alignment(root_a
, 8);
2683 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2685 root_b
= bt_field_type_variant_create(NULL
, "a");
2687 root_b_HELLO
= bt_field_type_string_create();
2688 assert(root_b_HELLO
);
2689 ret
= bt_field_type_string_set_encoding(root_b_HELLO
, BT_STRING_ENCODING_UTF8
);
2691 ret
= bt_field_type_variant_add_field(root_b
, root_b_HELLO
, "HELLO");
2693 ret
= bt_field_type_structure_add_field(root
, root_b
, "b");
2695 root_c
= bt_field_type_string_create();
2697 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2699 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2701 root_d
= bt_field_type_integer_create(17);
2703 ret
= bt_field_type_integer_set_is_signed(root_d
, 0);
2705 ret
= bt_field_type_integer_set_base(root_d
, 10);
2707 ret
= bt_field_type_integer_set_encoding(root_d
, BT_STRING_ENCODING_NONE
);
2709 ret
= bt_field_type_set_byte_order(root_d
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2711 ret
= bt_field_type_set_alignment(root_d
, 1);
2713 ret
= bt_field_type_structure_add_field(root
, root_d
, "d");
2718 BT_PUT(root_b_HELLO
);
2726 void test_fail_variant_tag_is_not_enum(void)
2728 struct bt_field_type
*ep
;
2730 ep
= test_fail_variant_tag_is_not_enum_get_ep();
2732 ok(try_add_event_class_to_trace(NULL
, ep
),
2733 "Variant FT with non-enum FT as its tag FT is invalid");
2738 struct bt_field_type
*test_fail_variant_tag_mismatch_mappings_get_ep(void)
2741 Generated by bt-ctfirtg using the following input:
2768 struct bt_field_type
*root
= NULL
;
2769 struct bt_field_type
*root_a
= NULL
;
2770 struct bt_field_type
*root_a_int
= NULL
;
2771 struct bt_field_type
*root_b
= NULL
;
2772 struct bt_field_type
*root_b_GLASS
= NULL
;
2773 struct bt_field_type
*root_b_OF
= NULL
;
2774 struct bt_field_type
*root_c
= NULL
;
2777 root
= bt_field_type_structure_create();
2779 ret
= bt_field_type_set_alignment(root
, 8);
2781 root_a_int
= bt_field_type_integer_create(16);
2783 ret
= bt_field_type_integer_set_is_signed(root_a_int
, 0);
2785 ret
= bt_field_type_integer_set_base(root_a_int
, 10);
2787 ret
= bt_field_type_integer_set_encoding(root_a_int
, BT_STRING_ENCODING_NONE
);
2789 ret
= bt_field_type_set_byte_order(root_a_int
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2791 ret
= bt_field_type_set_alignment(root_a_int
, 8);
2793 root_a
= bt_field_type_enumeration_create(root_a_int
);
2795 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_a
, "GLASS", 0, 0);
2797 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_a
, "OF", 1, 1);
2799 ret
= bt_field_type_enumeration_unsigned_add_mapping(root_a
, "WATER", 2, 2);
2801 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2803 root_b
= bt_field_type_variant_create(NULL
, "a");
2805 root_b_GLASS
= bt_field_type_string_create();
2806 assert(root_b_GLASS
);
2807 ret
= bt_field_type_string_set_encoding(root_b_GLASS
, BT_STRING_ENCODING_UTF8
);
2809 ret
= bt_field_type_variant_add_field(root_b
, root_b_GLASS
, "GLASS");
2811 root_b_OF
= bt_field_type_integer_create(2);
2813 ret
= bt_field_type_integer_set_is_signed(root_b_OF
, 0);
2815 ret
= bt_field_type_integer_set_base(root_b_OF
, 10);
2817 ret
= bt_field_type_integer_set_encoding(root_b_OF
, BT_STRING_ENCODING_NONE
);
2819 ret
= bt_field_type_set_byte_order(root_b_OF
, BT_BYTE_ORDER_LITTLE_ENDIAN
);
2821 ret
= bt_field_type_set_alignment(root_b_OF
, 1);
2823 ret
= bt_field_type_variant_add_field(root_b
, root_b_OF
, "OF");
2825 ret
= bt_field_type_structure_add_field(root
, root_b
, "b");
2827 root_c
= bt_field_type_string_create();
2829 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2831 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2837 BT_PUT(root_b_GLASS
);
2845 void test_fail_variant_tag_mismatch_mappings(void)
2847 struct bt_field_type
*ep
;
2849 ep
= test_fail_variant_tag_mismatch_mappings_get_ep();
2851 ok(try_add_event_class_to_trace(NULL
, ep
) == 0,
2852 "Variant FT with mismatching tag FT is valid");
2857 struct bt_field_type
*test_fail_sequence_tag_is_not_int_get_ep(void)
2860 Generated by bt-ctfirtg using the following input:
2876 struct bt_field_type
*root
= NULL
;
2877 struct bt_field_type
*root_a
= NULL
;
2878 struct bt_field_type
*root_b
= NULL
;
2879 struct bt_field_type
*root_b_elem
= NULL
;
2880 struct bt_field_type
*root_c
= NULL
;
2883 root
= bt_field_type_structure_create();
2885 ret
= bt_field_type_set_alignment(root
, 8);
2887 root_a
= bt_field_type_string_create();
2889 ret
= bt_field_type_string_set_encoding(root_a
, BT_STRING_ENCODING_UTF8
);
2891 ret
= bt_field_type_structure_add_field(root
, root_a
, "a");
2893 root_b_elem
= bt_field_type_string_create();
2894 assert(root_b_elem
);
2895 ret
= bt_field_type_string_set_encoding(root_b_elem
, BT_STRING_ENCODING_UTF8
);
2897 root_b
= bt_field_type_sequence_create(root_b_elem
, "a");
2899 ret
= bt_field_type_structure_add_field(root
, root_b
, "b");
2901 root_c
= bt_field_type_string_create();
2903 ret
= bt_field_type_string_set_encoding(root_c
, BT_STRING_ENCODING_UTF8
);
2905 ret
= bt_field_type_structure_add_field(root
, root_c
, "c");
2910 BT_PUT(root_b_elem
);
2917 void test_fail_sequence_tag_is_not_int(void)
2919 struct bt_field_type
*ep
;
2921 ep
= test_fail_sequence_tag_is_not_int_get_ep();
2923 ok(try_add_event_class_to_trace(NULL
, ep
),
2924 "Sequence FT with non-enum length FT is invalid");
2929 void test_fail(void)
2931 test_fail_unavailable_root();
2932 test_fail_target_is_root();
2933 test_fail_target_is_after_source();
2934 test_fail_target_is_ancestor_of_source();
2935 test_fail_target_is_source();
2936 test_fail_variant_tag_is_not_enum();
2937 test_fail_variant_tag_mismatch_mappings();
2938 test_fail_sequence_tag_is_not_int();