2 * test_bt_ctf_field_type_validation.c
4 * Babeltrace CTF IR field type validation test
6 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; under version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <babeltrace/ctf-ir/field-types.h>
23 #include <babeltrace/ctf-ir/field-path.h>
24 #include <babeltrace/ctf-ir/event.h>
25 #include <babeltrace/ctf-ir/event-class.h>
26 #include <babeltrace/ctf-ir/stream-class.h>
27 #include <babeltrace/ctf-ir/trace.h>
36 struct bt_ctf_field_type
*get_good_packet_header_type(void)
39 Generated by bt-ctfirtg using the following input:
99 length: trace.packet.header.iron.dust
104 length: trace.packet.header.stream_id
113 struct bt_ctf_field_type
*root
= NULL
;
114 struct bt_ctf_field_type
*root_magic
= NULL
;
115 struct bt_ctf_field_type
*root_uuid
= NULL
;
116 struct bt_ctf_field_type
*root_uuid_elem
= NULL
;
117 struct bt_ctf_field_type
*root_stream_id
= NULL
;
118 struct bt_ctf_field_type
*root_iron
= NULL
;
119 struct bt_ctf_field_type
*root_iron_listen
= NULL
;
120 struct bt_ctf_field_type
*root_iron_dust
= NULL
;
121 struct bt_ctf_field_type
*root_iron_parallel
= NULL
;
122 struct bt_ctf_field_type
*root_iron_parallel_int
= NULL
;
123 struct bt_ctf_field_type
*root_iron_fire
= NULL
;
124 struct bt_ctf_field_type
*root_iron_fire_word
= NULL
;
125 struct bt_ctf_field_type
*root_iron_fire_rabbit
= NULL
;
126 struct bt_ctf_field_type
*root_iron_fire_keen
= NULL
;
127 struct bt_ctf_field_type
*root_iron_fire_keen_elem
= NULL
;
128 struct bt_ctf_field_type
*root_iron_fire_keen_elem_RED
= NULL
;
129 struct bt_ctf_field_type
*root_iron_fire_keen_elem_BLUE
= NULL
;
130 struct bt_ctf_field_type
*root_iron_fire_keen_elem_BLUE_elem
= NULL
;
131 struct bt_ctf_field_type
*root_iron_fire_keen_elem_YELLOW
= NULL
;
132 struct bt_ctf_field_type
*root_iron_report
= NULL
;
133 struct bt_ctf_field_type
*root_iron_report_elem
= NULL
;
134 struct bt_ctf_field_type
*root_iron_group
= NULL
;
135 struct bt_ctf_field_type
*root_iron_group_elem
= NULL
;
136 struct bt_ctf_field_type
*root_serious
= NULL
;
139 root
= bt_ctf_field_type_structure_create();
141 ret
= bt_ctf_field_type_set_alignment(root
, 8);
143 root_magic
= bt_ctf_field_type_integer_create(32);
145 ret
= bt_ctf_field_type_integer_set_signed(root_magic
, 0);
147 ret
= bt_ctf_field_type_integer_set_base(root_magic
, 10);
149 ret
= bt_ctf_field_type_integer_set_encoding(root_magic
, BT_CTF_STRING_ENCODING_NONE
);
151 ret
= bt_ctf_field_type_set_byte_order(root_magic
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
153 ret
= bt_ctf_field_type_set_alignment(root_magic
, 8);
155 ret
= bt_ctf_field_type_structure_add_field(root
, root_magic
, "magic");
157 root_uuid_elem
= bt_ctf_field_type_integer_create(8);
158 assert(root_uuid_elem
);
159 ret
= bt_ctf_field_type_integer_set_signed(root_uuid_elem
, 0);
161 ret
= bt_ctf_field_type_integer_set_base(root_uuid_elem
, 10);
163 ret
= bt_ctf_field_type_integer_set_encoding(root_uuid_elem
, BT_CTF_STRING_ENCODING_NONE
);
165 ret
= bt_ctf_field_type_set_byte_order(root_uuid_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
167 ret
= bt_ctf_field_type_set_alignment(root_uuid_elem
, 8);
169 root_uuid
= bt_ctf_field_type_array_create(root_uuid_elem
, 16);
171 ret
= bt_ctf_field_type_structure_add_field(root
, root_uuid
, "uuid");
173 root_stream_id
= bt_ctf_field_type_integer_create(32);
174 assert(root_stream_id
);
175 ret
= bt_ctf_field_type_integer_set_signed(root_stream_id
, 0);
177 ret
= bt_ctf_field_type_integer_set_base(root_stream_id
, 10);
179 ret
= bt_ctf_field_type_integer_set_encoding(root_stream_id
, BT_CTF_STRING_ENCODING_NONE
);
181 ret
= bt_ctf_field_type_set_byte_order(root_stream_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
183 ret
= bt_ctf_field_type_set_alignment(root_stream_id
, 8);
185 ret
= bt_ctf_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
187 root_iron
= bt_ctf_field_type_structure_create();
189 ret
= bt_ctf_field_type_set_alignment(root_iron
, 8);
191 root_iron_listen
= bt_ctf_field_type_string_create();
192 assert(root_iron_listen
);
193 ret
= bt_ctf_field_type_string_set_encoding(root_iron_listen
, BT_CTF_STRING_ENCODING_UTF8
);
195 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_listen
, "listen");
197 root_iron_dust
= bt_ctf_field_type_integer_create(23);
198 assert(root_iron_dust
);
199 ret
= bt_ctf_field_type_integer_set_signed(root_iron_dust
, 0);
201 ret
= bt_ctf_field_type_integer_set_base(root_iron_dust
, 10);
203 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_dust
, BT_CTF_STRING_ENCODING_NONE
);
205 ret
= bt_ctf_field_type_set_byte_order(root_iron_dust
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
207 ret
= bt_ctf_field_type_set_alignment(root_iron_dust
, 1);
209 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_dust
, "dust");
211 root_iron_parallel_int
= bt_ctf_field_type_integer_create(10);
212 assert(root_iron_parallel_int
);
213 ret
= bt_ctf_field_type_integer_set_signed(root_iron_parallel_int
, 0);
215 ret
= bt_ctf_field_type_integer_set_base(root_iron_parallel_int
, 10);
217 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_parallel_int
, BT_CTF_STRING_ENCODING_NONE
);
219 ret
= bt_ctf_field_type_set_byte_order(root_iron_parallel_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
221 ret
= bt_ctf_field_type_set_alignment(root_iron_parallel_int
, 1);
223 root_iron_parallel
= bt_ctf_field_type_enumeration_create(root_iron_parallel_int
);
224 assert(root_iron_parallel
);
225 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "RED", 0, 0);
227 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "BLUE", 1, 1);
229 ret
= bt_ctf_field_type_enumeration_add_mapping(root_iron_parallel
, "YELLOW", 2, 2);
231 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_parallel
, "parallel");
233 root_iron_fire
= bt_ctf_field_type_structure_create();
234 assert(root_iron_fire
);
235 ret
= bt_ctf_field_type_set_alignment(root_iron_fire
, 8);
237 root_iron_fire_word
= bt_ctf_field_type_integer_create(17);
238 assert(root_iron_fire_word
);
239 ret
= bt_ctf_field_type_integer_set_signed(root_iron_fire_word
, 0);
241 ret
= bt_ctf_field_type_integer_set_base(root_iron_fire_word
, 10);
243 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_fire_word
, BT_CTF_STRING_ENCODING_NONE
);
245 ret
= bt_ctf_field_type_set_byte_order(root_iron_fire_word
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
247 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_word
, 1);
249 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_word
, "word");
251 root_iron_fire_rabbit
= bt_ctf_field_type_string_create();
252 assert(root_iron_fire_rabbit
);
253 ret
= bt_ctf_field_type_string_set_encoding(root_iron_fire_rabbit
, BT_CTF_STRING_ENCODING_UTF8
);
255 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_rabbit
, "rabbit");
257 root_iron_fire_keen_elem
= bt_ctf_field_type_variant_create(NULL
, "iron.parallel");
258 assert(root_iron_fire_keen_elem
);
259 root_iron_fire_keen_elem_RED
= bt_ctf_field_type_string_create();
260 assert(root_iron_fire_keen_elem_RED
);
261 ret
= bt_ctf_field_type_string_set_encoding(root_iron_fire_keen_elem_RED
, BT_CTF_STRING_ENCODING_UTF8
);
263 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_RED
, "RED");
265 root_iron_fire_keen_elem_BLUE_elem
= bt_ctf_field_type_integer_create(5);
266 assert(root_iron_fire_keen_elem_BLUE_elem
);
267 ret
= bt_ctf_field_type_integer_set_signed(root_iron_fire_keen_elem_BLUE_elem
, 0);
269 ret
= bt_ctf_field_type_integer_set_base(root_iron_fire_keen_elem_BLUE_elem
, 10);
271 ret
= bt_ctf_field_type_integer_set_encoding(root_iron_fire_keen_elem_BLUE_elem
, BT_CTF_STRING_ENCODING_NONE
);
273 ret
= bt_ctf_field_type_set_byte_order(root_iron_fire_keen_elem_BLUE_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
275 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_keen_elem_BLUE_elem
, 1);
277 root_iron_fire_keen_elem_BLUE
= bt_ctf_field_type_sequence_create(root_iron_fire_keen_elem_BLUE_elem
, "magic");
278 assert(root_iron_fire_keen_elem_BLUE
);
279 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_BLUE
, "BLUE");
281 root_iron_fire_keen_elem_YELLOW
= bt_ctf_field_type_structure_create();
282 assert(root_iron_fire_keen_elem_YELLOW
);
283 ret
= bt_ctf_field_type_set_alignment(root_iron_fire_keen_elem_YELLOW
, 1);
285 ret
= bt_ctf_field_type_variant_add_field(root_iron_fire_keen_elem
, root_iron_fire_keen_elem_YELLOW
, "YELLOW");
287 root_iron_fire_keen
= bt_ctf_field_type_sequence_create(root_iron_fire_keen_elem
, "word");
288 assert(root_iron_fire_keen
);
289 ret
= bt_ctf_field_type_structure_add_field(root_iron_fire
, root_iron_fire_keen
, "keen");
291 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_fire
, "fire");
293 root_iron_report_elem
= bt_ctf_field_type_string_create();
294 assert(root_iron_report_elem
);
295 ret
= bt_ctf_field_type_string_set_encoding(root_iron_report_elem
, BT_CTF_STRING_ENCODING_UTF8
);
297 root_iron_report
= bt_ctf_field_type_sequence_create(root_iron_report_elem
, "trace.packet.header.iron.dust");
298 assert(root_iron_report
);
299 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_report
, "report");
301 root_iron_group_elem
= bt_ctf_field_type_string_create();
302 assert(root_iron_group_elem
);
303 ret
= bt_ctf_field_type_string_set_encoding(root_iron_group_elem
, BT_CTF_STRING_ENCODING_UTF8
);
305 root_iron_group
= bt_ctf_field_type_sequence_create(root_iron_group_elem
, "trace.packet.header.stream_id");
306 assert(root_iron_group
);
307 ret
= bt_ctf_field_type_structure_add_field(root_iron
, root_iron_group
, "group");
309 ret
= bt_ctf_field_type_structure_add_field(root
, root_iron
, "iron");
311 root_serious
= bt_ctf_field_type_integer_create(1);
312 assert(root_serious
);
313 ret
= bt_ctf_field_type_integer_set_signed(root_serious
, 0);
315 ret
= bt_ctf_field_type_integer_set_base(root_serious
, 10);
317 ret
= bt_ctf_field_type_integer_set_encoding(root_serious
, BT_CTF_STRING_ENCODING_NONE
);
319 ret
= bt_ctf_field_type_set_byte_order(root_serious
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
321 ret
= bt_ctf_field_type_set_alignment(root_serious
, 1);
323 ret
= bt_ctf_field_type_structure_add_field(root
, root_serious
, "serious");
328 BT_PUT(root_uuid_elem
);
329 BT_PUT(root_stream_id
);
331 BT_PUT(root_iron_listen
);
332 BT_PUT(root_iron_dust
);
333 BT_PUT(root_iron_parallel
);
334 BT_PUT(root_iron_parallel_int
);
335 BT_PUT(root_iron_fire
);
336 BT_PUT(root_iron_fire_word
);
337 BT_PUT(root_iron_fire_rabbit
);
338 BT_PUT(root_iron_fire_keen
);
339 BT_PUT(root_iron_fire_keen_elem
);
340 BT_PUT(root_iron_fire_keen_elem_RED
);
341 BT_PUT(root_iron_fire_keen_elem_BLUE
);
342 BT_PUT(root_iron_fire_keen_elem_BLUE_elem
);
343 BT_PUT(root_iron_fire_keen_elem_YELLOW
);
344 BT_PUT(root_iron_report
);
345 BT_PUT(root_iron_report_elem
);
346 BT_PUT(root_iron_group
);
347 BT_PUT(root_iron_group_elem
);
348 BT_PUT(root_serious
);
354 struct bt_ctf_field_type
*get_good_packet_context_type(void)
357 Generated by bt-ctfirtg using the following input:
389 length: trace.packet.header.iron.fire.word
399 length: stream.packet.context.clover.oval
422 struct bt_ctf_field_type
*root
= NULL
;
423 struct bt_ctf_field_type
*root_placid
= NULL
;
424 struct bt_ctf_field_type
*root_meow
= NULL
;
425 struct bt_ctf_field_type
*root_serious
= NULL
;
426 struct bt_ctf_field_type
*root_naive
= NULL
;
427 struct bt_ctf_field_type
*root_naive_elem
= NULL
;
428 struct bt_ctf_field_type
*root_naive_elem_elem
= NULL
;
429 struct bt_ctf_field_type
*root_clover
= NULL
;
430 struct bt_ctf_field_type
*root_clover_oval
= NULL
;
431 struct bt_ctf_field_type
*root_clover_whole
= NULL
;
432 struct bt_ctf_field_type
*root_clover_whole_BLUE
= NULL
;
433 struct bt_ctf_field_type
*root_clover_whole_BLUE_elem
= NULL
;
434 struct bt_ctf_field_type
*root_clover_whole_RED
= NULL
;
435 struct bt_ctf_field_type
*root_clover_whole_YELLOW
= NULL
;
436 struct bt_ctf_field_type
*root_clover_egg
= NULL
;
437 struct bt_ctf_field_type
*root_clover_egg_elem
= NULL
;
438 struct bt_ctf_field_type
*root_clover_square
= NULL
;
439 struct bt_ctf_field_type
*root_clover_square_int
= NULL
;
440 struct bt_ctf_field_type
*root_clover_useful
= NULL
;
441 struct bt_ctf_field_type
*root_clover_useful_elem
= NULL
;
442 struct bt_ctf_field_type
*root_tart
= NULL
;
445 root
= bt_ctf_field_type_structure_create();
447 ret
= bt_ctf_field_type_set_alignment(root
, 8);
449 root_placid
= bt_ctf_field_type_integer_create(32);
451 ret
= bt_ctf_field_type_integer_set_signed(root_placid
, 0);
453 ret
= bt_ctf_field_type_integer_set_base(root_placid
, 10);
455 ret
= bt_ctf_field_type_integer_set_encoding(root_placid
, BT_CTF_STRING_ENCODING_NONE
);
457 ret
= bt_ctf_field_type_set_byte_order(root_placid
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
459 ret
= bt_ctf_field_type_set_alignment(root_placid
, 8);
461 ret
= bt_ctf_field_type_structure_add_field(root
, root_placid
, "placid");
463 root_meow
= bt_ctf_field_type_string_create();
465 ret
= bt_ctf_field_type_string_set_encoding(root_meow
, BT_CTF_STRING_ENCODING_UTF8
);
467 ret
= bt_ctf_field_type_structure_add_field(root
, root_meow
, "meow");
469 root_serious
= bt_ctf_field_type_integer_create(11);
470 assert(root_serious
);
471 ret
= bt_ctf_field_type_integer_set_signed(root_serious
, 0);
473 ret
= bt_ctf_field_type_integer_set_base(root_serious
, 10);
475 ret
= bt_ctf_field_type_integer_set_encoding(root_serious
, BT_CTF_STRING_ENCODING_NONE
);
477 ret
= bt_ctf_field_type_set_byte_order(root_serious
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
479 ret
= bt_ctf_field_type_set_alignment(root_serious
, 1);
481 ret
= bt_ctf_field_type_structure_add_field(root
, root_serious
, "serious");
483 root_naive_elem_elem
= bt_ctf_field_type_string_create();
484 assert(root_naive_elem_elem
);
485 ret
= bt_ctf_field_type_string_set_encoding(root_naive_elem_elem
, BT_CTF_STRING_ENCODING_UTF8
);
487 root_naive_elem
= bt_ctf_field_type_sequence_create(root_naive_elem_elem
, "placid");
488 assert(root_naive_elem
);
489 root_naive
= bt_ctf_field_type_array_create(root_naive_elem
, 17);
491 ret
= bt_ctf_field_type_structure_add_field(root
, root_naive
, "naive");
493 root_clover
= bt_ctf_field_type_structure_create();
495 ret
= bt_ctf_field_type_set_alignment(root_clover
, 1);
497 root_clover_oval
= bt_ctf_field_type_integer_create(17);
498 assert(root_clover_oval
);
499 ret
= bt_ctf_field_type_integer_set_signed(root_clover_oval
, 0);
501 ret
= bt_ctf_field_type_integer_set_base(root_clover_oval
, 10);
503 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_oval
, BT_CTF_STRING_ENCODING_NONE
);
505 ret
= bt_ctf_field_type_set_byte_order(root_clover_oval
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
507 ret
= bt_ctf_field_type_set_alignment(root_clover_oval
, 1);
509 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_oval
, "oval");
511 root_clover_whole
= bt_ctf_field_type_variant_create(NULL
, "iron.parallel");
512 assert(root_clover_whole
);
513 root_clover_whole_BLUE_elem
= bt_ctf_field_type_string_create();
514 assert(root_clover_whole_BLUE_elem
);
515 ret
= bt_ctf_field_type_string_set_encoding(root_clover_whole_BLUE_elem
, BT_CTF_STRING_ENCODING_UTF8
);
517 root_clover_whole_BLUE
= bt_ctf_field_type_sequence_create(root_clover_whole_BLUE_elem
, "trace.packet.header.iron.fire.word");
518 assert(root_clover_whole_BLUE
);
519 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_BLUE
, "BLUE");
521 root_clover_whole_RED
= bt_ctf_field_type_integer_create(44);
522 assert(root_clover_whole_RED
);
523 ret
= bt_ctf_field_type_integer_set_signed(root_clover_whole_RED
, 0);
525 ret
= bt_ctf_field_type_integer_set_base(root_clover_whole_RED
, 10);
527 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_whole_RED
, BT_CTF_STRING_ENCODING_NONE
);
529 ret
= bt_ctf_field_type_set_byte_order(root_clover_whole_RED
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
531 ret
= bt_ctf_field_type_set_alignment(root_clover_whole_RED
, 1);
533 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_RED
, "RED");
535 root_clover_whole_YELLOW
= bt_ctf_field_type_string_create();
536 assert(root_clover_whole_YELLOW
);
537 ret
= bt_ctf_field_type_string_set_encoding(root_clover_whole_YELLOW
, BT_CTF_STRING_ENCODING_UTF8
);
539 ret
= bt_ctf_field_type_variant_add_field(root_clover_whole
, root_clover_whole_YELLOW
, "YELLOW");
541 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_whole
, "whole");
543 root_clover_egg_elem
= bt_ctf_field_type_integer_create(55);
544 assert(root_clover_egg_elem
);
545 ret
= bt_ctf_field_type_integer_set_signed(root_clover_egg_elem
, 0);
547 ret
= bt_ctf_field_type_integer_set_base(root_clover_egg_elem
, 10);
549 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_egg_elem
, BT_CTF_STRING_ENCODING_NONE
);
551 ret
= bt_ctf_field_type_set_byte_order(root_clover_egg_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
553 ret
= bt_ctf_field_type_set_alignment(root_clover_egg_elem
, 1);
555 root_clover_egg
= bt_ctf_field_type_sequence_create(root_clover_egg_elem
, "stream.packet.context.clover.oval");
556 assert(root_clover_egg
);
557 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_egg
, "egg");
559 root_clover_square_int
= bt_ctf_field_type_integer_create(12);
560 assert(root_clover_square_int
);
561 ret
= bt_ctf_field_type_integer_set_signed(root_clover_square_int
, 0);
563 ret
= bt_ctf_field_type_integer_set_base(root_clover_square_int
, 10);
565 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_square_int
, BT_CTF_STRING_ENCODING_NONE
);
567 ret
= bt_ctf_field_type_set_byte_order(root_clover_square_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
569 ret
= bt_ctf_field_type_set_alignment(root_clover_square_int
, 1);
571 root_clover_square
= bt_ctf_field_type_enumeration_create(root_clover_square_int
);
572 assert(root_clover_square
);
573 ret
= bt_ctf_field_type_enumeration_add_mapping(root_clover_square
, "YOUNG", 0, 0);
575 ret
= bt_ctf_field_type_enumeration_add_mapping(root_clover_square
, "OLD", 1, 1);
577 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_square
, "square");
579 root_clover_useful_elem
= bt_ctf_field_type_integer_create(2);
580 assert(root_clover_useful_elem
);
581 ret
= bt_ctf_field_type_integer_set_signed(root_clover_useful_elem
, 0);
583 ret
= bt_ctf_field_type_integer_set_base(root_clover_useful_elem
, 10);
585 ret
= bt_ctf_field_type_integer_set_encoding(root_clover_useful_elem
, BT_CTF_STRING_ENCODING_NONE
);
587 ret
= bt_ctf_field_type_set_byte_order(root_clover_useful_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
589 ret
= bt_ctf_field_type_set_alignment(root_clover_useful_elem
, 1);
591 root_clover_useful
= bt_ctf_field_type_sequence_create(root_clover_useful_elem
, "serious");
592 assert(root_clover_useful
);
593 ret
= bt_ctf_field_type_structure_add_field(root_clover
, root_clover_useful
, "useful");
595 ret
= bt_ctf_field_type_structure_add_field(root
, root_clover
, "clover");
597 root_tart
= bt_ctf_field_type_string_create();
599 ret
= bt_ctf_field_type_string_set_encoding(root_tart
, BT_CTF_STRING_ENCODING_UTF8
);
601 ret
= bt_ctf_field_type_structure_add_field(root
, root_tart
, "tart");
606 BT_PUT(root_serious
);
608 BT_PUT(root_naive_elem
);
609 BT_PUT(root_naive_elem_elem
);
611 BT_PUT(root_clover_oval
);
612 BT_PUT(root_clover_whole
);
613 BT_PUT(root_clover_whole_BLUE
);
614 BT_PUT(root_clover_whole_BLUE_elem
);
615 BT_PUT(root_clover_whole_RED
);
616 BT_PUT(root_clover_whole_YELLOW
);
617 BT_PUT(root_clover_egg
);
618 BT_PUT(root_clover_egg_elem
);
619 BT_PUT(root_clover_square
);
620 BT_PUT(root_clover_square_int
);
621 BT_PUT(root_clover_useful
);
622 BT_PUT(root_clover_useful_elem
);
630 struct bt_ctf_field_type
*get_good_event_header_type(void)
633 Generated by bt-ctfirtg using the following input:
651 length: stream.packet.context.placid
658 length: trace.packet.header.serious
664 length: clover.whole.RED
672 length: action.special
679 struct bt_ctf_field_type
*root
= NULL
;
680 struct bt_ctf_field_type
*root_id
= NULL
;
681 struct bt_ctf_field_type
*root_timestamp
= NULL
;
682 struct bt_ctf_field_type
*root_action
= NULL
;
683 struct bt_ctf_field_type
*root_action_special
= NULL
;
684 struct bt_ctf_field_type
*root_action_lucky
= NULL
;
685 struct bt_ctf_field_type
*root_action_lucky_elem
= NULL
;
686 struct bt_ctf_field_type
*root_action_dream
= NULL
;
687 struct bt_ctf_field_type
*root_action_grandiose
= NULL
;
688 struct bt_ctf_field_type
*root_action_grandiose_elem
= NULL
;
689 struct bt_ctf_field_type
*root_stiff
= NULL
;
690 struct bt_ctf_field_type
*root_stiff_elem
= NULL
;
691 struct bt_ctf_field_type
*root_fruit
= NULL
;
692 struct bt_ctf_field_type
*root_fruit_apple
= NULL
;
693 struct bt_ctf_field_type
*root_fruit_apple_elem
= NULL
;
696 root
= bt_ctf_field_type_structure_create();
698 ret
= bt_ctf_field_type_set_alignment(root
, 8);
700 root_id
= bt_ctf_field_type_integer_create(17);
702 ret
= bt_ctf_field_type_integer_set_signed(root_id
, 0);
704 ret
= bt_ctf_field_type_integer_set_base(root_id
, 10);
706 ret
= bt_ctf_field_type_integer_set_encoding(root_id
, BT_CTF_STRING_ENCODING_NONE
);
708 ret
= bt_ctf_field_type_set_byte_order(root_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
710 ret
= bt_ctf_field_type_set_alignment(root_id
, 1);
712 ret
= bt_ctf_field_type_structure_add_field(root
, root_id
, "id");
714 root_timestamp
= bt_ctf_field_type_integer_create(64);
715 assert(root_timestamp
);
716 ret
= bt_ctf_field_type_integer_set_signed(root_timestamp
, 0);
718 ret
= bt_ctf_field_type_integer_set_base(root_timestamp
, 10);
720 ret
= bt_ctf_field_type_integer_set_encoding(root_timestamp
, BT_CTF_STRING_ENCODING_NONE
);
722 ret
= bt_ctf_field_type_set_byte_order(root_timestamp
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
724 ret
= bt_ctf_field_type_set_alignment(root_timestamp
, 8);
726 ret
= bt_ctf_field_type_structure_add_field(root
, root_timestamp
, "timestamp");
728 root_action
= bt_ctf_field_type_structure_create();
730 ret
= bt_ctf_field_type_set_alignment(root_action
, 8);
732 root_action_special
= bt_ctf_field_type_integer_create(17);
733 assert(root_action_special
);
734 ret
= bt_ctf_field_type_integer_set_signed(root_action_special
, 0);
736 ret
= bt_ctf_field_type_integer_set_base(root_action_special
, 10);
738 ret
= bt_ctf_field_type_integer_set_encoding(root_action_special
, BT_CTF_STRING_ENCODING_NONE
);
740 ret
= bt_ctf_field_type_set_byte_order(root_action_special
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
742 ret
= bt_ctf_field_type_set_alignment(root_action_special
, 1);
744 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_special
, "special");
746 root_action_lucky_elem
= bt_ctf_field_type_string_create();
747 assert(root_action_lucky_elem
);
748 ret
= bt_ctf_field_type_string_set_encoding(root_action_lucky_elem
, BT_CTF_STRING_ENCODING_UTF8
);
750 root_action_lucky
= bt_ctf_field_type_sequence_create(root_action_lucky_elem
, "stream.packet.context.placid");
751 assert(root_action_lucky
);
752 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_lucky
, "lucky");
754 root_action_dream
= bt_ctf_field_type_string_create();
755 assert(root_action_dream
);
756 ret
= bt_ctf_field_type_string_set_encoding(root_action_dream
, BT_CTF_STRING_ENCODING_UTF8
);
758 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_dream
, "dream");
760 root_action_grandiose_elem
= bt_ctf_field_type_integer_create(3);
761 assert(root_action_grandiose_elem
);
762 ret
= bt_ctf_field_type_integer_set_signed(root_action_grandiose_elem
, 0);
764 ret
= bt_ctf_field_type_integer_set_base(root_action_grandiose_elem
, 10);
766 ret
= bt_ctf_field_type_integer_set_encoding(root_action_grandiose_elem
, BT_CTF_STRING_ENCODING_NONE
);
768 ret
= bt_ctf_field_type_set_byte_order(root_action_grandiose_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
770 ret
= bt_ctf_field_type_set_alignment(root_action_grandiose_elem
, 1);
772 root_action_grandiose
= bt_ctf_field_type_sequence_create(root_action_grandiose_elem
, "trace.packet.header.serious");
773 assert(root_action_grandiose
);
774 ret
= bt_ctf_field_type_structure_add_field(root_action
, root_action_grandiose
, "grandiose");
776 ret
= bt_ctf_field_type_structure_add_field(root
, root_action
, "action");
778 root_stiff_elem
= bt_ctf_field_type_string_create();
779 assert(root_stiff_elem
);
780 ret
= bt_ctf_field_type_string_set_encoding(root_stiff_elem
, BT_CTF_STRING_ENCODING_UTF8
);
782 root_stiff
= bt_ctf_field_type_sequence_create(root_stiff_elem
, "clover.whole.RED");
784 ret
= bt_ctf_field_type_structure_add_field(root
, root_stiff
, "stiff");
786 root_fruit
= bt_ctf_field_type_structure_create();
788 ret
= bt_ctf_field_type_set_alignment(root_fruit
, 1);
790 root_fruit_apple_elem
= bt_ctf_field_type_integer_create(5);
791 assert(root_fruit_apple_elem
);
792 ret
= bt_ctf_field_type_integer_set_signed(root_fruit_apple_elem
, 0);
794 ret
= bt_ctf_field_type_integer_set_base(root_fruit_apple_elem
, 10);
796 ret
= bt_ctf_field_type_integer_set_encoding(root_fruit_apple_elem
, BT_CTF_STRING_ENCODING_NONE
);
798 ret
= bt_ctf_field_type_set_byte_order(root_fruit_apple_elem
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
800 ret
= bt_ctf_field_type_set_alignment(root_fruit_apple_elem
, 1);
802 root_fruit_apple
= bt_ctf_field_type_sequence_create(root_fruit_apple_elem
, "action.special");
803 assert(root_fruit_apple
);
804 ret
= bt_ctf_field_type_structure_add_field(root_fruit
, root_fruit_apple
, "apple");
806 ret
= bt_ctf_field_type_structure_add_field(root
, root_fruit
, "fruit");
810 BT_PUT(root_timestamp
);
812 BT_PUT(root_action_special
);
813 BT_PUT(root_action_lucky
);
814 BT_PUT(root_action_lucky_elem
);
815 BT_PUT(root_action_dream
);
816 BT_PUT(root_action_grandiose
);
817 BT_PUT(root_action_grandiose_elem
);
819 BT_PUT(root_stiff_elem
);
821 BT_PUT(root_fruit_apple
);
822 BT_PUT(root_fruit_apple_elem
);
828 struct bt_ctf_field_type
*get_good_stream_event_context_type(void)
831 Generated by bt-ctfirtg using the following input:
861 length: stream.packet.context.placid
864 length: trace.packet.header.iron.dust
867 length: stream.event.context.face.magic
876 struct bt_ctf_field_type
*root
= NULL
;
877 struct bt_ctf_field_type
*root_face
= NULL
;
878 struct bt_ctf_field_type
*root_face_branch
= NULL
;
879 struct bt_ctf_field_type
*root_face_branch_elem
= NULL
;
880 struct bt_ctf_field_type
*root_face_income
= NULL
;
881 struct bt_ctf_field_type
*root_face_income_elem
= NULL
;
882 struct bt_ctf_field_type
*root_face_magic
= NULL
;
883 struct bt_ctf_field_type
*root_face_lucky
= NULL
;
884 struct bt_ctf_field_type
*root_face_lucky_elem
= NULL
;
885 struct bt_ctf_field_type
*root_cats
= NULL
;
886 struct bt_ctf_field_type
*root_dream
= NULL
;
887 struct bt_ctf_field_type
*root_dream_elem
= NULL
;
888 struct bt_ctf_field_type
*root_dream_elem_elem
= NULL
;
889 struct bt_ctf_field_type
*root_dream_elem_elem_elem
= NULL
;
890 struct bt_ctf_field_type
*root_stream_id
= NULL
;
893 root
= bt_ctf_field_type_structure_create();
895 ret
= bt_ctf_field_type_set_alignment(root
, 8);
897 root_face
= bt_ctf_field_type_structure_create();
899 ret
= bt_ctf_field_type_set_alignment(root_face
, 8);
901 root_face_branch_elem
= bt_ctf_field_type_string_create();
902 assert(root_face_branch_elem
);
903 ret
= bt_ctf_field_type_string_set_encoding(root_face_branch_elem
, BT_CTF_STRING_ENCODING_UTF8
);
905 root_face_branch
= bt_ctf_field_type_sequence_create(root_face_branch_elem
, "serious");
906 assert(root_face_branch
);
907 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_branch
, "branch");
909 root_face_income_elem
= bt_ctf_field_type_string_create();
910 assert(root_face_income_elem
);
911 ret
= bt_ctf_field_type_string_set_encoding(root_face_income_elem
, BT_CTF_STRING_ENCODING_UTF8
);
913 root_face_income
= bt_ctf_field_type_sequence_create(root_face_income_elem
, "magic");
914 assert(root_face_income
);
915 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_income
, "income");
917 root_face_magic
= bt_ctf_field_type_integer_create(23);
918 assert(root_face_magic
);
919 ret
= bt_ctf_field_type_integer_set_signed(root_face_magic
, 0);
921 ret
= bt_ctf_field_type_integer_set_base(root_face_magic
, 10);
923 ret
= bt_ctf_field_type_integer_set_encoding(root_face_magic
, BT_CTF_STRING_ENCODING_NONE
);
925 ret
= bt_ctf_field_type_set_byte_order(root_face_magic
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
927 ret
= bt_ctf_field_type_set_alignment(root_face_magic
, 1);
929 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_magic
, "magic");
931 root_face_lucky_elem
= bt_ctf_field_type_string_create();
932 assert(root_face_lucky_elem
);
933 ret
= bt_ctf_field_type_string_set_encoding(root_face_lucky_elem
, BT_CTF_STRING_ENCODING_UTF8
);
935 root_face_lucky
= bt_ctf_field_type_sequence_create(root_face_lucky_elem
, "magic");
936 assert(root_face_lucky
);
937 ret
= bt_ctf_field_type_structure_add_field(root_face
, root_face_lucky
, "lucky");
939 ret
= bt_ctf_field_type_structure_add_field(root
, root_face
, "face");
941 root_cats
= bt_ctf_field_type_integer_create(5);
943 ret
= bt_ctf_field_type_integer_set_signed(root_cats
, 0);
945 ret
= bt_ctf_field_type_integer_set_base(root_cats
, 10);
947 ret
= bt_ctf_field_type_integer_set_encoding(root_cats
, BT_CTF_STRING_ENCODING_NONE
);
949 ret
= bt_ctf_field_type_set_byte_order(root_cats
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
951 ret
= bt_ctf_field_type_set_alignment(root_cats
, 1);
953 ret
= bt_ctf_field_type_structure_add_field(root
, root_cats
, "cats");
955 root_dream_elem_elem_elem
= bt_ctf_field_type_string_create();
956 assert(root_dream_elem_elem_elem
);
957 ret
= bt_ctf_field_type_string_set_encoding(root_dream_elem_elem_elem
, BT_CTF_STRING_ENCODING_UTF8
);
959 root_dream_elem_elem
= bt_ctf_field_type_sequence_create(root_dream_elem_elem_elem
, "stream.event.context.face.magic");
960 assert(root_dream_elem_elem
);
961 root_dream_elem
= bt_ctf_field_type_sequence_create(root_dream_elem_elem
, "trace.packet.header.iron.dust");
962 assert(root_dream_elem
);
963 root_dream
= bt_ctf_field_type_sequence_create(root_dream_elem
, "stream.packet.context.placid");
965 ret
= bt_ctf_field_type_structure_add_field(root
, root_dream
, "dream");
967 root_stream_id
= bt_ctf_field_type_integer_create(9);
968 assert(root_stream_id
);
969 ret
= bt_ctf_field_type_integer_set_signed(root_stream_id
, 0);
971 ret
= bt_ctf_field_type_integer_set_base(root_stream_id
, 10);
973 ret
= bt_ctf_field_type_integer_set_encoding(root_stream_id
, BT_CTF_STRING_ENCODING_NONE
);
975 ret
= bt_ctf_field_type_set_byte_order(root_stream_id
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
977 ret
= bt_ctf_field_type_set_alignment(root_stream_id
, 1);
979 ret
= bt_ctf_field_type_structure_add_field(root
, root_stream_id
, "stream_id");
983 BT_PUT(root_face_branch
);
984 BT_PUT(root_face_branch_elem
);
985 BT_PUT(root_face_income
);
986 BT_PUT(root_face_income_elem
);
987 BT_PUT(root_face_magic
);
988 BT_PUT(root_face_lucky
);
989 BT_PUT(root_face_lucky_elem
);
992 BT_PUT(root_dream_elem
);
993 BT_PUT(root_dream_elem_elem
);
994 BT_PUT(root_dream_elem_elem_elem
);
995 BT_PUT(root_stream_id
);
1001 struct bt_ctf_field_type
*get_good_event_context_type(void)
1004 Generated by bt-ctfirtg using the following input:
1026 length: action.special
1039 length: iron.fire.word
1050 length: trace.packet.header.iron.fire.word
1055 length: stream.packet.context.clover.oval
1060 length: stream.event.header.action.special
1065 length: stream.event.context.face.magic
1075 length: event.context.film
1081 struct bt_ctf_field_type
*root
= NULL
;
1082 struct bt_ctf_field_type
*root_film
= NULL
;
1083 struct bt_ctf_field_type
*root_berry
= NULL
;
1084 struct bt_ctf_field_type
*root_berry_pine
= NULL
;
1085 struct bt_ctf_field_type
*root_berry_pine_elem
= NULL
;
1086 struct bt_ctf_field_type
*root_berry_porter
= NULL
;
1087 struct bt_ctf_field_type
*root_berry_porter_elem
= NULL
;
1088 struct bt_ctf_field_type
*root_berry_mice
= NULL
;
1089 struct bt_ctf_field_type
*root_berry_mice_elem
= NULL
;
1090 struct bt_ctf_field_type
*root_berry_third
= NULL
;
1091 struct bt_ctf_field_type
*root_berry_guard
= NULL
;
1092 struct bt_ctf_field_type
*root_berry_guard_elem
= NULL
;
1093 struct bt_ctf_field_type
*root_berry_one
= NULL
;
1094 struct bt_ctf_field_type
*root_berry_one_elem
= NULL
;
1095 struct bt_ctf_field_type
*root_cats
= NULL
;
1096 struct bt_ctf_field_type
*root_loud
= NULL
;
1097 struct bt_ctf_field_type
*root_loud_toys
= NULL
;
1098 struct bt_ctf_field_type
*root_loud_toys_elem
= NULL
;
1099 struct bt_ctf_field_type
*root_loud_spoon
= NULL
;
1100 struct bt_ctf_field_type
*root_loud_spoon_elem
= NULL
;
1101 struct bt_ctf_field_type
*root_loud_turkey
= NULL
;
1102 struct bt_ctf_field_type
*root_loud_turkey_elem
= NULL
;
1103 struct bt_ctf_field_type
*root_loud_inform
= NULL
;
1104 struct bt_ctf_field_type
*root_loud_inform_elem
= NULL
;
1105 struct bt_ctf_field_type
*root_loud_odd
= NULL
;
1106 struct bt_ctf_field_type
*root_loud_odd_elem
= NULL
;
1107 struct bt_ctf_field_type
*root_loud_amuck
= NULL
;
1108 struct bt_ctf_field_type
*root_loud_amuck_elem
= NULL
;
1111 root
= bt_ctf_field_type_structure_create();
1113 ret
= bt_ctf_field_type_set_alignment(root
, 8);
1115 root_film
= bt_ctf_field_type_integer_create(19);
1117 ret
= bt_ctf_field_type_integer_set_signed(root_film
, 0);
1119 ret
= bt_ctf_field_type_integer_set_base(root_film
, 10);
1121 ret
= bt_ctf_field_type_integer_set_encoding(root_film
, BT_CTF_STRING_ENCODING_NONE
);
1123 ret
= bt_ctf_field_type_set_byte_order(root_film
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1125 ret
= bt_ctf_field_type_set_alignment(root_film
, 1);
1127 ret
= bt_ctf_field_type_structure_add_field(root
, root_film
, "film");
1129 root_berry
= bt_ctf_field_type_structure_create();
1131 ret
= bt_ctf_field_type_set_alignment(root_berry
, 8);
1133 root_berry_pine_elem
= bt_ctf_field_type_string_create();
1134 assert(root_berry_pine_elem
);
1135 ret
= bt_ctf_field_type_string_set_encoding(root_berry_pine_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1137 root_berry_pine
= bt_ctf_field_type_sequence_create(root_berry_pine_elem
, "stream_id");
1138 assert(root_berry_pine
);
1139 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_pine
, "pine");
1141 root_berry_porter_elem
= bt_ctf_field_type_string_create();
1142 assert(root_berry_porter_elem
);
1143 ret
= bt_ctf_field_type_string_set_encoding(root_berry_porter_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1145 root_berry_porter
= bt_ctf_field_type_sequence_create(root_berry_porter_elem
, "face.magic");
1146 assert(root_berry_porter
);
1147 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_porter
, "porter");
1149 root_berry_mice_elem
= bt_ctf_field_type_string_create();
1150 assert(root_berry_mice_elem
);
1151 ret
= bt_ctf_field_type_string_set_encoding(root_berry_mice_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1153 root_berry_mice
= bt_ctf_field_type_sequence_create(root_berry_mice_elem
, "action.special");
1154 assert(root_berry_mice
);
1155 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_mice
, "mice");
1157 root_berry_third
= bt_ctf_field_type_integer_create(18);
1158 assert(root_berry_third
);
1159 ret
= bt_ctf_field_type_integer_set_signed(root_berry_third
, 0);
1161 ret
= bt_ctf_field_type_integer_set_base(root_berry_third
, 10);
1163 ret
= bt_ctf_field_type_integer_set_encoding(root_berry_third
, BT_CTF_STRING_ENCODING_NONE
);
1165 ret
= bt_ctf_field_type_set_byte_order(root_berry_third
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1167 ret
= bt_ctf_field_type_set_alignment(root_berry_third
, 1);
1169 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_third
, "third");
1171 root_berry_guard_elem
= bt_ctf_field_type_string_create();
1172 assert(root_berry_guard_elem
);
1173 ret
= bt_ctf_field_type_string_set_encoding(root_berry_guard_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1175 root_berry_guard
= bt_ctf_field_type_sequence_create(root_berry_guard_elem
, "clover.oval");
1176 assert(root_berry_guard
);
1177 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_guard
, "guard");
1179 root_berry_one_elem
= bt_ctf_field_type_string_create();
1180 assert(root_berry_one_elem
);
1181 ret
= bt_ctf_field_type_string_set_encoding(root_berry_one_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1183 root_berry_one
= bt_ctf_field_type_sequence_create(root_berry_one_elem
, "iron.fire.word");
1184 assert(root_berry_one
);
1185 ret
= bt_ctf_field_type_structure_add_field(root_berry
, root_berry_one
, "one");
1187 ret
= bt_ctf_field_type_structure_add_field(root
, root_berry
, "berry");
1189 root_cats
= bt_ctf_field_type_integer_create(55);
1191 ret
= bt_ctf_field_type_integer_set_signed(root_cats
, 0);
1193 ret
= bt_ctf_field_type_integer_set_base(root_cats
, 10);
1195 ret
= bt_ctf_field_type_integer_set_encoding(root_cats
, BT_CTF_STRING_ENCODING_NONE
);
1197 ret
= bt_ctf_field_type_set_byte_order(root_cats
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1199 ret
= bt_ctf_field_type_set_alignment(root_cats
, 1);
1201 ret
= bt_ctf_field_type_structure_add_field(root
, root_cats
, "cats");
1203 root_loud
= bt_ctf_field_type_structure_create();
1205 ret
= bt_ctf_field_type_set_alignment(root_loud
, 8);
1207 root_loud_toys_elem
= bt_ctf_field_type_string_create();
1208 assert(root_loud_toys_elem
);
1209 ret
= bt_ctf_field_type_string_set_encoding(root_loud_toys_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1211 root_loud_toys
= bt_ctf_field_type_sequence_create(root_loud_toys_elem
, "trace.packet.header.iron.fire.word");
1212 assert(root_loud_toys
);
1213 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_toys
, "toys");
1215 root_loud_spoon_elem
= bt_ctf_field_type_string_create();
1216 assert(root_loud_spoon_elem
);
1217 ret
= bt_ctf_field_type_string_set_encoding(root_loud_spoon_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1219 root_loud_spoon
= bt_ctf_field_type_sequence_create(root_loud_spoon_elem
, "stream.packet.context.clover.oval");
1220 assert(root_loud_spoon
);
1221 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_spoon
, "spoon");
1223 root_loud_turkey_elem
= bt_ctf_field_type_string_create();
1224 assert(root_loud_turkey_elem
);
1225 ret
= bt_ctf_field_type_string_set_encoding(root_loud_turkey_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1227 root_loud_turkey
= bt_ctf_field_type_sequence_create(root_loud_turkey_elem
, "stream.event.header.action.special");
1228 assert(root_loud_turkey
);
1229 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_turkey
, "turkey");
1231 root_loud_inform_elem
= bt_ctf_field_type_string_create();
1232 assert(root_loud_inform_elem
);
1233 ret
= bt_ctf_field_type_string_set_encoding(root_loud_inform_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1235 root_loud_inform
= bt_ctf_field_type_sequence_create(root_loud_inform_elem
, "stream.event.context.face.magic");
1236 assert(root_loud_inform
);
1237 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_inform
, "inform");
1239 root_loud_odd_elem
= bt_ctf_field_type_string_create();
1240 assert(root_loud_odd_elem
);
1241 ret
= bt_ctf_field_type_string_set_encoding(root_loud_odd_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1243 root_loud_odd
= bt_ctf_field_type_sequence_create(root_loud_odd_elem
, "berry.third");
1244 assert(root_loud_odd
);
1245 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_odd
, "odd");
1247 root_loud_amuck_elem
= bt_ctf_field_type_string_create();
1248 assert(root_loud_amuck_elem
);
1249 ret
= bt_ctf_field_type_string_set_encoding(root_loud_amuck_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1251 root_loud_amuck
= bt_ctf_field_type_sequence_create(root_loud_amuck_elem
, "event.context.film");
1252 assert(root_loud_amuck
);
1253 ret
= bt_ctf_field_type_structure_add_field(root_loud
, root_loud_amuck
, "amuck");
1255 ret
= bt_ctf_field_type_structure_add_field(root
, root_loud
, "loud");
1260 BT_PUT(root_berry_pine
);
1261 BT_PUT(root_berry_pine_elem
);
1262 BT_PUT(root_berry_porter
);
1263 BT_PUT(root_berry_porter_elem
);
1264 BT_PUT(root_berry_mice
);
1265 BT_PUT(root_berry_mice_elem
);
1266 BT_PUT(root_berry_third
);
1267 BT_PUT(root_berry_guard
);
1268 BT_PUT(root_berry_guard_elem
);
1269 BT_PUT(root_berry_one
);
1270 BT_PUT(root_berry_one_elem
);
1273 BT_PUT(root_loud_toys
);
1274 BT_PUT(root_loud_toys_elem
);
1275 BT_PUT(root_loud_spoon
);
1276 BT_PUT(root_loud_spoon_elem
);
1277 BT_PUT(root_loud_turkey
);
1278 BT_PUT(root_loud_turkey_elem
);
1279 BT_PUT(root_loud_inform
);
1280 BT_PUT(root_loud_inform_elem
);
1281 BT_PUT(root_loud_odd
);
1282 BT_PUT(root_loud_odd_elem
);
1283 BT_PUT(root_loud_amuck
);
1284 BT_PUT(root_loud_amuck_elem
);
1290 struct bt_ctf_field_type
*get_good_event_payload_type(void)
1293 Generated by bt-ctfirtg using the following input:
1343 length: event.fields.splendid
1348 length: event.context.cats
1353 length: event.context.berry.third
1358 length: stream.event.context.face.magic
1363 length: stream.event.header.id
1368 length: stream.packet.context.serious
1373 length: trace.packet.header.iron.dust
1379 struct bt_ctf_field_type
*root
= NULL
;
1380 struct bt_ctf_field_type
*root_splendid
= NULL
;
1381 struct bt_ctf_field_type
*root_relative
= NULL
;
1382 struct bt_ctf_field_type
*root_relative_equal
= NULL
;
1383 struct bt_ctf_field_type
*root_relative_equal_elem
= NULL
;
1384 struct bt_ctf_field_type
*root_relative_amuck
= NULL
;
1385 struct bt_ctf_field_type
*root_relative_amuck_elem
= NULL
;
1386 struct bt_ctf_field_type
*root_relative_push
= NULL
;
1387 struct bt_ctf_field_type
*root_relative_push_elem
= NULL
;
1388 struct bt_ctf_field_type
*root_relative_brick
= NULL
;
1389 struct bt_ctf_field_type
*root_relative_brick_elem
= NULL
;
1390 struct bt_ctf_field_type
*root_relative_crush
= NULL
;
1391 struct bt_ctf_field_type
*root_relative_crush_elem
= NULL
;
1392 struct bt_ctf_field_type
*root_relative_canvas
= NULL
;
1393 struct bt_ctf_field_type
*root_relative_canvas_elem
= NULL
;
1394 struct bt_ctf_field_type
*root_absolute
= NULL
;
1395 struct bt_ctf_field_type
*root_absolute_equal
= NULL
;
1396 struct bt_ctf_field_type
*root_absolute_equal_elem
= NULL
;
1397 struct bt_ctf_field_type
*root_absolute_amuck
= NULL
;
1398 struct bt_ctf_field_type
*root_absolute_amuck_elem
= NULL
;
1399 struct bt_ctf_field_type
*root_absolute_push
= NULL
;
1400 struct bt_ctf_field_type
*root_absolute_push_elem
= NULL
;
1401 struct bt_ctf_field_type
*root_absolute_brick
= NULL
;
1402 struct bt_ctf_field_type
*root_absolute_brick_elem
= NULL
;
1403 struct bt_ctf_field_type
*root_absolute_crush
= NULL
;
1404 struct bt_ctf_field_type
*root_absolute_crush_elem
= NULL
;
1405 struct bt_ctf_field_type
*root_absolute_canvas
= NULL
;
1406 struct bt_ctf_field_type
*root_absolute_canvas_elem
= NULL
;
1409 root
= bt_ctf_field_type_structure_create();
1411 ret
= bt_ctf_field_type_set_alignment(root
, 8);
1413 root_splendid
= bt_ctf_field_type_integer_create(12);
1414 assert(root_splendid
);
1415 ret
= bt_ctf_field_type_integer_set_signed(root_splendid
, 0);
1417 ret
= bt_ctf_field_type_integer_set_base(root_splendid
, 10);
1419 ret
= bt_ctf_field_type_integer_set_encoding(root_splendid
, BT_CTF_STRING_ENCODING_NONE
);
1421 ret
= bt_ctf_field_type_set_byte_order(root_splendid
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
1423 ret
= bt_ctf_field_type_set_alignment(root_splendid
, 1);
1425 ret
= bt_ctf_field_type_structure_add_field(root
, root_splendid
, "splendid");
1427 root_relative
= bt_ctf_field_type_structure_create();
1428 assert(root_relative
);
1429 ret
= bt_ctf_field_type_set_alignment(root_relative
, 8);
1431 root_relative_equal_elem
= bt_ctf_field_type_string_create();
1432 assert(root_relative_equal_elem
);
1433 ret
= bt_ctf_field_type_string_set_encoding(root_relative_equal_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1435 root_relative_equal
= bt_ctf_field_type_sequence_create(root_relative_equal_elem
, "splendid");
1436 assert(root_relative_equal
);
1437 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_equal
, "equal");
1439 root_relative_amuck_elem
= bt_ctf_field_type_string_create();
1440 assert(root_relative_amuck_elem
);
1441 ret
= bt_ctf_field_type_string_set_encoding(root_relative_amuck_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1443 root_relative_amuck
= bt_ctf_field_type_sequence_create(root_relative_amuck_elem
, "id");
1444 assert(root_relative_amuck
);
1445 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_amuck
, "amuck");
1447 root_relative_push_elem
= bt_ctf_field_type_string_create();
1448 assert(root_relative_push_elem
);
1449 ret
= bt_ctf_field_type_string_set_encoding(root_relative_push_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1451 root_relative_push
= bt_ctf_field_type_sequence_create(root_relative_push_elem
, "berry.third");
1452 assert(root_relative_push
);
1453 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_push
, "push");
1455 root_relative_brick_elem
= bt_ctf_field_type_string_create();
1456 assert(root_relative_brick_elem
);
1457 ret
= bt_ctf_field_type_string_set_encoding(root_relative_brick_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1459 root_relative_brick
= bt_ctf_field_type_sequence_create(root_relative_brick_elem
, "face.magic");
1460 assert(root_relative_brick
);
1461 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_brick
, "brick");
1463 root_relative_crush_elem
= bt_ctf_field_type_string_create();
1464 assert(root_relative_crush_elem
);
1465 ret
= bt_ctf_field_type_string_set_encoding(root_relative_crush_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1467 root_relative_crush
= bt_ctf_field_type_sequence_create(root_relative_crush_elem
, "serious");
1468 assert(root_relative_crush
);
1469 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_crush
, "crush");
1471 root_relative_canvas_elem
= bt_ctf_field_type_string_create();
1472 assert(root_relative_canvas_elem
);
1473 ret
= bt_ctf_field_type_string_set_encoding(root_relative_canvas_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1475 root_relative_canvas
= bt_ctf_field_type_sequence_create(root_relative_canvas_elem
, "iron.dust");
1476 assert(root_relative_canvas
);
1477 ret
= bt_ctf_field_type_structure_add_field(root_relative
, root_relative_canvas
, "canvas");
1479 ret
= bt_ctf_field_type_structure_add_field(root
, root_relative
, "relative");
1481 root_absolute
= bt_ctf_field_type_structure_create();
1482 assert(root_absolute
);
1483 ret
= bt_ctf_field_type_set_alignment(root_absolute
, 8);
1485 root_absolute_equal_elem
= bt_ctf_field_type_string_create();
1486 assert(root_absolute_equal_elem
);
1487 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_equal_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1489 root_absolute_equal
= bt_ctf_field_type_sequence_create(root_absolute_equal_elem
, "event.fields.splendid");
1490 assert(root_absolute_equal
);
1491 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_equal
, "equal");
1493 root_absolute_amuck_elem
= bt_ctf_field_type_string_create();
1494 assert(root_absolute_amuck_elem
);
1495 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_amuck_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1497 root_absolute_amuck
= bt_ctf_field_type_sequence_create(root_absolute_amuck_elem
, "stream.event.header.id");
1498 assert(root_absolute_amuck
);
1499 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_amuck
, "amuck");
1501 root_absolute_push_elem
= bt_ctf_field_type_string_create();
1502 assert(root_absolute_push_elem
);
1503 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_push_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1505 root_absolute_push
= bt_ctf_field_type_sequence_create(root_absolute_push_elem
, "event.context.berry.third");
1506 assert(root_absolute_push
);
1507 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_push
, "push");
1509 root_absolute_brick_elem
= bt_ctf_field_type_string_create();
1510 assert(root_absolute_brick_elem
);
1511 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_brick_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1513 root_absolute_brick
= bt_ctf_field_type_sequence_create(root_absolute_brick_elem
, "stream.event.context.face.magic");
1514 assert(root_absolute_brick
);
1515 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_brick
, "brick");
1517 root_absolute_crush_elem
= bt_ctf_field_type_string_create();
1518 assert(root_absolute_crush_elem
);
1519 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_crush_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1521 root_absolute_crush
= bt_ctf_field_type_sequence_create(root_absolute_crush_elem
, "stream.packet.context.serious");
1522 assert(root_absolute_crush
);
1523 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_crush
, "crush");
1525 root_absolute_canvas_elem
= bt_ctf_field_type_string_create();
1526 assert(root_absolute_canvas_elem
);
1527 ret
= bt_ctf_field_type_string_set_encoding(root_absolute_canvas_elem
, BT_CTF_STRING_ENCODING_UTF8
);
1529 root_absolute_canvas
= bt_ctf_field_type_sequence_create(root_absolute_canvas_elem
, "trace.packet.header.iron.dust");
1530 assert(root_absolute_canvas
);
1531 ret
= bt_ctf_field_type_structure_add_field(root_absolute
, root_absolute_canvas
, "canvas");
1533 ret
= bt_ctf_field_type_structure_add_field(root
, root_absolute
, "absolute");
1536 BT_PUT(root_splendid
);
1537 BT_PUT(root_relative
);
1538 BT_PUT(root_relative_equal
);
1539 BT_PUT(root_relative_equal_elem
);
1540 BT_PUT(root_relative_amuck
);
1541 BT_PUT(root_relative_amuck_elem
);
1542 BT_PUT(root_relative_push
);
1543 BT_PUT(root_relative_push_elem
);
1544 BT_PUT(root_relative_brick
);
1545 BT_PUT(root_relative_brick_elem
);
1546 BT_PUT(root_relative_crush
);
1547 BT_PUT(root_relative_crush_elem
);
1548 BT_PUT(root_relative_canvas
);
1549 BT_PUT(root_relative_canvas_elem
);
1550 BT_PUT(root_absolute
);
1551 BT_PUT(root_absolute_equal
);
1552 BT_PUT(root_absolute_equal_elem
);
1553 BT_PUT(root_absolute_amuck
);
1554 BT_PUT(root_absolute_amuck_elem
);
1555 BT_PUT(root_absolute_push
);
1556 BT_PUT(root_absolute_push_elem
);
1557 BT_PUT(root_absolute_brick
);
1558 BT_PUT(root_absolute_brick_elem
);
1559 BT_PUT(root_absolute_crush
);
1560 BT_PUT(root_absolute_crush_elem
);
1561 BT_PUT(root_absolute_canvas
);
1562 BT_PUT(root_absolute_canvas_elem
);
1568 struct bt_ctf_field_type
*get_child_ft(struct bt_ctf_field_type
*parent_ft
,
1571 struct bt_ctf_field_type
*ft
= NULL
;
1573 switch (bt_ctf_field_type_get_type_id(parent_ft
)) {
1574 case CTF_TYPE_STRUCT
:
1575 ft
= bt_ctf_field_type_structure_get_field_type_by_name(
1579 case CTF_TYPE_VARIANT
:
1580 ft
= bt_ctf_field_type_variant_get_field_type_by_name(
1584 case CTF_TYPE_ARRAY
:
1585 ft
= bt_ctf_field_type_array_get_element_type(parent_ft
);
1588 case CTF_TYPE_SEQUENCE
:
1589 ft
= bt_ctf_field_type_sequence_get_element_type(parent_ft
);
1593 ft
= bt_ctf_field_type_enumeration_get_container_type(
1607 struct bt_ctf_field_type
*get_ft(struct bt_ctf_field_type
*root_ft
, ...)
1609 struct bt_ctf_field_type
*child_ft
= NULL
;
1610 struct bt_ctf_field_type
*ft
= root_ft
;
1613 va_start(ap
, root_ft
);
1617 const char *field_name
= va_arg(ap
, const char *);
1619 if (field_name
== NULL
) {
1623 child_ft
= get_child_ft(ft
, field_name
);
1630 BT_MOVE(ft
, child_ft
);
1639 #define FIELD_PATH_END -2
1642 int validate_field_path(struct bt_ctf_field_type
*field_type
, int int_root
, ...)
1644 enum bt_ctf_scope root
= int_root
;
1650 struct bt_ctf_field_path
*field_path
= NULL
;
1653 va_start(ap
, int_root
);
1654 if (bt_ctf_field_type_is_sequence(field_type
)) {
1655 field_path
= bt_ctf_field_type_sequence_get_length_field_path(
1657 } else if (bt_ctf_field_type_is_variant(field_type
)) {
1658 field_path
= bt_ctf_field_type_variant_get_tag_field_path(
1667 if (bt_ctf_field_path_get_root_scope(field_path
) != root
) {
1672 len
= bt_ctf_field_path_get_index_count(field_path
);
1675 expected_index
= va_arg(ap
, int);
1677 if (expected_index
== FIELD_PATH_END
) {
1685 actual_index
= bt_ctf_field_path_get_index(field_path
, i
);
1687 if (actual_index
== INT_MIN
) {
1695 if (i
!= len
|| expected_index
!= FIELD_PATH_END
) {
1707 void validate_test_pass(struct bt_ctf_trace
*trace
)
1709 struct bt_ctf_stream_class
*sc
;
1710 struct bt_ctf_event_class
*ec
;
1711 struct bt_ctf_field_type
*ph
;
1712 struct bt_ctf_field_type
*pc
;
1713 struct bt_ctf_field_type
*eh
;
1714 struct bt_ctf_field_type
*sec
;
1715 struct bt_ctf_field_type
*ectx
;
1716 struct bt_ctf_field_type
*ep
;
1717 struct bt_ctf_field_type
*ft_src
= NULL
;
1718 struct bt_ctf_field_type
*ft_target
= NULL
;
1719 struct bt_ctf_field_type
*ft_tag
= NULL
;
1721 sc
= bt_ctf_trace_get_stream_class_by_index(trace
, 0);
1723 ec
= bt_ctf_stream_class_get_event_class_by_index(sc
, 0);
1726 ph
= bt_ctf_trace_get_packet_header_type(trace
);
1727 ok(ph
, "Trace packet header still exists after successful validation");
1728 pc
= bt_ctf_stream_class_get_packet_context_type(sc
);
1729 ok(pc
, "Stream packet context still exists after successful validation");
1730 eh
= bt_ctf_stream_class_get_event_header_type(sc
);
1731 ok(eh
, "Stream event header still exists after successful validation");
1732 sec
= bt_ctf_stream_class_get_event_context_type(sc
);
1733 ok(sec
, "Stream event context still exists after successful validation");
1734 ectx
= bt_ctf_event_class_get_context_type(ec
);
1735 ok(ectx
, "Event context still exists after successful validation");
1736 ep
= bt_ctf_event_class_get_payload_type(ec
);
1737 ok(ep
, "Event payload still exists after successful validation");
1739 /* trace.packet.header.iron.fire.keen */
1740 ft_src
= get_ft(ph
, "iron", "fire", "keen", NULL
);
1741 ok(!validate_field_path(ft_src
, BT_CTF_SCOPE_TRACE_PACKET_HEADER
,
1742 3, 3, 0, FIELD_PATH_END
),
1743 "trace.packet.header.iron.fire.keen has the correct field path");
1746 /* trace.packet.header.iron.fire.keen.[element] */
1747 ft_src
= get_ft(ph
, "iron", "fire", "keen", "", NULL
);
1748 ok(!validate_field_path(ft_src
,
1749 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 2, FIELD_PATH_END
),
1750 "trace.packet.header.iron.fire.keen.[element] has the correct field path");
1751 ft_target
= get_ft(ph
, "iron", "parallel", NULL
);
1752 ft_tag
= bt_ctf_field_type_variant_get_tag_type(ft_src
);
1753 ok(ft_tag
== ft_target
,
1754 "trace.packet.header.iron.fire.keen.[element] has the correct tag type");
1759 /* trace.packet.header.iron.fire.keen.[element].BLUE */
1760 ft_src
= get_ft(ph
, "iron", "fire", "keen", "", "BLUE", NULL
);
1761 ok(!validate_field_path(ft_src
,
1762 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 0, FIELD_PATH_END
),
1763 "trace.packet.header.iron.fire.keen.[element].BLUE has the correct field path");
1766 /* trace.packet.header.iron.report */
1767 ft_src
= get_ft(ph
, "iron", "report", NULL
);
1768 ok(!validate_field_path(ft_src
,
1769 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
1770 "trace.packet.header.iron.report has the correct field path");
1773 /* trace.packet.header.iron.group */
1774 ft_src
= get_ft(ph
, "iron", "group", NULL
);
1775 ok(!validate_field_path(ft_src
,
1776 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 2, FIELD_PATH_END
),
1777 "trace.packet.header.iron.group has the correct field path");
1780 /* stream.packet.context.naive.[element] */
1781 ft_src
= get_ft(pc
, "naive", "", NULL
);
1782 ok(!validate_field_path(ft_src
,
1783 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1784 "stream.packet.context.naive.[element] has the correct field path");
1787 /* stream.packet.context.clover.whole */
1788 ft_src
= get_ft(pc
, "clover", "whole", NULL
);
1789 ok(!validate_field_path(ft_src
,
1790 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 2, FIELD_PATH_END
),
1791 "stream.packet.context.clover.whole has the correct field path");
1792 ft_target
= get_ft(ph
, "iron", "parallel", NULL
);
1793 ft_tag
= bt_ctf_field_type_variant_get_tag_type(ft_src
);
1794 ok(ft_tag
== ft_target
,
1795 "stream.packet.context.clover.whole has the correct tag type");
1800 /* stream.packet.context.clover.whole.BLUE */
1801 ft_src
= get_ft(pc
, "clover", "whole", "BLUE", NULL
);
1802 ok(!validate_field_path(ft_src
,
1803 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1804 "stream.packet.context.clover.whole.BLUE has the correct field path");
1807 /* stream.packet.context.clover.egg */
1808 ft_src
= get_ft(pc
, "clover", "egg", NULL
);
1809 ok(!validate_field_path(ft_src
,
1810 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1811 "stream.packet.context.clover.egg has the correct field path");
1814 /* stream.packet.context.clover.useful */
1815 ft_src
= get_ft(pc
, "clover", "useful", NULL
);
1816 ok(!validate_field_path(ft_src
,
1817 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1818 "stream.packet.context.clover.useful has the correct field path");
1821 /* stream.event.header.action.lucky */
1822 ft_src
= get_ft(eh
, "action", "lucky", NULL
);
1823 ok(!validate_field_path(ft_src
,
1824 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1825 "stream.event.header.action.lucky has the correct field path");
1828 /* stream.event.header.stiff */
1829 ft_src
= get_ft(eh
, "stiff", NULL
);
1830 ok(!validate_field_path(ft_src
,
1831 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 1, 1, FIELD_PATH_END
),
1832 "stream.event.header.stiff has the correct field path");
1835 /* stream.event.header.fruit.apple */
1836 ft_src
= get_ft(eh
, "fruit", "apple", NULL
);
1837 ok(!validate_field_path(ft_src
,
1838 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1839 "stream.event.header.fruit.apple has the correct field path");
1842 /* stream.event.context.face.branch */
1843 ft_src
= get_ft(sec
, "face", "branch", NULL
);
1844 ok(!validate_field_path(ft_src
,
1845 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1846 "stream.event.context.face.branch has the correct field path");
1849 /* stream.event.context.face.income */
1850 ft_src
= get_ft(sec
, "face", "income", NULL
);
1851 ok(!validate_field_path(ft_src
,
1852 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 0, FIELD_PATH_END
),
1853 "stream.event.context.face.income has the correct field path");
1856 /* stream.event.context.face.lucky */
1857 ft_src
= get_ft(sec
, "face", "lucky", NULL
);
1858 ok(!validate_field_path(ft_src
,
1859 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1860 "stream.event.context.face.lucky has the correct field path");
1863 /* stream.event.context.dream */
1864 ft_src
= get_ft(sec
, "dream", NULL
);
1865 ok(!validate_field_path(ft_src
,
1866 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 0, FIELD_PATH_END
),
1867 "stream.event.context.dream has the correct field path");
1870 /* stream.event.context.dream.[element] */
1871 ft_src
= get_ft(sec
, "dream", "", NULL
);
1872 ok(!validate_field_path(ft_src
,
1873 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
1874 "stream.event.context.dream.[element] has the correct field path");
1877 /* stream.event.context.dream.[element].[element] */
1878 ft_src
= get_ft(sec
, "dream", "", "", NULL
);
1879 ok(!validate_field_path(ft_src
,
1880 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1881 "stream.event.context.dream.[element].[element] has the correct field path");
1884 /* event.context.berry.porter */
1885 ft_src
= get_ft(ectx
, "berry", "porter", NULL
);
1886 ok(!validate_field_path(ft_src
,
1887 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1888 "event.context.berry.porter has the correct field path");
1891 /* event.context.berry.porter */
1892 ft_src
= get_ft(ectx
, "berry", "porter", NULL
);
1893 ok(!validate_field_path(ft_src
,
1894 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1895 "event.context.berry.porter has the correct field path");
1898 /* event.context.berry.mice */
1899 ft_src
= get_ft(ectx
, "berry", "mice", NULL
);
1900 ok(!validate_field_path(ft_src
,
1901 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1902 "event.context.berry.mice has the correct field path");
1905 /* event.context.berry.guard */
1906 ft_src
= get_ft(ectx
, "berry", "guard", NULL
);
1907 ok(!validate_field_path(ft_src
,
1908 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1909 "event.context.berry.guard has the correct field path");
1912 /* event.context.berry.one */
1913 ft_src
= get_ft(ectx
, "berry", "one", NULL
);
1914 ok(!validate_field_path(ft_src
,
1915 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1916 "event.context.berry.one has the correct field path");
1919 /* event.context.loud.toys */
1920 ft_src
= get_ft(ectx
, "loud", "toys", NULL
);
1921 ok(!validate_field_path(ft_src
,
1922 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 3, 0, FIELD_PATH_END
),
1923 "event.context.loud.toys has the correct field path");
1926 /* event.context.loud.spoon */
1927 ft_src
= get_ft(ectx
, "loud", "spoon", NULL
);
1928 ok(!validate_field_path(ft_src
,
1929 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 4, 0, FIELD_PATH_END
),
1930 "event.context.loud.spoon has the correct field path");
1933 /* event.context.loud.turkey */
1934 ft_src
= get_ft(ectx
, "loud", "turkey", NULL
);
1935 ok(!validate_field_path(ft_src
,
1936 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 2, 0, FIELD_PATH_END
),
1937 "event.context.loud.turkey has the correct field path");
1940 /* event.context.loud.inform */
1941 ft_src
= get_ft(ectx
, "loud", "inform", NULL
);
1942 ok(!validate_field_path(ft_src
,
1943 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1944 "event.context.loud.inform has the correct field path");
1947 /* event.context.loud.odd */
1948 ft_src
= get_ft(ectx
, "loud", "odd", NULL
);
1949 ok(!validate_field_path(ft_src
,
1950 BT_CTF_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
1951 "event.context.loud.odd has the correct field path");
1954 /* event.context.loud.amuck */
1955 ft_src
= get_ft(ectx
, "loud", "amuck", NULL
);
1956 ok(!validate_field_path(ft_src
,
1957 BT_CTF_SCOPE_EVENT_CONTEXT
, 0, FIELD_PATH_END
),
1958 "event.context.loud.amuck has the correct field path");
1961 /* event.fields.relative.equal */
1962 ft_src
= get_ft(ep
, "relative", "equal", NULL
);
1963 ok(!validate_field_path(ft_src
,
1964 BT_CTF_SCOPE_EVENT_FIELDS
, 0, FIELD_PATH_END
),
1965 "event.fields.relative.equal has the correct field path");
1968 /* event.fields.relative.amuck */
1969 ft_src
= get_ft(ep
, "relative", "amuck", NULL
);
1970 ok(!validate_field_path(ft_src
,
1971 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 0, FIELD_PATH_END
),
1972 "event.fields.relative.amuck has the correct field path");
1975 /* event.fields.relative.push */
1976 ft_src
= get_ft(ep
, "relative", "push", NULL
);
1977 ok(!validate_field_path(ft_src
,
1978 BT_CTF_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
1979 "event.fields.relative.push has the correct field path");
1982 /* event.fields.relative.brick */
1983 ft_src
= get_ft(ep
, "relative", "brick", NULL
);
1984 ok(!validate_field_path(ft_src
,
1985 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
1986 "event.fields.relative.brick has the correct field path");
1989 /* event.fields.relative.crush */
1990 ft_src
= get_ft(ep
, "relative", "crush", NULL
);
1991 ok(!validate_field_path(ft_src
,
1992 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
1993 "event.fields.relative.crush has the correct field path");
1996 /* event.fields.relative.canvas */
1997 ft_src
= get_ft(ep
, "relative", "canvas", NULL
);
1998 ok(!validate_field_path(ft_src
,
1999 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
2000 "event.fields.relative.canvas has the correct field path");
2003 /* event.fields.absolute.equal */
2004 ft_src
= get_ft(ep
, "absolute", "equal", NULL
);
2005 ok(!validate_field_path(ft_src
,
2006 BT_CTF_SCOPE_EVENT_FIELDS
, 0, FIELD_PATH_END
),
2007 "event.fields.absolute.equal has the correct field path");
2010 /* event.fields.absolute.amuck */
2011 ft_src
= get_ft(ep
, "absolute", "amuck", NULL
);
2012 ok(!validate_field_path(ft_src
,
2013 BT_CTF_SCOPE_STREAM_EVENT_HEADER
, 0, FIELD_PATH_END
),
2014 "event.fields.absolute.amuck has the correct field path");
2017 /* event.fields.absolute.push */
2018 ft_src
= get_ft(ep
, "absolute", "push", NULL
);
2019 ok(!validate_field_path(ft_src
,
2020 BT_CTF_SCOPE_EVENT_CONTEXT
, 1, 3, FIELD_PATH_END
),
2021 "event.fields.absolute.push has the correct field path");
2024 /* event.fields.absolute.brick */
2025 ft_src
= get_ft(ep
, "absolute", "brick", NULL
);
2026 ok(!validate_field_path(ft_src
,
2027 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
, 0, 2, FIELD_PATH_END
),
2028 "event.fields.absolute.brick has the correct field path");
2031 /* event.fields.absolute.crush */
2032 ft_src
= get_ft(ep
, "absolute", "crush", NULL
);
2033 ok(!validate_field_path(ft_src
,
2034 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
, 2, FIELD_PATH_END
),
2035 "event.fields.absolute.crush has the correct field path");
2038 /* event.fields.absolute.canvas */
2039 ft_src
= get_ft(ep
, "absolute", "canvas", NULL
);
2040 ok(!validate_field_path(ft_src
,
2041 BT_CTF_SCOPE_TRACE_PACKET_HEADER
, 3, 1, FIELD_PATH_END
),
2042 "event.fields.absolute.canvas has the correct field path");
2058 void test_pass(void)
2061 struct bt_ctf_trace
*trace
;
2062 struct bt_ctf_stream_class
*sc
;
2063 struct bt_ctf_event_class
*ec
;
2064 struct bt_ctf_field_type
*ph
;
2065 struct bt_ctf_field_type
*pc
;
2066 struct bt_ctf_field_type
*eh
;
2067 struct bt_ctf_field_type
*sec
;
2068 struct bt_ctf_field_type
*ectx
;
2069 struct bt_ctf_field_type
*ep
;
2071 trace
= bt_ctf_trace_create();
2073 sc
= bt_ctf_stream_class_create("nice_piece_of_stream_class");
2075 ec
= bt_ctf_event_class_create("oh_what_an_event_class");
2078 ph
= get_good_packet_header_type();
2080 pc
= get_good_packet_context_type();
2082 eh
= get_good_event_header_type();
2084 sec
= get_good_stream_event_context_type();
2086 ectx
= get_good_event_context_type();
2088 ep
= get_good_event_payload_type();
2091 ret
= bt_ctf_trace_set_packet_header_type(trace
, ph
);
2093 ret
= bt_ctf_stream_class_set_packet_context_type(sc
, pc
);
2095 ret
= bt_ctf_stream_class_set_event_header_type(sc
, eh
);
2097 ret
= bt_ctf_stream_class_set_event_context_type(sc
, sec
);
2099 ret
= bt_ctf_event_class_set_context_type(ec
, ectx
);
2101 ret
= bt_ctf_event_class_set_payload_type(ec
, ep
);
2104 ret
= bt_ctf_stream_class_add_event_class(sc
, ec
);
2107 /* Validation happens here */
2108 ret
= bt_ctf_trace_add_stream_class(trace
, sc
);
2109 ok(ret
== 0, "Valid type system is considered valid");
2111 validate_test_pass(trace
);
2125 struct bt_ctf_event
*create_event_with_context_and_payload(
2126 struct bt_ctf_field_type
*ectx
, struct bt_ctf_field_type
*ep
)
2129 struct bt_ctf_stream_class
*sc
;
2130 struct bt_ctf_event_class
*ec
;
2131 struct bt_ctf_event
*event
;
2133 sc
= bt_ctf_stream_class_create("sc");
2135 ec
= bt_ctf_event_class_create("ec");
2139 ret
= bt_ctf_event_class_set_context_type(ec
, ectx
);
2144 ret
= bt_ctf_event_class_set_payload_type(ec
, ep
);
2148 ret
= bt_ctf_stream_class_add_event_class(sc
, ec
);
2151 /* Validation happens here */
2152 event
= bt_ctf_event_create(ec
);
2162 struct bt_ctf_field_type
*test_fail_unavailable_root_get_event_payload(void)
2165 Generated by bt-ctfirtg using the following input:
2174 length: stream.event.context.lol
2182 struct bt_ctf_field_type
*root
= NULL
;
2183 struct bt_ctf_field_type
*root_a
= NULL
;
2184 struct bt_ctf_field_type
*root_b
= NULL
;
2185 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2186 struct bt_ctf_field_type
*root_c
= NULL
;
2189 root
= bt_ctf_field_type_structure_create();
2191 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2193 root_a
= bt_ctf_field_type_integer_create(32);
2195 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2197 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2199 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2201 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2203 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2205 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2207 root_b_elem
= bt_ctf_field_type_string_create();
2208 assert(root_b_elem
);
2209 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2211 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "stream.event.context.lol");
2213 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2215 root_c
= bt_ctf_field_type_string_create();
2217 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2219 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2224 BT_PUT(root_b_elem
);
2231 void test_fail_unavailable_root(void)
2233 struct bt_ctf_field_type
*ep
;
2234 struct bt_ctf_event
*event
;
2236 ep
= test_fail_unavailable_root_get_event_payload();
2238 event
= create_event_with_context_and_payload(NULL
, ep
);
2239 ok(!event
, "Sequence FT with length in unavailable root is invalid");
2246 struct bt_ctf_field_type
*test_fail_target_is_root_get_event_payload(void)
2249 Generated by bt-ctfirtg using the following input:
2258 length: event.fields
2266 struct bt_ctf_field_type
*root
= NULL
;
2267 struct bt_ctf_field_type
*root_a
= NULL
;
2268 struct bt_ctf_field_type
*root_b
= NULL
;
2269 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2270 struct bt_ctf_field_type
*root_c
= NULL
;
2273 root
= bt_ctf_field_type_structure_create();
2275 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2277 root_a
= bt_ctf_field_type_integer_create(32);
2279 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2281 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2283 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2285 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2287 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2289 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2291 root_b_elem
= bt_ctf_field_type_string_create();
2292 assert(root_b_elem
);
2293 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2295 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "event.fields");
2297 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2299 root_c
= bt_ctf_field_type_string_create();
2301 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2303 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2308 BT_PUT(root_b_elem
);
2315 void test_fail_target_is_root(void)
2317 struct bt_ctf_field_type
*ep
;
2318 struct bt_ctf_event
*event
;
2320 ep
= test_fail_target_is_root_get_event_payload();
2322 event
= create_event_with_context_and_payload(NULL
, ep
);
2323 ok(!event
, "Sequence FT with root as its length is invalid");
2330 struct bt_ctf_field_type
*test_fail_target_is_after_source_get_ep(void)
2333 Generated by bt-ctfirtg using the following input:
2353 struct bt_ctf_field_type
*root
= NULL
;
2354 struct bt_ctf_field_type
*root_a
= NULL
;
2355 struct bt_ctf_field_type
*root_b
= NULL
;
2356 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2357 struct bt_ctf_field_type
*root_c
= NULL
;
2358 struct bt_ctf_field_type
*root_d
= NULL
;
2361 root
= bt_ctf_field_type_structure_create();
2363 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2365 root_a
= bt_ctf_field_type_integer_create(32);
2367 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2369 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2371 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2373 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2375 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2377 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2379 root_b_elem
= bt_ctf_field_type_string_create();
2380 assert(root_b_elem
);
2381 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2383 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "d");
2385 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2387 root_c
= bt_ctf_field_type_string_create();
2389 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2391 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2393 root_d
= bt_ctf_field_type_integer_create(17);
2395 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2397 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2399 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2401 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2403 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2405 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2410 BT_PUT(root_b_elem
);
2418 void test_fail_target_is_after_source(void)
2420 struct bt_ctf_field_type
*ep
;
2421 struct bt_ctf_event
*event
;
2423 ep
= test_fail_target_is_after_source_get_ep();
2425 event
= create_event_with_context_and_payload(NULL
, ep
);
2426 ok(!event
, "Sequence FT with length after it is invalid");
2433 struct bt_ctf_field_type
*test_fail_target_is_ancestor_of_source_get_ep(void)
2436 Generated by bt-ctfirtg using the following input:
2459 struct bt_ctf_field_type
*root
= NULL
;
2460 struct bt_ctf_field_type
*root_a
= NULL
;
2461 struct bt_ctf_field_type
*root_z
= NULL
;
2462 struct bt_ctf_field_type
*root_z_b
= NULL
;
2463 struct bt_ctf_field_type
*root_z_b_elem
= NULL
;
2464 struct bt_ctf_field_type
*root_c
= NULL
;
2465 struct bt_ctf_field_type
*root_d
= NULL
;
2468 root
= bt_ctf_field_type_structure_create();
2470 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2472 root_a
= bt_ctf_field_type_integer_create(32);
2474 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2476 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2478 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2480 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2482 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2484 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2486 root_z
= bt_ctf_field_type_structure_create();
2488 ret
= bt_ctf_field_type_set_alignment(root_z
, 8);
2490 root_z_b_elem
= bt_ctf_field_type_string_create();
2491 assert(root_z_b_elem
);
2492 ret
= bt_ctf_field_type_string_set_encoding(root_z_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2494 root_z_b
= bt_ctf_field_type_sequence_create(root_z_b_elem
, "z");
2496 ret
= bt_ctf_field_type_structure_add_field(root_z
, root_z_b
, "b");
2498 ret
= bt_ctf_field_type_structure_add_field(root
, root_z
, "z");
2500 root_c
= bt_ctf_field_type_string_create();
2502 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2504 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2506 root_d
= bt_ctf_field_type_integer_create(17);
2508 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2510 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2512 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2514 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2516 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2518 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2524 BT_PUT(root_z_b_elem
);
2532 void test_fail_target_is_ancestor_of_source(void)
2534 struct bt_ctf_field_type
*ep
;
2535 struct bt_ctf_event
*event
;
2537 ep
= test_fail_target_is_ancestor_of_source_get_ep();
2539 event
= create_event_with_context_and_payload(NULL
, ep
);
2540 ok(!event
, "Sequence FT with ancestor as its length is invalid");
2547 struct bt_ctf_field_type
*test_fail_target_is_source_get_event_payload(void)
2550 Generated by bt-ctfirtg using the following input:
2559 length: event.fields.b
2570 struct bt_ctf_field_type
*root
= NULL
;
2571 struct bt_ctf_field_type
*root_a
= NULL
;
2572 struct bt_ctf_field_type
*root_b
= NULL
;
2573 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2574 struct bt_ctf_field_type
*root_c
= NULL
;
2575 struct bt_ctf_field_type
*root_d
= NULL
;
2578 root
= bt_ctf_field_type_structure_create();
2580 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2582 root_a
= bt_ctf_field_type_integer_create(32);
2584 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2586 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2588 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2590 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2592 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2594 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2596 root_b_elem
= bt_ctf_field_type_string_create();
2597 assert(root_b_elem
);
2598 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2600 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "event.fields.b");
2602 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2604 root_c
= bt_ctf_field_type_string_create();
2606 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2608 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2610 root_d
= bt_ctf_field_type_integer_create(17);
2612 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2614 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2616 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2618 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2620 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2622 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2627 BT_PUT(root_b_elem
);
2635 void test_fail_target_is_source(void)
2637 struct bt_ctf_field_type
*ep
;
2638 struct bt_ctf_event
*event
;
2640 ep
= test_fail_target_is_source_get_event_payload();
2642 event
= create_event_with_context_and_payload(NULL
, ep
);
2643 ok(!event
, "Sequence FT with itself as its length is invalid");
2650 struct bt_ctf_field_type
*test_fail_variant_tag_is_not_enum_get_ep(void)
2653 Generated by bt-ctfirtg using the following input:
2674 struct bt_ctf_field_type
*root
= NULL
;
2675 struct bt_ctf_field_type
*root_a
= NULL
;
2676 struct bt_ctf_field_type
*root_b
= NULL
;
2677 struct bt_ctf_field_type
*root_b_HELLO
= NULL
;
2678 struct bt_ctf_field_type
*root_c
= NULL
;
2679 struct bt_ctf_field_type
*root_d
= NULL
;
2682 root
= bt_ctf_field_type_structure_create();
2684 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2686 root_a
= bt_ctf_field_type_integer_create(32);
2688 ret
= bt_ctf_field_type_integer_set_signed(root_a
, 0);
2690 ret
= bt_ctf_field_type_integer_set_base(root_a
, 10);
2692 ret
= bt_ctf_field_type_integer_set_encoding(root_a
, BT_CTF_STRING_ENCODING_NONE
);
2694 ret
= bt_ctf_field_type_set_byte_order(root_a
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2696 ret
= bt_ctf_field_type_set_alignment(root_a
, 8);
2698 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2700 root_b
= bt_ctf_field_type_variant_create(NULL
, "a");
2702 root_b_HELLO
= bt_ctf_field_type_string_create();
2703 assert(root_b_HELLO
);
2704 ret
= bt_ctf_field_type_string_set_encoding(root_b_HELLO
, BT_CTF_STRING_ENCODING_UTF8
);
2706 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_HELLO
, "HELLO");
2708 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2710 root_c
= bt_ctf_field_type_string_create();
2712 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2714 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2716 root_d
= bt_ctf_field_type_integer_create(17);
2718 ret
= bt_ctf_field_type_integer_set_signed(root_d
, 0);
2720 ret
= bt_ctf_field_type_integer_set_base(root_d
, 10);
2722 ret
= bt_ctf_field_type_integer_set_encoding(root_d
, BT_CTF_STRING_ENCODING_NONE
);
2724 ret
= bt_ctf_field_type_set_byte_order(root_d
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2726 ret
= bt_ctf_field_type_set_alignment(root_d
, 1);
2728 ret
= bt_ctf_field_type_structure_add_field(root
, root_d
, "d");
2733 BT_PUT(root_b_HELLO
);
2741 void test_fail_variant_tag_is_not_enum(void)
2743 struct bt_ctf_field_type
*ep
;
2744 struct bt_ctf_event
*event
;
2746 ep
= test_fail_variant_tag_is_not_enum_get_ep();
2748 event
= create_event_with_context_and_payload(NULL
, ep
);
2749 ok(!event
, "Variant FT with non-enum FT as its tag FT is invalid");
2756 struct bt_ctf_field_type
*test_fail_variant_tag_mismatch_mappings_get_ep(void)
2759 Generated by bt-ctfirtg using the following input:
2786 struct bt_ctf_field_type
*root
= NULL
;
2787 struct bt_ctf_field_type
*root_a
= NULL
;
2788 struct bt_ctf_field_type
*root_a_int
= NULL
;
2789 struct bt_ctf_field_type
*root_b
= NULL
;
2790 struct bt_ctf_field_type
*root_b_GLASS
= NULL
;
2791 struct bt_ctf_field_type
*root_b_OF
= NULL
;
2792 struct bt_ctf_field_type
*root_c
= NULL
;
2795 root
= bt_ctf_field_type_structure_create();
2797 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2799 root_a_int
= bt_ctf_field_type_integer_create(16);
2801 ret
= bt_ctf_field_type_integer_set_signed(root_a_int
, 0);
2803 ret
= bt_ctf_field_type_integer_set_base(root_a_int
, 10);
2805 ret
= bt_ctf_field_type_integer_set_encoding(root_a_int
, BT_CTF_STRING_ENCODING_NONE
);
2807 ret
= bt_ctf_field_type_set_byte_order(root_a_int
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2809 ret
= bt_ctf_field_type_set_alignment(root_a_int
, 8);
2811 root_a
= bt_ctf_field_type_enumeration_create(root_a_int
);
2813 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "GLASS", 0, 0);
2815 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "OF", 1, 1);
2817 ret
= bt_ctf_field_type_enumeration_add_mapping(root_a
, "WATER", 2, 2);
2819 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2821 root_b
= bt_ctf_field_type_variant_create(NULL
, "a");
2823 root_b_GLASS
= bt_ctf_field_type_string_create();
2824 assert(root_b_GLASS
);
2825 ret
= bt_ctf_field_type_string_set_encoding(root_b_GLASS
, BT_CTF_STRING_ENCODING_UTF8
);
2827 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_GLASS
, "GLASS");
2829 root_b_OF
= bt_ctf_field_type_integer_create(2);
2831 ret
= bt_ctf_field_type_integer_set_signed(root_b_OF
, 0);
2833 ret
= bt_ctf_field_type_integer_set_base(root_b_OF
, 10);
2835 ret
= bt_ctf_field_type_integer_set_encoding(root_b_OF
, BT_CTF_STRING_ENCODING_NONE
);
2837 ret
= bt_ctf_field_type_set_byte_order(root_b_OF
, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
);
2839 ret
= bt_ctf_field_type_set_alignment(root_b_OF
, 1);
2841 ret
= bt_ctf_field_type_variant_add_field(root_b
, root_b_OF
, "OF");
2843 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2845 root_c
= bt_ctf_field_type_string_create();
2847 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2849 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2855 BT_PUT(root_b_GLASS
);
2863 void test_fail_variant_tag_mismatch_mappings(void)
2865 struct bt_ctf_field_type
*ep
;
2866 struct bt_ctf_event
*event
;
2868 ep
= test_fail_variant_tag_mismatch_mappings_get_ep();
2870 event
= create_event_with_context_and_payload(NULL
, ep
);
2871 ok(!event
, "Variant FT with mismatching tag FT is invalid");
2878 struct bt_ctf_field_type
*test_fail_sequence_tag_is_not_int_get_ep(void)
2881 Generated by bt-ctfirtg using the following input:
2897 struct bt_ctf_field_type
*root
= NULL
;
2898 struct bt_ctf_field_type
*root_a
= NULL
;
2899 struct bt_ctf_field_type
*root_b
= NULL
;
2900 struct bt_ctf_field_type
*root_b_elem
= NULL
;
2901 struct bt_ctf_field_type
*root_c
= NULL
;
2904 root
= bt_ctf_field_type_structure_create();
2906 ret
= bt_ctf_field_type_set_alignment(root
, 8);
2908 root_a
= bt_ctf_field_type_string_create();
2910 ret
= bt_ctf_field_type_string_set_encoding(root_a
, BT_CTF_STRING_ENCODING_UTF8
);
2912 ret
= bt_ctf_field_type_structure_add_field(root
, root_a
, "a");
2914 root_b_elem
= bt_ctf_field_type_string_create();
2915 assert(root_b_elem
);
2916 ret
= bt_ctf_field_type_string_set_encoding(root_b_elem
, BT_CTF_STRING_ENCODING_UTF8
);
2918 root_b
= bt_ctf_field_type_sequence_create(root_b_elem
, "a");
2920 ret
= bt_ctf_field_type_structure_add_field(root
, root_b
, "b");
2922 root_c
= bt_ctf_field_type_string_create();
2924 ret
= bt_ctf_field_type_string_set_encoding(root_c
, BT_CTF_STRING_ENCODING_UTF8
);
2926 ret
= bt_ctf_field_type_structure_add_field(root
, root_c
, "c");
2931 BT_PUT(root_b_elem
);
2938 void test_fail_sequence_tag_is_not_int(void)
2940 struct bt_ctf_field_type
*ep
;
2941 struct bt_ctf_event
*event
;
2943 ep
= test_fail_sequence_tag_is_not_int_get_ep();
2945 event
= create_event_with_context_and_payload(NULL
, ep
);
2946 ok(!event
, "Sequence FT with non-enum length FT is invalid");
2953 void test_fail(void)
2955 test_fail_unavailable_root();
2956 test_fail_target_is_root();
2957 test_fail_target_is_after_source();
2958 test_fail_target_is_ancestor_of_source();
2959 test_fail_target_is_source();
2960 test_fail_variant_tag_is_not_enum();
2961 test_fail_variant_tag_mismatch_mappings();
2962 test_fail_sequence_tag_is_not_int();