bt_ctf_stream_class_set_packet_context_type was checking the current
stream packet context's type instead of the one being passed.
Added a test to validate that the check is done appropriately.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
}
assert(stream_class->packet_context_type);
}
assert(stream_class->packet_context_type);
- if (bt_ctf_field_type_get_type_id(stream_class->packet_context_type) !=
+ if (bt_ctf_field_type_get_type_id(packet_context_type) !=
CTF_TYPE_STRUCT) {
/* A packet context must be a structure */
ret = -1;
CTF_TYPE_STRUCT) {
/* A packet context must be a structure */
ret = -1;
const char *ret_string;
const unsigned char *ret_uuid;
unsigned char tmp_uuid[16] = { 0 };
const char *ret_string;
const unsigned char *ret_uuid;
unsigned char tmp_uuid[16] = { 0 };
- struct bt_ctf_field_type *packet_context_type, *packet_context_field_type;
+ struct bt_ctf_field_type *packet_context_type,
+ *packet_context_field_type,
+ *integer_type;
struct bt_ctf_trace *trace;
int ret;
struct bt_ctf_trace *trace;
int ret;
"bt_ctf_stream_class_set_packet_context_type handles a NULL stream class correctly");
ok(bt_ctf_stream_class_set_packet_context_type(stream_class, NULL),
"bt_ctf_stream_class_set_packet_context_type handles a NULL packet context type correctly");
"bt_ctf_stream_class_set_packet_context_type handles a NULL stream class correctly");
ok(bt_ctf_stream_class_set_packet_context_type(stream_class, NULL),
"bt_ctf_stream_class_set_packet_context_type handles a NULL packet context type correctly");
+
+ integer_type = bt_ctf_field_type_integer_create(32);
+ ok(bt_ctf_stream_class_set_packet_context_type(stream_class,
+ integer_type) < 0,
+ "bt_ctf_stream_class_set_packet_context_type rejects a packet context that is not a structure");
ret = bt_ctf_field_type_structure_add_field(packet_context_type,
packet_context_field_type, "custom_field");
ok(ret == 0, "Packet context field added successfully");
ret = bt_ctf_field_type_structure_add_field(packet_context_type,
packet_context_field_type, "custom_field");
ok(ret == 0, "Packet context field added successfully");
bt_ctf_stream_put(stream1);
bt_ctf_field_type_put(packet_context_type);
bt_ctf_field_type_put(packet_context_field_type);
bt_ctf_stream_put(stream1);
bt_ctf_field_type_put(packet_context_type);
bt_ctf_field_type_put(packet_context_field_type);
+ bt_ctf_field_type_put(integer_type);
bt_ctf_trace_put(trace);
free(metadata_string);
bt_ctf_trace_put(trace);
free(metadata_string);