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/event-types.h>
23 #include <babeltrace/ctf-ir/event-types-internal.h>
24 #include <babeltrace/ctf-ir/event.h>
25 #include <babeltrace/ctf-ir/stream-class.h>
26 #include <babeltrace/ctf-ir/trace.h>
34 struct bt_ctf_field_type
*get_good_packet_header_type(void)
37 Generated by bt-ctfirtg using the following input:
97 length: trace.packet.header.iron.dust
102 length: trace.packet.header.stream_id
111 struct bt_ctf_field_type
*root
= NULL
;
112 struct bt_ctf_field_type
*root_magic
= NULL
;
113 struct bt_ctf_field_type
*root_uuid
= NULL
;
114 struct bt_ctf_field_type
*root_uuid_elem
= NULL
;
115 struct bt_ctf_field_type
*root_stream_id
= NULL
;
116 struct bt_ctf_field_type
*root_iron
= NULL
;
117 struct bt_ctf_field_type
*root_iron_listen
= NULL
;
118 struct bt_ctf_field_type
*root_iron_dust
= NULL
;
119 struct bt_ctf_field_type
*root_iron_parallel
= NULL
;
120 struct bt_ctf_field_type
*root_iron_parallel_int
= NULL
;
121 struct bt_ctf_field_type
*root_iron_fire
= NULL
;
122 struct bt_ctf_field_type
*root_iron_fire_word
= NULL
;
123 struct bt_ctf_field_type
*root_iron_fire_rabbit
= NULL
;
124 struct bt_ctf_field_type
*root_iron_fire_keen
= NULL
;
125 struct bt_ctf_field_type
*root_iron_fire_keen_elem
= NULL
;
126 struct bt_ctf_field_type
*root_iron_fire_keen_elem_RED
= NULL
;
127 struct bt_ctf_field_type
*root_iron_fire_keen_elem_BLUE
= NULL
;
128 struct bt_ctf_field_type
*root_iron_fire_keen_elem_BLUE_elem
= NULL
;
129 struct bt_ctf_field_type
*root_iron_fire_keen_elem_YELLOW
= NULL
;
130 struct bt_ctf_field_type
*root_iron_report
= NULL
;
131 struct bt_ctf_field_type
*root_iron_report_elem
= NULL
;
132 struct bt_ctf_field_type
*root_iron_group
= NULL
;
133 struct bt_ctf_field_type
*root_iron_group_elem
= NULL
;
134 struct bt_ctf_field_type
*root_serious
= NULL
;
137 root
= bt_ctf_field_type_structure_create();
139 ret
= bt_ctf_field_type_set_alignment(root
, 8);
141 root_magic
= bt_ctf_field_type_integer_create(32);
143 ret
= bt_ctf_field_type_integer_set_signed(root_magic
, 0);
145 ret
= bt_ctf_field_type_integer_set_base(root_magic
, 10);
147 ret
= bt_ctf_field_type_integer_set_encoding(root_magic
, CTF_STRING_NONE
);
149 ret
= bt_ctf_field_type_set_byte_order(root_magic
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
151 ret
= bt_ctf_field_type_set_alignment(root_magic
, 8);
153 ret
= bt_ctf_field_type_structure_add_field(root
, root_magic
, "magic");
155 root_uuid_elem
= bt_ctf_field_type_integer_create(8);
156 assert(root_uuid_elem
);
157 ret
= bt_ctf_field_type_integer_set_signed(root_uuid_elem
, 0);
159 ret
= bt_ctf_field_type_integer_set_base(root_uuid_elem
, 10);
161 ret
= bt_ctf_field_type_integer_set_encoding(root_uuid_elem
, CTF_STRING_NONE
);
163 ret
= bt_ctf_field_type_set_byte_order(root_uuid_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
165 ret
= bt_ctf_field_type_set_alignment(root_uuid_elem
, 8);
167 root_uuid
= bt_ctf_field_type_array_create(root_uuid_elem
, 16);
169 ret
= bt_ctf_field_type_structure_add_field(root
, root_uuid
, "uuid");
171 root_stream_id
= bt_ctf_field_type_integer_create(32);
172 assert(root_stream_id
);
173 ret
= bt_ctf_field_type_integer_set_signed(root_stream_id
, 0);
175 ret
= bt_ctf_field_type_integer_set_base(root_stream_id
, 10);
177 ret
= bt_ctf_field_type_integer_set_encoding(root_stream_id
, CTF_STRING_NONE
);
179 ret
= bt_ctf_field_type_set_byte_order(root_stream_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
181 ret
= bt_ctf_field_type_set_alignment(root_stream_id
, 8);
183 ret
= bt_ctf_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
185 root_iron
= bt_ctf_field_type_structure_create();
187 ret
= bt_ctf_field_type_set_alignment(root_iron
, 8);
189 root_iron_listen
= bt_ctf_field_type_string_create();
190 assert(root_iron_listen
);
191 ret
= bt_ctf_field_type_string_set_encoding(root_iron_listen
, CTF_STRING_UTF8
);
193 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_listen
, "listen");
195 root_iron_dust
= bt_ctf_field_type_integer_create(23);
196 assert(root_iron_dust
);
197 ret
= bt_ctf_field_type_integer_set_signed(root_iron_dust
, 0);
199 ret
= bt_ctf_field_type_integer_set_base(root_iron_dust
, 10);
201 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_dust
, CTF_STRING_NONE
);
203 ret
= bt_ctf_field_type_set_byte_order(root_iron_dust
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
205 ret
= bt_ctf_field_type_set_alignment(root_iron_dust
, 1);
207 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_dust
, "dust");
209 root_iron_parallel_int
= bt_ctf_field_type_integer_create(10);
210 assert(root_iron_parallel_int
);
211 ret
= bt_ctf_field_type_integer_set_signed(root_iron_parallel_int
, 0);
213 ret
= bt_ctf_field_type_integer_set_base(root_iron_parallel_int
, 10);
215 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_parallel_int
, CTF_STRING_NONE
);
217 ret
= bt_ctf_field_type_set_byte_order(root_iron_parallel_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
219 ret
= bt_ctf_field_type_set_alignment(root_iron_parallel_int
, 1);
221 root_iron_parallel
= bt_ctf_field_type_enumeration_create(root_iron_parallel_int
);
222 assert(root_iron_parallel
);
223 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "RED", 0, 0);
225 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "BLUE", 1, 1);
227 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "YELLOW", 2, 2);
229 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_parallel
, "parallel");
231 root_iron_fire
= bt_ctf_field_type_structure_create();
232 assert(root_iron_fire
);
233 ret
= bt_ctf_field_type_set_alignment(root_iron_fire
, 8);
235 root_iron_fire_word
= bt_ctf_field_type_integer_create(17);
236 assert(root_iron_fire_word
);
237 ret
= bt_ctf_field_type_integer_set_signed(root_iron_fire_word
, 0);
239 ret
= bt_ctf_field_type_integer_set_base(root_iron_fire_word
, 10);
241 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_fire_word
, CTF_STRING_NONE
);
243 ret
= bt_ctf_field_type_set_byte_order(root_iron_fire_word
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
245 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_word
, 1);
247 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_word
, "word");
249 root_iron_fire_rabbit
= bt_ctf_field_type_string_create();
250 assert(root_iron_fire_rabbit
);
251 ret
= bt_ctf_field_type_string_set_encoding(root_iron_fire_rabbit
, CTF_STRING_UTF8
);
253 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_rabbit
, "rabbit");
255 root_iron_fire_keen_elem
= bt_ctf_field_type_variant_create(NULL
, "iron.parallel");
256 assert(root_iron_fire_keen_elem
);
257 root_iron_fire_keen_elem_RED
= bt_ctf_field_type_string_create();
258 assert(root_iron_fire_keen_elem_RED
);
259 ret
= bt_ctf_field_type_string_set_encoding(root_iron_fire_keen_elem_RED
, CTF_STRING_UTF8
);
261 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_RED
, "RED");
263 root_iron_fire_keen_elem_BLUE_elem
= bt_ctf_field_type_integer_create(5);
264 assert(root_iron_fire_keen_elem_BLUE_elem
);
265 ret
= bt_ctf_field_type_integer_set_signed(root_iron_fire_keen_elem_BLUE_elem
, 0);
267 ret
= bt_ctf_field_type_integer_set_base(root_iron_fire_keen_elem_BLUE_elem
, 10);
269 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_fire_keen_elem_BLUE_elem
, CTF_STRING_NONE
);
271 ret
= bt_ctf_field_type_set_byte_order(root_iron_fire_keen_elem_BLUE_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
273 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_keen_elem_BLUE_elem
, 1);
275 root_iron_fire_keen_elem_BLUE
= bt_ctf_field_type_sequence_create(root_iron_fire_keen_elem_BLUE_elem
, "magic");
276 assert(root_iron_fire_keen_elem_BLUE
);
277 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_BLUE
, "BLUE");
279 root_iron_fire_keen_elem_YELLOW
= bt_ctf_field_type_structure_create();
280 assert(root_iron_fire_keen_elem_YELLOW
);
281 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_keen_elem_YELLOW
, 1);
283 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_YELLOW
, "YELLOW");
285 root_iron_fire_keen
= bt_ctf_field_type_sequence_create(root_iron_fire_keen_elem
, "word");
286 assert(root_iron_fire_keen
);
287 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_keen
, "keen");
289 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_fire
, "fire");
291 root_iron_report_elem
= bt_ctf_field_type_string_create();
292 assert(root_iron_report_elem
);
293 ret
= bt_ctf_field_type_string_set_encoding(root_iron_report_elem
, CTF_STRING_UTF8
);
295 root_iron_report
= bt_ctf_field_type_sequence_create(root_iron_report_elem
, "trace.packet.header.iron.dust");
296 assert(root_iron_report
);
297 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_report
, "report");
299 root_iron_group_elem
= bt_ctf_field_type_string_create();
300 assert(root_iron_group_elem
);
301 ret
= bt_ctf_field_type_string_set_encoding(root_iron_group_elem
, CTF_STRING_UTF8
);
303 root_iron_group
= bt_ctf_field_type_sequence_create(root_iron_group_elem
, "trace.packet.header.stream_id");
304 assert(root_iron_group
);
305 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_group
, "group");
307 ret
= bt_ctf_field_type_structure_add_field(root
, root_iron
, "iron");
309 root_serious
= bt_ctf_field_type_integer_create(1);
310 assert(root_serious
);
311 ret
= bt_ctf_field_type_integer_set_signed(root_serious
, 0);
313 ret
= bt_ctf_field_type_integer_set_base(root_serious
, 10);
315 ret
= bt_ctf_field_type_integer_set_encoding(root_serious
, CTF_STRING_NONE
);
317 ret
= bt_ctf_field_type_set_byte_order(root_serious
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
319 ret
= bt_ctf_field_type_set_alignment(root_serious
, 1);
321 ret
= bt_ctf_field_type_structure_add_field(root
, root_serious
, "serious");
326 BT_PUT(root_uuid_elem
);
327 BT_PUT(root_stream_id
);
329 BT_PUT(root_iron_listen
);
330 BT_PUT(root_iron_dust
);
331 BT_PUT(root_iron_parallel
);
332 BT_PUT(root_iron_parallel_int
);
333 BT_PUT(root_iron_fire
);
334 BT_PUT(root_iron_fire_word
);
335 BT_PUT(root_iron_fire_rabbit
);
336 BT_PUT(root_iron_fire_keen
);
337 BT_PUT(root_iron_fire_keen_elem
);
338 BT_PUT(root_iron_fire_keen_elem_RED
);
339 BT_PUT(root_iron_fire_keen_elem_BLUE
);
340 BT_PUT(root_iron_fire_keen_elem_BLUE_elem
);
341 BT_PUT(root_iron_fire_keen_elem_YELLOW
);
342 BT_PUT(root_iron_report
);
343 BT_PUT(root_iron_report_elem
);
344 BT_PUT(root_iron_group
);
345 BT_PUT(root_iron_group_elem
);
346 BT_PUT(root_serious
);
352 struct bt_ctf_field_type
*get_good_packet_context_type(void)
355 Generated by bt-ctfirtg using the following input:
387 length: trace.packet.header.iron.fire.word
397 length: stream.packet.context.clover.oval
420 struct bt_ctf_field_type
*root
= NULL
;
421 struct bt_ctf_field_type
*root_placid
= NULL
;
422 struct bt_ctf_field_type
*root_meow
= NULL
;
423 struct bt_ctf_field_type
*root_serious
= NULL
;
424 struct bt_ctf_field_type
*root_naive
= NULL
;
425 struct bt_ctf_field_type
*root_naive_elem
= NULL
;
426 struct bt_ctf_field_type
*root_naive_elem_elem
= NULL
;
427 struct bt_ctf_field_type
*root_clover
= NULL
;
428 struct bt_ctf_field_type
*root_clover_oval
= NULL
;
429 struct bt_ctf_field_type
*root_clover_whole
= NULL
;
430 struct bt_ctf_field_type
*root_clover_whole_BLUE
= NULL
;
431 struct bt_ctf_field_type
*root_clover_whole_BLUE_elem
= NULL
;
432 struct bt_ctf_field_type
*root_clover_whole_RED
= NULL
;
433 struct bt_ctf_field_type
*root_clover_whole_YELLOW
= NULL
;
434 struct bt_ctf_field_type
*root_clover_egg
= NULL
;
435 struct bt_ctf_field_type
*root_clover_egg_elem
= NULL
;
436 struct bt_ctf_field_type
*root_clover_square
= NULL
;
437 struct bt_ctf_field_type
*root_clover_square_int
= NULL
;
438 struct bt_ctf_field_type
*root_clover_useful
= NULL
;
439 struct bt_ctf_field_type
*root_clover_useful_elem
= NULL
;
440 struct bt_ctf_field_type
*root_tart
= NULL
;
443 root
= bt_ctf_field_type_structure_create();
445 ret
= bt_ctf_field_type_set_alignment(root
, 8);
447 root_placid
= bt_ctf_field_type_integer_create(32);
449 ret
= bt_ctf_field_type_integer_set_signed(root_placid
, 0);
451 ret
= bt_ctf_field_type_integer_set_base(root_placid
, 10);
453 ret
= bt_ctf_field_type_integer_set_encoding(root_placid
, CTF_STRING_NONE
);
455 ret
= bt_ctf_field_type_set_byte_order(root_placid
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
457 ret
= bt_ctf_field_type_set_alignment(root_placid
, 8);
459 ret
= bt_ctf_field_type_structure_add_field(root
, root_placid
, "placid");
461 root_meow
= bt_ctf_field_type_string_create();
463 ret
= bt_ctf_field_type_string_set_encoding(root_meow
, CTF_STRING_UTF8
);
465 ret
= bt_ctf_field_type_structure_add_field(root
, root_meow
, "meow");
467 root_serious
= bt_ctf_field_type_integer_create(11);
468 assert(root_serious
);
469 ret
= bt_ctf_field_type_integer_set_signed(root_serious
, 0);
471 ret
= bt_ctf_field_type_integer_set_base(root_serious
, 10);
473 ret
= bt_ctf_field_type_integer_set_encoding(root_serious
, CTF_STRING_NONE
);
475 ret
= bt_ctf_field_type_set_byte_order(root_serious
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
477 ret
= bt_ctf_field_type_set_alignment(root_serious
, 1);
479 ret
= bt_ctf_field_type_structure_add_field(root
, root_serious
, "serious");
481 root_naive_elem_elem
= bt_ctf_field_type_string_create();
482 assert(root_naive_elem_elem
);
483 ret
= bt_ctf_field_type_string_set_encoding(root_naive_elem_elem
, CTF_STRING_UTF8
);
485 root_naive_elem
= bt_ctf_field_type_sequence_create(root_naive_elem_elem
, "placid");
486 assert(root_naive_elem
);
487 root_naive
= bt_ctf_field_type_array_create(root_naive_elem
, 17);
489 ret
= bt_ctf_field_type_structure_add_field(root
, root_naive
, "naive");
491 root_clover
= bt_ctf_field_type_structure_create();
493 ret
= bt_ctf_field_type_set_alignment(root_clover
, 1);
495 root_clover_oval
= bt_ctf_field_type_integer_create(17);
496 assert(root_clover_oval
);
497 ret
= bt_ctf_field_type_integer_set_signed(root_clover_oval
, 0);
499 ret
= bt_ctf_field_type_integer_set_base(root_clover_oval
, 10);
501 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_oval
, CTF_STRING_NONE
);
503 ret
= bt_ctf_field_type_set_byte_order(root_clover_oval
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
505 ret
= bt_ctf_field_type_set_alignment(root_clover_oval
, 1);
507 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_oval
, "oval");
509 root_clover_whole
= bt_ctf_field_type_variant_create(NULL
, "iron.parallel");
510 assert(root_clover_whole
);
511 root_clover_whole_BLUE_elem
= bt_ctf_field_type_string_create();
512 assert(root_clover_whole_BLUE_elem
);
513 ret
= bt_ctf_field_type_string_set_encoding(root_clover_whole_BLUE_elem
, CTF_STRING_UTF8
);
515 root_clover_whole_BLUE
= bt_ctf_field_type_sequence_create(root_clover_whole_BLUE_elem
, "trace.packet.header.iron.fire.word");
516 assert(root_clover_whole_BLUE
);
517 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_BLUE
, "BLUE");
519 root_clover_whole_RED
= bt_ctf_field_type_integer_create(44);
520 assert(root_clover_whole_RED
);
521 ret
= bt_ctf_field_type_integer_set_signed(root_clover_whole_RED
, 0);
523 ret
= bt_ctf_field_type_integer_set_base(root_clover_whole_RED
, 10);
525 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_whole_RED
, CTF_STRING_NONE
);
527 ret
= bt_ctf_field_type_set_byte_order(root_clover_whole_RED
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
529 ret
= bt_ctf_field_type_set_alignment(root_clover_whole_RED
, 1);
531 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_RED
, "RED");
533 root_clover_whole_YELLOW
= bt_ctf_field_type_string_create();
534 assert(root_clover_whole_YELLOW
);
535 ret
= bt_ctf_field_type_string_set_encoding(root_clover_whole_YELLOW
, CTF_STRING_UTF8
);
537 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_YELLOW
, "YELLOW");
539 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_whole
, "whole");
541 root_clover_egg_elem
= bt_ctf_field_type_integer_create(55);
542 assert(root_clover_egg_elem
);
543 ret
= bt_ctf_field_type_integer_set_signed(root_clover_egg_elem
, 0);
545 ret
= bt_ctf_field_type_integer_set_base(root_clover_egg_elem
, 10);
547 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_egg_elem
, CTF_STRING_NONE
);
549 ret
= bt_ctf_field_type_set_byte_order(root_clover_egg_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
551 ret
= bt_ctf_field_type_set_alignment(root_clover_egg_elem
, 1);
553 root_clover_egg
= bt_ctf_field_type_sequence_create(root_clover_egg_elem
, "stream.packet.context.clover.oval");
554 assert(root_clover_egg
);
555 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_egg
, "egg");
557 root_clover_square_int
= bt_ctf_field_type_integer_create(12);
558 assert(root_clover_square_int
);
559 ret
= bt_ctf_field_type_integer_set_signed(root_clover_square_int
, 0);
561 ret
= bt_ctf_field_type_integer_set_base(root_clover_square_int
, 10);
563 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_square_int
, CTF_STRING_NONE
);
565 ret
= bt_ctf_field_type_set_byte_order(root_clover_square_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
567 ret
= bt_ctf_field_type_set_alignment(root_clover_square_int
, 1);
569 root_clover_square
= bt_ctf_field_type_enumeration_create(root_clover_square_int
);
570 assert(root_clover_square
);
571 ret
= bt_ctf_field_type_enumeration_add_mapping(root_clover_square
, "YOUNG", 0, 0);
573 ret
= bt_ctf_field_type_enumeration_add_mapping(root_clover_square
, "OLD", 1, 1);
575 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_square
, "square");
577 root_clover_useful_elem
= bt_ctf_field_type_integer_create(2);
578 assert(root_clover_useful_elem
);
579 ret
= bt_ctf_field_type_integer_set_signed(root_clover_useful_elem
, 0);
581 ret
= bt_ctf_field_type_integer_set_base(root_clover_useful_elem
, 10);
583 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_useful_elem
, CTF_STRING_NONE
);
585 ret
= bt_ctf_field_type_set_byte_order(root_clover_useful_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
587 ret
= bt_ctf_field_type_set_alignment(root_clover_useful_elem
, 1);
589 root_clover_useful
= bt_ctf_field_type_sequence_create(root_clover_useful_elem
, "serious");
590 assert(root_clover_useful
);
591 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_useful
, "useful");
593 ret
= bt_ctf_field_type_structure_add_field(root
, root_clover
, "clover");
595 root_tart
= bt_ctf_field_type_string_create();
597 ret
= bt_ctf_field_type_string_set_encoding(root_tart
, CTF_STRING_UTF8
);
599 ret
= bt_ctf_field_type_structure_add_field(root
, root_tart
, "tart");
604 BT_PUT(root_serious
);
606 BT_PUT(root_naive_elem
);
607 BT_PUT(root_naive_elem_elem
);
609 BT_PUT(root_clover_oval
);
610 BT_PUT(root_clover_whole
);
611 BT_PUT(root_clover_whole_BLUE
);
612 BT_PUT(root_clover_whole_BLUE_elem
);
613 BT_PUT(root_clover_whole_RED
);
614 BT_PUT(root_clover_whole_YELLOW
);
615 BT_PUT(root_clover_egg
);
616 BT_PUT(root_clover_egg_elem
);
617 BT_PUT(root_clover_square
);
618 BT_PUT(root_clover_square_int
);
619 BT_PUT(root_clover_useful
);
620 BT_PUT(root_clover_useful_elem
);
628 struct bt_ctf_field_type
*get_good_event_header_type(void)
631 Generated by bt-ctfirtg using the following input:
649 length: stream.packet.context.placid
656 length: trace.packet.header.serious
662 length: clover.whole.RED
670 length: action.special
677 struct bt_ctf_field_type
*root
= NULL
;
678 struct bt_ctf_field_type
*root_id
= NULL
;
679 struct bt_ctf_field_type
*root_timestamp
= NULL
;
680 struct bt_ctf_field_type
*root_action
= NULL
;
681 struct bt_ctf_field_type
*root_action_special
= NULL
;
682 struct bt_ctf_field_type
*root_action_lucky
= NULL
;
683 struct bt_ctf_field_type
*root_action_lucky_elem
= NULL
;
684 struct bt_ctf_field_type
*root_action_dream
= NULL
;
685 struct bt_ctf_field_type
*root_action_grandiose
= NULL
;
686 struct bt_ctf_field_type
*root_action_grandiose_elem
= NULL
;
687 struct bt_ctf_field_type
*root_stiff
= NULL
;
688 struct bt_ctf_field_type
*root_stiff_elem
= NULL
;
689 struct bt_ctf_field_type
*root_fruit
= NULL
;
690 struct bt_ctf_field_type
*root_fruit_apple
= NULL
;
691 struct bt_ctf_field_type
*root_fruit_apple_elem
= NULL
;
694 root
= bt_ctf_field_type_structure_create();
696 ret
= bt_ctf_field_type_set_alignment(root
, 8);
698 root_id
= bt_ctf_field_type_integer_create(17);
700 ret
= bt_ctf_field_type_integer_set_signed(root_id
, 0);
702 ret
= bt_ctf_field_type_integer_set_base(root_id
, 10);
704 ret
= bt_ctf_field_type_integer_set_encoding(root_id
, CTF_STRING_NONE
);
706 ret
= bt_ctf_field_type_set_byte_order(root_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
708 ret
= bt_ctf_field_type_set_alignment(root_id
, 1);
710 ret
= bt_ctf_field_type_structure_add_field(root
, root_id
, "id");
712 root_timestamp
= bt_ctf_field_type_integer_create(64);
713 assert(root_timestamp
);
714 ret
= bt_ctf_field_type_integer_set_signed(root_timestamp
, 0);
716 ret
= bt_ctf_field_type_integer_set_base(root_timestamp
, 10);
718 ret
= bt_ctf_field_type_integer_set_encoding(root_timestamp
, CTF_STRING_NONE
);
720 ret
= bt_ctf_field_type_set_byte_order(root_timestamp
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
722 ret
= bt_ctf_field_type_set_alignment(root_timestamp
, 8);
724 ret
= bt_ctf_field_type_structure_add_field(root
, root_timestamp
, "timestamp");
726 root_action
= bt_ctf_field_type_structure_create();
728 ret
= bt_ctf_field_type_set_alignment(root_action
, 8);
730 root_action_special
= bt_ctf_field_type_integer_create(17);
731 assert(root_action_special
);
732 ret
= bt_ctf_field_type_integer_set_signed(root_action_special
, 0);
734 ret
= bt_ctf_field_type_integer_set_base(root_action_special
, 10);
736 ret
= bt_ctf_field_type_integer_set_encoding(root_action_special
, CTF_STRING_NONE
);
738 ret
= bt_ctf_field_type_set_byte_order(root_action_special
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
740 ret
= bt_ctf_field_type_set_alignment(root_action_special
, 1);
742 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_special
, "special");
744 root_action_lucky_elem
= bt_ctf_field_type_string_create();
745 assert(root_action_lucky_elem
);
746 ret
= bt_ctf_field_type_string_set_encoding(root_action_lucky_elem
, CTF_STRING_UTF8
);
748 root_action_lucky
= bt_ctf_field_type_sequence_create(root_action_lucky_elem
, "stream.packet.context.placid");
749 assert(root_action_lucky
);
750 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_lucky
, "lucky");
752 root_action_dream
= bt_ctf_field_type_string_create();
753 assert(root_action_dream
);
754 ret
= bt_ctf_field_type_string_set_encoding(root_action_dream
, CTF_STRING_UTF8
);
756 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_dream
, "dream");
758 root_action_grandiose_elem
= bt_ctf_field_type_integer_create(3);
759 assert(root_action_grandiose_elem
);
760 ret
= bt_ctf_field_type_integer_set_signed(root_action_grandiose_elem
, 0);
762 ret
= bt_ctf_field_type_integer_set_base(root_action_grandiose_elem
, 10);
764 ret
= bt_ctf_field_type_integer_set_encoding(root_action_grandiose_elem
, CTF_STRING_NONE
);
766 ret
= bt_ctf_field_type_set_byte_order(root_action_grandiose_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
768 ret
= bt_ctf_field_type_set_alignment(root_action_grandiose_elem
, 1);
770 root_action_grandiose
= bt_ctf_field_type_sequence_create(root_action_grandiose_elem
, "trace.packet.header.serious");
771 assert(root_action_grandiose
);
772 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_grandiose
, "grandiose");
774 ret
= bt_ctf_field_type_structure_add_field(root
, root_action
, "action");
776 root_stiff_elem
= bt_ctf_field_type_string_create();
777 assert(root_stiff_elem
);
778 ret
= bt_ctf_field_type_string_set_encoding(root_stiff_elem
, CTF_STRING_UTF8
);
780 root_stiff
= bt_ctf_field_type_sequence_create(root_stiff_elem
, "clover.whole.RED");
782 ret
= bt_ctf_field_type_structure_add_field(root
, root_stiff
, "stiff");
784 root_fruit
= bt_ctf_field_type_structure_create();
786 ret
= bt_ctf_field_type_set_alignment(root_fruit
, 1);
788 root_fruit_apple_elem
= bt_ctf_field_type_integer_create(5);
789 assert(root_fruit_apple_elem
);
790 ret
= bt_ctf_field_type_integer_set_signed(root_fruit_apple_elem
, 0);
792 ret
= bt_ctf_field_type_integer_set_base(root_fruit_apple_elem
, 10);
794 ret
= bt_ctf_field_type_integer_set_encoding(root_fruit_apple_elem
, CTF_STRING_NONE
);
796 ret
= bt_ctf_field_type_set_byte_order(root_fruit_apple_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
798 ret
= bt_ctf_field_type_set_alignment(root_fruit_apple_elem
, 1);
800 root_fruit_apple
= bt_ctf_field_type_sequence_create(root_fruit_apple_elem
, "action.special");
801 assert(root_fruit_apple
);
802 ret
= bt_ctf_field_type_structure_add_field(root_fruit
, root_fruit_apple
, "apple");
804 ret
= bt_ctf_field_type_structure_add_field(root
, root_fruit
, "fruit");
808 BT_PUT(root_timestamp
);
810 BT_PUT(root_action_special
);
811 BT_PUT(root_action_lucky
);
812 BT_PUT(root_action_lucky_elem
);
813 BT_PUT(root_action_dream
);
814 BT_PUT(root_action_grandiose
);
815 BT_PUT(root_action_grandiose_elem
);
817 BT_PUT(root_stiff_elem
);
819 BT_PUT(root_fruit_apple
);
820 BT_PUT(root_fruit_apple_elem
);
826 struct bt_ctf_field_type
*get_good_stream_event_context_type(void)
829 Generated by bt-ctfirtg using the following input:
859 length: stream.packet.context.placid
862 length: trace.packet.header.iron.dust
865 length: stream.event.context.face.magic
874 struct bt_ctf_field_type
*root
= NULL
;
875 struct bt_ctf_field_type
*root_face
= NULL
;
876 struct bt_ctf_field_type
*root_face_branch
= NULL
;
877 struct bt_ctf_field_type
*root_face_branch_elem
= NULL
;
878 struct bt_ctf_field_type
*root_face_income
= NULL
;
879 struct bt_ctf_field_type
*root_face_income_elem
= NULL
;
880 struct bt_ctf_field_type
*root_face_magic
= NULL
;
881 struct bt_ctf_field_type
*root_face_lucky
= NULL
;
882 struct bt_ctf_field_type
*root_face_lucky_elem
= NULL
;
883 struct bt_ctf_field_type
*root_cats
= NULL
;
884 struct bt_ctf_field_type
*root_dream
= NULL
;
885 struct bt_ctf_field_type
*root_dream_elem
= NULL
;
886 struct bt_ctf_field_type
*root_dream_elem_elem
= NULL
;
887 struct bt_ctf_field_type
*root_dream_elem_elem_elem
= NULL
;
888 struct bt_ctf_field_type
*root_stream_id
= NULL
;
891 root
= bt_ctf_field_type_structure_create();
893 ret
= bt_ctf_field_type_set_alignment(root
, 8);
895 root_face
= bt_ctf_field_type_structure_create();
897 ret
= bt_ctf_field_type_set_alignment(root_face
, 8);
899 root_face_branch_elem
= bt_ctf_field_type_string_create();
900 assert(root_face_branch_elem
);
901 ret
= bt_ctf_field_type_string_set_encoding(root_face_branch_elem
, CTF_STRING_UTF8
);
903 root_face_branch
= bt_ctf_field_type_sequence_create(root_face_branch_elem
, "serious");
904 assert(root_face_branch
);
905 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_branch
, "branch");
907 root_face_income_elem
= bt_ctf_field_type_string_create();
908 assert(root_face_income_elem
);
909 ret
= bt_ctf_field_type_string_set_encoding(root_face_income_elem
, CTF_STRING_UTF8
);
911 root_face_income
= bt_ctf_field_type_sequence_create(root_face_income_elem
, "magic");
912 assert(root_face_income
);
913 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_income
, "income");
915 root_face_magic
= bt_ctf_field_type_integer_create(23);
916 assert(root_face_magic
);
917 ret
= bt_ctf_field_type_integer_set_signed(root_face_magic
, 0);
919 ret
= bt_ctf_field_type_integer_set_base(root_face_magic
, 10);
921 ret
= bt_ctf_field_type_integer_set_encoding(root_face_magic
, CTF_STRING_NONE
);
923 ret
= bt_ctf_field_type_set_byte_order(root_face_magic
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
925 ret
= bt_ctf_field_type_set_alignment(root_face_magic
, 1);
927 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_magic
, "magic");
929 root_face_lucky_elem
= bt_ctf_field_type_string_create();
930 assert(root_face_lucky_elem
);
931 ret
= bt_ctf_field_type_string_set_encoding(root_face_lucky_elem
, CTF_STRING_UTF8
);
933 root_face_lucky
= bt_ctf_field_type_sequence_create(root_face_lucky_elem
, "magic");
934 assert(root_face_lucky
);
935 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_lucky
, "lucky");
937 ret
= bt_ctf_field_type_structure_add_field(root
, root_face
, "face");
939 root_cats
= bt_ctf_field_type_integer_create(5);
941 ret
= bt_ctf_field_type_integer_set_signed(root_cats
, 0);
943 ret
= bt_ctf_field_type_integer_set_base(root_cats
, 10);
945 ret
= bt_ctf_field_type_integer_set_encoding(root_cats
, CTF_STRING_NONE
);
947 ret
= bt_ctf_field_type_set_byte_order(root_cats
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
949 ret
= bt_ctf_field_type_set_alignment(root_cats
, 1);
951 ret
= bt_ctf_field_type_structure_add_field(root
, root_cats
, "cats");
953 root_dream_elem_elem_elem
= bt_ctf_field_type_string_create();
954 assert(root_dream_elem_elem_elem
);
955 ret
= bt_ctf_field_type_string_set_encoding(root_dream_elem_elem_elem
, CTF_STRING_UTF8
);
957 root_dream_elem_elem
= bt_ctf_field_type_sequence_create(root_dream_elem_elem_elem
, "stream.event.context.face.magic");
958 assert(root_dream_elem_elem
);
959 root_dream_elem
= bt_ctf_field_type_sequence_create(root_dream_elem_elem
, "trace.packet.header.iron.dust");
960 assert(root_dream_elem
);
961 root_dream
= bt_ctf_field_type_sequence_create(root_dream_elem
, "stream.packet.context.placid");
963 ret
= bt_ctf_field_type_structure_add_field(root
, root_dream
, "dream");
965 root_stream_id
= bt_ctf_field_type_integer_create(9);
966 assert(root_stream_id
);
967 ret
= bt_ctf_field_type_integer_set_signed(root_stream_id
, 0);
969 ret
= bt_ctf_field_type_integer_set_base(root_stream_id
, 10);
971 ret
= bt_ctf_field_type_integer_set_encoding(root_stream_id
, CTF_STRING_NONE
);
973 ret
= bt_ctf_field_type_set_byte_order(root_stream_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
975 ret
= bt_ctf_field_type_set_alignment(root_stream_id
, 1);
977 ret
= bt_ctf_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
981 BT_PUT(root_face_branch
);
982 BT_PUT(root_face_branch_elem
);
983 BT_PUT(root_face_income
);
984 BT_PUT(root_face_income_elem
);
985 BT_PUT(root_face_magic
);
986 BT_PUT(root_face_lucky
);
987 BT_PUT(root_face_lucky_elem
);
990 BT_PUT(root_dream_elem
);
991 BT_PUT(root_dream_elem_elem
);
992 BT_PUT(root_dream_elem_elem_elem
);
993 BT_PUT(root_stream_id
);
999 struct bt_ctf_field_type
*get_good_event_context_type(void)
1002 Generated by bt-ctfirtg using the following input:
1024 length: action.special
1037 length: iron.fire.word
1048 length: trace.packet.header.iron.fire.word
1053 length: stream.packet.context.clover.oval
1058 length: stream.event.header.action.special
1063 length: stream.event.context.face.magic
1073 length: event.context.film
1079 struct bt_ctf_field_type
*root
= NULL
;
1080 struct bt_ctf_field_type
*root_film
= NULL
;
1081 struct bt_ctf_field_type
*root_berry
= NULL
;
1082 struct bt_ctf_field_type
*root_berry_pine
= NULL
;
1083 struct bt_ctf_field_type
*root_berry_pine_elem
= NULL
;
1084 struct bt_ctf_field_type
*root_berry_porter
= NULL
;
1085 struct bt_ctf_field_type
*root_berry_porter_elem
= NULL
;
1086 struct bt_ctf_field_type
*root_berry_mice
= NULL
;
1087 struct bt_ctf_field_type
*root_berry_mice_elem
= NULL
;
1088 struct bt_ctf_field_type
*root_berry_third
= NULL
;
1089 struct bt_ctf_field_type
*root_berry_guard
= NULL
;
1090 struct bt_ctf_field_type
*root_berry_guard_elem
= NULL
;
1091 struct bt_ctf_field_type
*root_berry_one
= NULL
;
1092 struct bt_ctf_field_type
*root_berry_one_elem
= NULL
;
1093 struct bt_ctf_field_type
*root_cats
= NULL
;
1094 struct bt_ctf_field_type
*root_loud
= NULL
;
1095 struct bt_ctf_field_type
*root_loud_toys
= NULL
;
1096 struct bt_ctf_field_type
*root_loud_toys_elem
= NULL
;
1097 struct bt_ctf_field_type
*root_loud_spoon
= NULL
;
1098 struct bt_ctf_field_type
*root_loud_spoon_elem
= NULL
;
1099 struct bt_ctf_field_type
*root_loud_turkey
= NULL
;
1100 struct bt_ctf_field_type
*root_loud_turkey_elem
= NULL
;
1101 struct bt_ctf_field_type
*root_loud_inform
= NULL
;
1102 struct bt_ctf_field_type
*root_loud_inform_elem
= NULL
;
1103 struct bt_ctf_field_type
*root_loud_odd
= NULL
;
1104 struct bt_ctf_field_type
*root_loud_odd_elem
= NULL
;
1105 struct bt_ctf_field_type
*root_loud_amuck
= NULL
;
1106 struct bt_ctf_field_type
*root_loud_amuck_elem
= NULL
;
1109 root
= bt_ctf_field_type_structure_create();
1111 ret
= bt_ctf_field_type_set_alignment(root
, 8);
1113 root_film
= bt_ctf_field_type_integer_create(19);
1115 ret
= bt_ctf_field_type_integer_set_signed(root_film
, 0);
1117 ret
= bt_ctf_field_type_integer_set_base(root_film
, 10);
1119 ret
= bt_ctf_field_type_integer_set_encoding(root_film
, CTF_STRING_NONE
);
1121 ret
= bt_ctf_field_type_set_byte_order(root_film
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1123 ret
= bt_ctf_field_type_set_alignment(root_film
, 1);
1125 ret
= bt_ctf_field_type_structure_add_field(root
, root_film
, "film");
1127 root_berry
= bt_ctf_field_type_structure_create();
1129 ret
= bt_ctf_field_type_set_alignment(root_berry
, 8);
1131 root_berry_pine_elem
= bt_ctf_field_type_string_create();
1132 assert(root_berry_pine_elem
);
1133 ret
= bt_ctf_field_type_string_set_encoding(root_berry_pine_elem
, CTF_STRING_UTF8
);
1135 root_berry_pine
= bt_ctf_field_type_sequence_create(root_berry_pine_elem
, "stream_id");
1136 assert(root_berry_pine
);
1137 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_pine
, "pine");
1139 root_berry_porter_elem
= bt_ctf_field_type_string_create();
1140 assert(root_berry_porter_elem
);
1141 ret
= bt_ctf_field_type_string_set_encoding(root_berry_porter_elem
, CTF_STRING_UTF8
);
1143 root_berry_porter
= bt_ctf_field_type_sequence_create(root_berry_porter_elem
, "face.magic");
1144 assert(root_berry_porter
);
1145 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_porter
, "porter");
1147 root_berry_mice_elem
= bt_ctf_field_type_string_create();
1148 assert(root_berry_mice_elem
);
1149 ret
= bt_ctf_field_type_string_set_encoding(root_berry_mice_elem
, CTF_STRING_UTF8
);
1151 root_berry_mice
= bt_ctf_field_type_sequence_create(root_berry_mice_elem
, "action.special");
1152 assert(root_berry_mice
);
1153 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_mice
, "mice");
1155 root_berry_third
= bt_ctf_field_type_integer_create(18);
1156 assert(root_berry_third
);
1157 ret
= bt_ctf_field_type_integer_set_signed(root_berry_third
, 0);
1159 ret
= bt_ctf_field_type_integer_set_base(root_berry_third
, 10);
1161 ret
= bt_ctf_field_type_integer_set_encoding(root_berry_third
, CTF_STRING_NONE
);
1163 ret
= bt_ctf_field_type_set_byte_order(root_berry_third
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1165 ret
= bt_ctf_field_type_set_alignment(root_berry_third
, 1);
1167 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_third
, "third");
1169 root_berry_guard_elem
= bt_ctf_field_type_string_create();
1170 assert(root_berry_guard_elem
);
1171 ret
= bt_ctf_field_type_string_set_encoding(root_berry_guard_elem
, CTF_STRING_UTF8
);
1173 root_berry_guard
= bt_ctf_field_type_sequence_create(root_berry_guard_elem
, "clover.oval");
1174 assert(root_berry_guard
);
1175 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_guard
, "guard");
1177 root_berry_one_elem
= bt_ctf_field_type_string_create();
1178 assert(root_berry_one_elem
);
1179 ret
= bt_ctf_field_type_string_set_encoding(root_berry_one_elem
, CTF_STRING_UTF8
);
1181 root_berry_one
= bt_ctf_field_type_sequence_create(root_berry_one_elem
, "iron.fire.word");
1182 assert(root_berry_one
);
1183 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_one
, "one");
1185 ret
= bt_ctf_field_type_structure_add_field(root
, root_berry
, "berry");
1187 root_cats
= bt_ctf_field_type_integer_create(55);
1189 ret
= bt_ctf_field_type_integer_set_signed(root_cats
, 0);
1191 ret
= bt_ctf_field_type_integer_set_base(root_cats
, 10);
1193 ret
= bt_ctf_field_type_integer_set_encoding(root_cats
, CTF_STRING_NONE
);
1195 ret
= bt_ctf_field_type_set_byte_order(root_cats
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1197 ret
= bt_ctf_field_type_set_alignment(root_cats
, 1);
1199 ret
= bt_ctf_field_type_structure_add_field(root
, root_cats
, "cats");
1201 root_loud
= bt_ctf_field_type_structure_create();
1203 ret
= bt_ctf_field_type_set_alignment(root_loud
, 8);
1205 root_loud_toys_elem
= bt_ctf_field_type_string_create();
1206 assert(root_loud_toys_elem
);
1207 ret
= bt_ctf_field_type_string_set_encoding(root_loud_toys_elem
, CTF_STRING_UTF8
);
1209 root_loud_toys
= bt_ctf_field_type_sequence_create(root_loud_toys_elem
, "trace.packet.header.iron.fire.word");
1210 assert(root_loud_toys
);
1211 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_toys
, "toys");
1213 root_loud_spoon_elem
= bt_ctf_field_type_string_create();
1214 assert(root_loud_spoon_elem
);
1215 ret
= bt_ctf_field_type_string_set_encoding(root_loud_spoon_elem
, CTF_STRING_UTF8
);
1217 root_loud_spoon
= bt_ctf_field_type_sequence_create(root_loud_spoon_elem
, "stream.packet.context.clover.oval");
1218 assert(root_loud_spoon
);
1219 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_spoon
, "spoon");
1221 root_loud_turkey_elem
= bt_ctf_field_type_string_create();
1222 assert(root_loud_turkey_elem
);
1223 ret
= bt_ctf_field_type_string_set_encoding(root_loud_turkey_elem
, CTF_STRING_UTF8
);
1225 root_loud_turkey
= bt_ctf_field_type_sequence_create(root_loud_turkey_elem
, "stream.event.header.action.special");
1226 assert(root_loud_turkey
);
1227 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_turkey
, "turkey");
1229 root_loud_inform_elem
= bt_ctf_field_type_string_create();
1230 assert(root_loud_inform_elem
);
1231 ret
= bt_ctf_field_type_string_set_encoding(root_loud_inform_elem
, CTF_STRING_UTF8
);
1233 root_loud_inform
= bt_ctf_field_type_sequence_create(root_loud_inform_elem
, "stream.event.context.face.magic");
1234 assert(root_loud_inform
);
1235 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_inform
, "inform");
1237 root_loud_odd_elem
= bt_ctf_field_type_string_create();
1238 assert(root_loud_odd_elem
);
1239 ret
= bt_ctf_field_type_string_set_encoding(root_loud_odd_elem
, CTF_STRING_UTF8
);
1241 root_loud_odd
= bt_ctf_field_type_sequence_create(root_loud_odd_elem
, "berry.third");
1242 assert(root_loud_odd
);
1243 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_odd
, "odd");
1245 root_loud_amuck_elem
= bt_ctf_field_type_string_create();
1246 assert(root_loud_amuck_elem
);
1247 ret
= bt_ctf_field_type_string_set_encoding(root_loud_amuck_elem
, CTF_STRING_UTF8
);
1249 root_loud_amuck
= bt_ctf_field_type_sequence_create(root_loud_amuck_elem
, "event.context.film");
1250 assert(root_loud_amuck
);
1251 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_amuck
, "amuck");
1253 ret
= bt_ctf_field_type_structure_add_field(root
, root_loud
, "loud");
1258 BT_PUT(root_berry_pine
);
1259 BT_PUT(root_berry_pine_elem
);
1260 BT_PUT(root_berry_porter
);
1261 BT_PUT(root_berry_porter_elem
);
1262 BT_PUT(root_berry_mice
);
1263 BT_PUT(root_berry_mice_elem
);
1264 BT_PUT(root_berry_third
);
1265 BT_PUT(root_berry_guard
);
1266 BT_PUT(root_berry_guard_elem
);
1267 BT_PUT(root_berry_one
);
1268 BT_PUT(root_berry_one_elem
);
1271 BT_PUT(root_loud_toys
);
1272 BT_PUT(root_loud_toys_elem
);
1273 BT_PUT(root_loud_spoon
);
1274 BT_PUT(root_loud_spoon_elem
);
1275 BT_PUT(root_loud_turkey
);
1276 BT_PUT(root_loud_turkey_elem
);
1277 BT_PUT(root_loud_inform
);
1278 BT_PUT(root_loud_inform_elem
);
1279 BT_PUT(root_loud_odd
);
1280 BT_PUT(root_loud_odd_elem
);
1281 BT_PUT(root_loud_amuck
);
1282 BT_PUT(root_loud_amuck_elem
);
1288 struct bt_ctf_field_type
*get_good_event_payload_type(void)
1291 Generated by bt-ctfirtg using the following input:
1341 length: event.fields.splendid
1346 length: event.context.cats
1351 length: event.context.berry.third
1356 length: stream.event.context.face.magic
1361 length: stream.event.header.id
1366 length: stream.packet.context.serious
1371 length: trace.packet.header.iron.dust
1377 struct bt_ctf_field_type
*root
= NULL
;
1378 struct bt_ctf_field_type
*root_splendid
= NULL
;
1379 struct bt_ctf_field_type
*root_relative
= NULL
;
1380 struct bt_ctf_field_type
*root_relative_equal
= NULL
;
1381 struct bt_ctf_field_type
*root_relative_equal_elem
= NULL
;
1382 struct bt_ctf_field_type
*root_relative_amuck
= NULL
;
1383 struct bt_ctf_field_type
*root_relative_amuck_elem
= NULL
;
1384 struct bt_ctf_field_type
*root_relative_push
= NULL
;
1385 struct bt_ctf_field_type
*root_relative_push_elem
= NULL
;
1386 struct bt_ctf_field_type
*root_relative_brick
= NULL
;
1387 struct bt_ctf_field_type
*root_relative_brick_elem
= NULL
;
1388 struct bt_ctf_field_type
*root_relative_crush
= NULL
;
1389 struct bt_ctf_field_type
*root_relative_crush_elem
= NULL
;
1390 struct bt_ctf_field_type
*root_relative_canvas
= NULL
;
1391 struct bt_ctf_field_type
*root_relative_canvas_elem
= NULL
;
1392 struct bt_ctf_field_type
*root_absolute
= NULL
;
1393 struct bt_ctf_field_type
*root_absolute_equal
= NULL
;
1394 struct bt_ctf_field_type
*root_absolute_equal_elem
= NULL
;
1395 struct bt_ctf_field_type
*root_absolute_amuck
= NULL
;
1396 struct bt_ctf_field_type
*root_absolute_amuck_elem
= NULL
;
1397 struct bt_ctf_field_type
*root_absolute_push
= NULL
;
1398 struct bt_ctf_field_type
*root_absolute_push_elem
= NULL
;
1399 struct bt_ctf_field_type
*root_absolute_brick
= NULL
;
1400 struct bt_ctf_field_type
*root_absolute_brick_elem
= NULL
;
1401 struct bt_ctf_field_type
*root_absolute_crush
= NULL
;
1402 struct bt_ctf_field_type
*root_absolute_crush_elem
= NULL
;
1403 struct bt_ctf_field_type
*root_absolute_canvas
= NULL
;
1404 struct bt_ctf_field_type
*root_absolute_canvas_elem
= NULL
;
1407 root
= bt_ctf_field_type_structure_create();
1409 ret
= bt_ctf_field_type_set_alignment(root
, 8);
1411 root_splendid
= bt_ctf_field_type_integer_create(12);
1412 assert(root_splendid
);
1413 ret
= bt_ctf_field_type_integer_set_signed(root_splendid
, 0);
1415 ret
= bt_ctf_field_type_integer_set_base(root_splendid
, 10);
1417 ret
= bt_ctf_field_type_integer_set_encoding(root_splendid
, CTF_STRING_NONE
);
1419 ret
= bt_ctf_field_type_set_byte_order(root_splendid
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1421 ret
= bt_ctf_field_type_set_alignment(root_splendid
, 1);
1423 ret
= bt_ctf_field_type_structure_add_field(root
, root_splendid
, "splendid");
1425 root_relative
= bt_ctf_field_type_structure_create();
1426 assert(root_relative
);
1427 ret
= bt_ctf_field_type_set_alignment(root_relative
, 8);
1429 root_relative_equal_elem
= bt_ctf_field_type_string_create();
1430 assert(root_relative_equal_elem
);
1431 ret
= bt_ctf_field_type_string_set_encoding(root_relative_equal_elem
, CTF_STRING_UTF8
);
1433 root_relative_equal
= bt_ctf_field_type_sequence_create(root_relative_equal_elem
, "splendid");
1434 assert(root_relative_equal
);
1435 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_equal
, "equal");
1437 root_relative_amuck_elem
= bt_ctf_field_type_string_create();
1438 assert(root_relative_amuck_elem
);
1439 ret
= bt_ctf_field_type_string_set_encoding(root_relative_amuck_elem
, CTF_STRING_UTF8
);
1441 root_relative_amuck
= bt_ctf_field_type_sequence_create(root_relative_amuck_elem
, "id");
1442 assert(root_relative_amuck
);
1443 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_amuck
, "amuck");
1445 root_relative_push_elem
= bt_ctf_field_type_string_create();
1446 assert(root_relative_push_elem
);
1447 ret
= bt_ctf_field_type_string_set_encoding(root_relative_push_elem
, CTF_STRING_UTF8
);
1449 root_relative_push
= bt_ctf_field_type_sequence_create(root_relative_push_elem
, "berry.third");
1450 assert(root_relative_push
);
1451 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_push
, "push");
1453 root_relative_brick_elem
= bt_ctf_field_type_string_create();
1454 assert(root_relative_brick_elem
);
1455 ret
= bt_ctf_field_type_string_set_encoding(root_relative_brick_elem
, CTF_STRING_UTF8
);
1457 root_relative_brick
= bt_ctf_field_type_sequence_create(root_relative_brick_elem
, "face.magic");
1458 assert(root_relative_brick
);
1459 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_brick
, "brick");
1461 root_relative_crush_elem
= bt_ctf_field_type_string_create();
1462 assert(root_relative_crush_elem
);
1463 ret
= bt_ctf_field_type_string_set_encoding(root_relative_crush_elem
, CTF_STRING_UTF8
);
1465 root_relative_crush
= bt_ctf_field_type_sequence_create(root_relative_crush_elem
, "serious");
1466 assert(root_relative_crush
);
1467 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_crush
, "crush");
1469 root_relative_canvas_elem
= bt_ctf_field_type_string_create();
1470 assert(root_relative_canvas_elem
);
1471 ret
= bt_ctf_field_type_string_set_encoding(root_relative_canvas_elem
, CTF_STRING_UTF8
);
1473 root_relative_canvas
= bt_ctf_field_type_sequence_create(root_relative_canvas_elem
, "iron.dust");
1474 assert(root_relative_canvas
);
1475 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_canvas
, "canvas");
1477 ret
= bt_ctf_field_type_structure_add_field(root
, root_relative
, "relative");
1479 root_absolute
= bt_ctf_field_type_structure_create();
1480 assert(root_absolute
);
1481 ret
= bt_ctf_field_type_set_alignment(root_absolute
, 8);
1483 root_absolute_equal_elem
= bt_ctf_field_type_string_create();
1484 assert(root_absolute_equal_elem
);
1485 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_equal_elem
, CTF_STRING_UTF8
);
1487 root_absolute_equal
= bt_ctf_field_type_sequence_create(root_absolute_equal_elem
, "event.fields.splendid");
1488 assert(root_absolute_equal
);
1489 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_equal
, "equal");
1491 root_absolute_amuck_elem
= bt_ctf_field_type_string_create();
1492 assert(root_absolute_amuck_elem
);
1493 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_amuck_elem
, CTF_STRING_UTF8
);
1495 root_absolute_amuck
= bt_ctf_field_type_sequence_create(root_absolute_amuck_elem
, "stream.event.header.id");
1496 assert(root_absolute_amuck
);
1497 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_amuck
, "amuck");
1499 root_absolute_push_elem
= bt_ctf_field_type_string_create();
1500 assert(root_absolute_push_elem
);
1501 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_push_elem
, CTF_STRING_UTF8
);
1503 root_absolute_push
= bt_ctf_field_type_sequence_create(root_absolute_push_elem
, "event.context.berry.third");
1504 assert(root_absolute_push
);
1505 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_push
, "push");
1507 root_absolute_brick_elem
= bt_ctf_field_type_string_create();
1508 assert(root_absolute_brick_elem
);
1509 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_brick_elem
, CTF_STRING_UTF8
);
1511 root_absolute_brick
= bt_ctf_field_type_sequence_create(root_absolute_brick_elem
, "stream.event.context.face.magic");
1512 assert(root_absolute_brick
);
1513 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_brick
, "brick");
1515 root_absolute_crush_elem
= bt_ctf_field_type_string_create();
1516 assert(root_absolute_crush_elem
);
1517 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_crush_elem
, CTF_STRING_UTF8
);
1519 root_absolute_crush
= bt_ctf_field_type_sequence_create(root_absolute_crush_elem
, "stream.packet.context.serious");
1520 assert(root_absolute_crush
);
1521 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_crush
, "crush");
1523 root_absolute_canvas_elem
= bt_ctf_field_type_string_create();
1524 assert(root_absolute_canvas_elem
);
1525 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_canvas_elem
, CTF_STRING_UTF8
);
1527 root_absolute_canvas
= bt_ctf_field_type_sequence_create(root_absolute_canvas_elem
, "trace.packet.header.iron.dust");
1528 assert(root_absolute_canvas
);
1529 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_canvas
, "canvas");
1531 ret
= bt_ctf_field_type_structure_add_field(root
, root_absolute
, "absolute");
1534 BT_PUT(root_splendid
);
1535 BT_PUT(root_relative
);
1536 BT_PUT(root_relative_equal
);
1537 BT_PUT(root_relative_equal_elem
);
1538 BT_PUT(root_relative_amuck
);
1539 BT_PUT(root_relative_amuck_elem
);
1540 BT_PUT(root_relative_push
);
1541 BT_PUT(root_relative_push_elem
);
1542 BT_PUT(root_relative_brick
);
1543 BT_PUT(root_relative_brick_elem
);
1544 BT_PUT(root_relative_crush
);
1545 BT_PUT(root_relative_crush_elem
);
1546 BT_PUT(root_relative_canvas
);
1547 BT_PUT(root_relative_canvas_elem
);
1548 BT_PUT(root_absolute
);
1549 BT_PUT(root_absolute_equal
);
1550 BT_PUT(root_absolute_equal_elem
);
1551 BT_PUT(root_absolute_amuck
);
1552 BT_PUT(root_absolute_amuck_elem
);
1553 BT_PUT(root_absolute_push
);
1554 BT_PUT(root_absolute_push_elem
);
1555 BT_PUT(root_absolute_brick
);
1556 BT_PUT(root_absolute_brick_elem
);
1557 BT_PUT(root_absolute_crush
);
1558 BT_PUT(root_absolute_crush_elem
);
1559 BT_PUT(root_absolute_canvas
);
1560 BT_PUT(root_absolute_canvas_elem
);
1566 struct bt_ctf_field_type
*get_child_ft(struct bt_ctf_field_type
*parent_ft
,
1569 struct bt_ctf_field_type
*ft
= NULL
;
1571 switch (bt_ctf_field_type_get_type_id(parent_ft
)) {
1572 case CTF_TYPE_STRUCT
:
1573 ft
= bt_ctf_field_type_structure_get_field_type_by_name(
1577 case CTF_TYPE_VARIANT
:
1578 ft
= bt_ctf_field_type_variant_get_field_type_by_name(
1582 case CTF_TYPE_ARRAY
:
1583 ft
= bt_ctf_field_type_array_get_element_type(parent_ft
);
1586 case CTF_TYPE_SEQUENCE
:
1587 ft
= bt_ctf_field_type_sequence_get_element_type(parent_ft
);
1591 ft
= bt_ctf_field_type_enumeration_get_container_type(
1605 struct bt_ctf_field_type
*get_ft(struct bt_ctf_field_type
*root_ft
, ...)
1607 struct bt_ctf_field_type
*child_ft
= NULL
;
1608 struct bt_ctf_field_type
*ft
= root_ft
;
1611 va_start(ap
, root_ft
);
1615 const char *field_name
= va_arg(ap
, const char *);
1617 if (field_name
== NULL
) {
1621 child_ft
= get_child_ft(ft
, field_name
);
1628 BT_MOVE(ft
, child_ft
);
1637 #define FIELD_PATH_END -2
1640 int validate_field_path(struct bt_ctf_field_type
*field_type
,
1641 enum bt_ctf_node root
, ...)
1648 const struct bt_ctf_field_path
*field_path
;
1653 if (bt_ctf_field_type_is_sequence(field_type
)) {
1654 field_path
= ((struct bt_ctf_field_type_sequence
*)
1655 field_type
)->length_field_path
;
1656 } else if (bt_ctf_field_type_is_variant(field_type
)) {
1657 field_path
= ((struct bt_ctf_field_type_variant
*)
1658 field_type
)->tag_path
;
1669 if (field_path
->root
!= root
) {
1674 len
= field_path
->path_indexes
->len
;
1677 expected_index
= va_arg(ap
, int);
1679 if (expected_index
== FIELD_PATH_END
) {
1687 actual_index
= g_array_index(field_path
->path_indexes
, int, i
);
1689 if (actual_index
!= expected_index
) {
1697 if (i
!= len
|| expected_index
!= FIELD_PATH_END
) {
1708 void validate_test_pass(struct bt_ctf_trace
*trace
)
1710 struct bt_ctf_stream_class
*sc
;
1711 struct bt_ctf_event_class
*ec
;
1712 struct bt_ctf_field_type
*ph
;
1713 struct bt_ctf_field_type
*pc
;
1714 struct bt_ctf_field_type
*eh
;
1715 struct bt_ctf_field_type
*sec
;
1716 struct bt_ctf_field_type
*ectx
;
1717 struct bt_ctf_field_type
*ep
;
1718 struct bt_ctf_field_type
*ft_src
= NULL
;
1719 struct bt_ctf_field_type
*ft_target
= NULL
;
1720 struct bt_ctf_field_type
*ft_tag
= NULL
;
1722 sc
= bt_ctf_trace_get_stream_class(trace
, 0);
1724 ec
= bt_ctf_stream_class_get_event_class(sc
, 0);
1727 ph
= bt_ctf_trace_get_packet_header_type(trace
);
1728 ok(ph
, "Trace packet header still exists after successful validation");
1729 pc
= bt_ctf_stream_class_get_packet_context_type(sc
);
1730 ok(pc
, "Stream packet context still exists after successful validation");
1731 eh
= bt_ctf_stream_class_get_event_header_type(sc
);
1732 ok(eh
, "Stream event header still exists after successful validation");
1733 sec
= bt_ctf_stream_class_get_event_context_type(sc
);
1734 ok(sec
, "Stream event context still exists after successful validation");
1735 ectx
= bt_ctf_event_class_get_context_type(ec
);
1736 ok(ectx
, "Event context still exists after successful validation");
1737 ep
= bt_ctf_event_class_get_payload_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
, CTF_NODE_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 CTF_NODE_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_ctf_field_type_variant_get_tag_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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_ctf_field_type_variant_get_tag_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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 CTF_NODE_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_ctf_trace
*trace
;
2063 struct bt_ctf_stream_class
*sc
;
2064 struct bt_ctf_event_class
*ec
;
2065 struct bt_ctf_field_type
*ph
;
2066 struct bt_ctf_field_type
*pc
;
2067 struct bt_ctf_field_type
*eh
;
2068 struct bt_ctf_field_type
*sec
;
2069 struct bt_ctf_field_type
*ectx
;
2070 struct bt_ctf_field_type
*ep
;
2072 trace
= bt_ctf_trace_create();
2074 sc
= bt_ctf_stream_class_create("nice_piece_of_stream_class");
2076 ec
= bt_ctf_event_class_create("oh_what_an_event_class");
2079 ph
= get_good_packet_header_type();
2081 pc
= get_good_packet_context_type();
2083 eh
= get_good_event_header_type();
2085 sec
= get_good_stream_event_context_type();
2087 ectx
= get_good_event_context_type();
2089 ep
= get_good_event_payload_type();
2092 ret
= bt_ctf_trace_set_packet_header_type(trace
, ph
);
2094 ret
= bt_ctf_stream_class_set_packet_context_type(sc
, pc
);
2096 ret
= bt_ctf_stream_class_set_event_header_type(sc
, eh
);
2098 ret
= bt_ctf_stream_class_set_event_context_type(sc
, sec
);
2100 ret
= bt_ctf_event_class_set_context_type(ec
, ectx
);
2102 ret
= bt_ctf_event_class_set_payload_type(ec
, ep
);
2105 ret
= bt_ctf_stream_class_add_event_class(sc
, ec
);
2108 /* Validation happens here */
2109 ret
= bt_ctf_trace_add_stream_class(trace
, sc
);
2110 ok(ret
== 0, "Valid type system is considered valid");
2112 validate_test_pass(trace
);
2126 struct bt_ctf_event
*create_event_with_context_and_payload(
2127 struct bt_ctf_field_type
*ectx
, struct bt_ctf_field_type
*ep
)
2130 struct bt_ctf_stream_class
*sc
;
2131 struct bt_ctf_event_class
*ec
;
2132 struct bt_ctf_event
*event
;
2134 sc
= bt_ctf_stream_class_create("sc");
2136 ec
= bt_ctf_event_class_create("ec");
2140 ret
= bt_ctf_event_class_set_context_type(ec
, ectx
);
2145 ret
= bt_ctf_event_class_set_payload_type(ec
, ep
);
2149 ret
= bt_ctf_stream_class_add_event_class(sc
, ec
);
2152 /* Validation happens here */
2153 event
= bt_ctf_event_create(ec
);
2163 struct bt_ctf_field_type
*test_fail_unavailable_root_get_event_payload(void)
2166 Generated by bt-ctfirtg using the following input:
2175 length: stream.event.context.lol
2183 struct bt_ctf_field_type
*root
= NULL
;
2184 struct bt_ctf_field_type
*root_a
= NULL
;
2185 struct bt_ctf_field_type
*root_b
= NULL
;
2186 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2187 struct bt_ctf_field_type
*root_c
= NULL
;
2190 root
= bt_ctf_field_type_structure_create();
2192 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2194 root_a
= bt_ctf_field_type_integer_create(32);
2196 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2198 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2200 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, CTF_STRING_NONE
);
2202 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2204 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2206 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2208 root_b_elem
= bt_ctf_field_type_string_create();
2209 assert(root_b_elem
);
2210 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, CTF_STRING_UTF8
);
2212 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "stream.event.context.lol");
2214 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2216 root_c
= bt_ctf_field_type_string_create();
2218 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2220 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2225 BT_PUT(root_b_elem
);
2232 void test_fail_unavailable_root(void)
2234 struct bt_ctf_field_type
*ep
;
2235 struct bt_ctf_event
*event
;
2237 ep
= test_fail_unavailable_root_get_event_payload();
2239 event
= create_event_with_context_and_payload(NULL
, ep
);
2240 ok(!event
, "Sequence FT with length in unavailable root is invalid");
2247 struct bt_ctf_field_type
*test_fail_target_is_root_get_event_payload(void)
2250 Generated by bt-ctfirtg using the following input:
2259 length: event.fields
2267 struct bt_ctf_field_type
*root
= NULL
;
2268 struct bt_ctf_field_type
*root_a
= NULL
;
2269 struct bt_ctf_field_type
*root_b
= NULL
;
2270 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2271 struct bt_ctf_field_type
*root_c
= NULL
;
2274 root
= bt_ctf_field_type_structure_create();
2276 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2278 root_a
= bt_ctf_field_type_integer_create(32);
2280 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2282 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2284 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, CTF_STRING_NONE
);
2286 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2288 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2290 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2292 root_b_elem
= bt_ctf_field_type_string_create();
2293 assert(root_b_elem
);
2294 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, CTF_STRING_UTF8
);
2296 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "event.fields");
2298 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2300 root_c
= bt_ctf_field_type_string_create();
2302 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2304 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2309 BT_PUT(root_b_elem
);
2316 void test_fail_target_is_root(void)
2318 struct bt_ctf_field_type
*ep
;
2319 struct bt_ctf_event
*event
;
2321 ep
= test_fail_target_is_root_get_event_payload();
2323 event
= create_event_with_context_and_payload(NULL
, ep
);
2324 ok(!event
, "Sequence FT with root as its length is invalid");
2331 struct bt_ctf_field_type
*test_fail_target_is_after_source_get_ep(void)
2334 Generated by bt-ctfirtg using the following input:
2354 struct bt_ctf_field_type
*root
= NULL
;
2355 struct bt_ctf_field_type
*root_a
= NULL
;
2356 struct bt_ctf_field_type
*root_b
= NULL
;
2357 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2358 struct bt_ctf_field_type
*root_c
= NULL
;
2359 struct bt_ctf_field_type
*root_d
= NULL
;
2362 root
= bt_ctf_field_type_structure_create();
2364 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2366 root_a
= bt_ctf_field_type_integer_create(32);
2368 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2370 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2372 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, CTF_STRING_NONE
);
2374 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2376 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2378 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2380 root_b_elem
= bt_ctf_field_type_string_create();
2381 assert(root_b_elem
);
2382 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, CTF_STRING_UTF8
);
2384 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "d");
2386 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2388 root_c
= bt_ctf_field_type_string_create();
2390 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2392 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2394 root_d
= bt_ctf_field_type_integer_create(17);
2396 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2398 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2400 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, CTF_STRING_NONE
);
2402 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2404 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2406 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2411 BT_PUT(root_b_elem
);
2419 void test_fail_target_is_after_source(void)
2421 struct bt_ctf_field_type
*ep
;
2422 struct bt_ctf_event
*event
;
2424 ep
= test_fail_target_is_after_source_get_ep();
2426 event
= create_event_with_context_and_payload(NULL
, ep
);
2427 ok(!event
, "Sequence FT with length after it is invalid");
2434 struct bt_ctf_field_type
*test_fail_target_is_ancestor_of_source_get_ep(void)
2437 Generated by bt-ctfirtg using the following input:
2460 struct bt_ctf_field_type
*root
= NULL
;
2461 struct bt_ctf_field_type
*root_a
= NULL
;
2462 struct bt_ctf_field_type
*root_z
= NULL
;
2463 struct bt_ctf_field_type
*root_z_b
= NULL
;
2464 struct bt_ctf_field_type
*root_z_b_elem
= NULL
;
2465 struct bt_ctf_field_type
*root_c
= NULL
;
2466 struct bt_ctf_field_type
*root_d
= NULL
;
2469 root
= bt_ctf_field_type_structure_create();
2471 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2473 root_a
= bt_ctf_field_type_integer_create(32);
2475 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2477 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2479 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, CTF_STRING_NONE
);
2481 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2483 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2485 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2487 root_z
= bt_ctf_field_type_structure_create();
2489 ret
= bt_ctf_field_type_set_alignment(root_z
, 8);
2491 root_z_b_elem
= bt_ctf_field_type_string_create();
2492 assert(root_z_b_elem
);
2493 ret
= bt_ctf_field_type_string_set_encoding(root_z_b_elem
, CTF_STRING_UTF8
);
2495 root_z_b
= bt_ctf_field_type_sequence_create(root_z_b_elem
, "z");
2497 ret
= bt_ctf_field_type_structure_add_field(root_z
, root_z_b
, "b");
2499 ret
= bt_ctf_field_type_structure_add_field(root
, root_z
, "z");
2501 root_c
= bt_ctf_field_type_string_create();
2503 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2505 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2507 root_d
= bt_ctf_field_type_integer_create(17);
2509 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2511 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2513 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, CTF_STRING_NONE
);
2515 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2517 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2519 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2525 BT_PUT(root_z_b_elem
);
2533 void test_fail_target_is_ancestor_of_source(void)
2535 struct bt_ctf_field_type
*ep
;
2536 struct bt_ctf_event
*event
;
2538 ep
= test_fail_target_is_ancestor_of_source_get_ep();
2540 event
= create_event_with_context_and_payload(NULL
, ep
);
2541 ok(!event
, "Sequence FT with ancestor as its length is invalid");
2548 struct bt_ctf_field_type
*test_fail_target_is_source_get_event_payload(void)
2551 Generated by bt-ctfirtg using the following input:
2560 length: event.fields.b
2571 struct bt_ctf_field_type
*root
= NULL
;
2572 struct bt_ctf_field_type
*root_a
= NULL
;
2573 struct bt_ctf_field_type
*root_b
= NULL
;
2574 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2575 struct bt_ctf_field_type
*root_c
= NULL
;
2576 struct bt_ctf_field_type
*root_d
= NULL
;
2579 root
= bt_ctf_field_type_structure_create();
2581 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2583 root_a
= bt_ctf_field_type_integer_create(32);
2585 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2587 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2589 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, CTF_STRING_NONE
);
2591 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2593 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2595 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2597 root_b_elem
= bt_ctf_field_type_string_create();
2598 assert(root_b_elem
);
2599 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, CTF_STRING_UTF8
);
2601 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "event.fields.b");
2603 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2605 root_c
= bt_ctf_field_type_string_create();
2607 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2609 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2611 root_d
= bt_ctf_field_type_integer_create(17);
2613 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2615 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2617 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, CTF_STRING_NONE
);
2619 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2621 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2623 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2628 BT_PUT(root_b_elem
);
2636 void test_fail_target_is_source(void)
2638 struct bt_ctf_field_type
*ep
;
2639 struct bt_ctf_event
*event
;
2641 ep
= test_fail_target_is_source_get_event_payload();
2643 event
= create_event_with_context_and_payload(NULL
, ep
);
2644 ok(!event
, "Sequence FT with itself as its length is invalid");
2651 struct bt_ctf_field_type
*test_fail_variant_tag_is_not_enum_get_ep(void)
2654 Generated by bt-ctfirtg using the following input:
2675 struct bt_ctf_field_type
*root
= NULL
;
2676 struct bt_ctf_field_type
*root_a
= NULL
;
2677 struct bt_ctf_field_type
*root_b
= NULL
;
2678 struct bt_ctf_field_type
*root_b_HELLO
= NULL
;
2679 struct bt_ctf_field_type
*root_c
= NULL
;
2680 struct bt_ctf_field_type
*root_d
= NULL
;
2683 root
= bt_ctf_field_type_structure_create();
2685 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2687 root_a
= bt_ctf_field_type_integer_create(32);
2689 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2691 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2693 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, CTF_STRING_NONE
);
2695 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2697 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2699 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2701 root_b
= bt_ctf_field_type_variant_create(NULL
, "a");
2703 root_b_HELLO
= bt_ctf_field_type_string_create();
2704 assert(root_b_HELLO
);
2705 ret
= bt_ctf_field_type_string_set_encoding(root_b_HELLO
, CTF_STRING_UTF8
);
2707 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_HELLO
, "HELLO");
2709 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2711 root_c
= bt_ctf_field_type_string_create();
2713 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2715 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2717 root_d
= bt_ctf_field_type_integer_create(17);
2719 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2721 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2723 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, CTF_STRING_NONE
);
2725 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2727 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2729 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2734 BT_PUT(root_b_HELLO
);
2742 void test_fail_variant_tag_is_not_enum(void)
2744 struct bt_ctf_field_type
*ep
;
2745 struct bt_ctf_event
*event
;
2747 ep
= test_fail_variant_tag_is_not_enum_get_ep();
2749 event
= create_event_with_context_and_payload(NULL
, ep
);
2750 ok(!event
, "Variant FT with non-enum FT as its tag FT is invalid");
2757 struct bt_ctf_field_type
*test_fail_variant_tag_mismatch_mappings_get_ep(void)
2760 Generated by bt-ctfirtg using the following input:
2787 struct bt_ctf_field_type
*root
= NULL
;
2788 struct bt_ctf_field_type
*root_a
= NULL
;
2789 struct bt_ctf_field_type
*root_a_int
= NULL
;
2790 struct bt_ctf_field_type
*root_b
= NULL
;
2791 struct bt_ctf_field_type
*root_b_GLASS
= NULL
;
2792 struct bt_ctf_field_type
*root_b_OF
= NULL
;
2793 struct bt_ctf_field_type
*root_c
= NULL
;
2796 root
= bt_ctf_field_type_structure_create();
2798 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2800 root_a_int
= bt_ctf_field_type_integer_create(16);
2802 ret
= bt_ctf_field_type_integer_set_signed(root_a_int
, 0);
2804 ret
= bt_ctf_field_type_integer_set_base(root_a_int
, 10);
2806 ret
= bt_ctf_field_type_integer_set_encoding(root_a_int
, CTF_STRING_NONE
);
2808 ret
= bt_ctf_field_type_set_byte_order(root_a_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2810 ret
= bt_ctf_field_type_set_alignment(root_a_int
, 8);
2812 root_a
= bt_ctf_field_type_enumeration_create(root_a_int
);
2814 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "GLASS", 0, 0);
2816 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "OF", 1, 1);
2818 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "WATER", 2, 2);
2820 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2822 root_b
= bt_ctf_field_type_variant_create(NULL
, "a");
2824 root_b_GLASS
= bt_ctf_field_type_string_create();
2825 assert(root_b_GLASS
);
2826 ret
= bt_ctf_field_type_string_set_encoding(root_b_GLASS
, CTF_STRING_UTF8
);
2828 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_GLASS
, "GLASS");
2830 root_b_OF
= bt_ctf_field_type_integer_create(2);
2832 ret
= bt_ctf_field_type_integer_set_signed(root_b_OF
, 0);
2834 ret
= bt_ctf_field_type_integer_set_base(root_b_OF
, 10);
2836 ret
= bt_ctf_field_type_integer_set_encoding(root_b_OF
, CTF_STRING_NONE
);
2838 ret
= bt_ctf_field_type_set_byte_order(root_b_OF
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2840 ret
= bt_ctf_field_type_set_alignment(root_b_OF
, 1);
2842 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_OF
, "OF");
2844 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2846 root_c
= bt_ctf_field_type_string_create();
2848 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2850 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2856 BT_PUT(root_b_GLASS
);
2864 void test_fail_variant_tag_mismatch_mappings(void)
2866 struct bt_ctf_field_type
*ep
;
2867 struct bt_ctf_event
*event
;
2869 ep
= test_fail_variant_tag_mismatch_mappings_get_ep();
2871 event
= create_event_with_context_and_payload(NULL
, ep
);
2872 ok(!event
, "Variant FT with mismatching tag FT is invalid");
2879 struct bt_ctf_field_type
*test_fail_sequence_tag_is_not_int_get_ep(void)
2882 Generated by bt-ctfirtg using the following input:
2898 struct bt_ctf_field_type
*root
= NULL
;
2899 struct bt_ctf_field_type
*root_a
= NULL
;
2900 struct bt_ctf_field_type
*root_b
= NULL
;
2901 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2902 struct bt_ctf_field_type
*root_c
= NULL
;
2905 root
= bt_ctf_field_type_structure_create();
2907 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2909 root_a
= bt_ctf_field_type_string_create();
2911 ret
= bt_ctf_field_type_string_set_encoding(root_a
, CTF_STRING_UTF8
);
2913 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2915 root_b_elem
= bt_ctf_field_type_string_create();
2916 assert(root_b_elem
);
2917 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, CTF_STRING_UTF8
);
2919 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "a");
2921 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2923 root_c
= bt_ctf_field_type_string_create();
2925 ret
= bt_ctf_field_type_string_set_encoding(root_c
, CTF_STRING_UTF8
);
2927 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2932 BT_PUT(root_b_elem
);
2939 void test_fail_sequence_tag_is_not_int(void)
2941 struct bt_ctf_field_type
*ep
;
2942 struct bt_ctf_event
*event
;
2944 ep
= test_fail_sequence_tag_is_not_int_get_ep();
2946 event
= create_event_with_context_and_payload(NULL
, ep
);
2947 ok(!event
, "Sequence FT with non-enum length FT is invalid");
2954 void test_fail(void)
2956 test_fail_unavailable_root();
2957 test_fail_target_is_root();
2958 test_fail_target_is_after_source();
2959 test_fail_target_is_ancestor_of_source();
2960 test_fail_target_is_source();
2961 test_fail_variant_tag_is_not_enum();
2962 test_fail_variant_tag_mismatch_mappings();
2963 test_fail_sequence_tag_is_not_int();