#define DEFAULT_CLOCK_OFFSET_S 0
#define DEFAULT_CLOCK_IS_ABSOLUTE 0
#define DEFAULT_CLOCK_TIME 0
+#define DEFAULT_CLOCK_VALUE 0
-#define NR_TESTS 594
+#define NR_TESTS 584
static int64_t current_time = 42;
}
}
-void event_copy_tests(struct bt_ctf_event *event)
-{
- struct bt_ctf_event *copy;
- struct bt_ctf_event_class *orig_event_class;
- struct bt_ctf_event_class *copy_event_class;
- struct bt_ctf_stream *orig_stream;
- struct bt_ctf_stream *copy_stream;
- struct bt_ctf_field *orig_field;
- struct bt_ctf_field *copy_field;
-
- /* copy */
- ok(!bt_ctf_event_copy(NULL),
- "bt_ctf_event_copy handles NULL correctly");
- copy = bt_ctf_event_copy(event);
- ok(copy, "bt_ctf_event_copy returns a valid pointer");
-
- /* validate event class */
- orig_event_class = bt_ctf_event_get_class(event);
- assert(orig_event_class);
- copy_event_class = bt_ctf_event_get_class(copy);
- ok(orig_event_class == copy_event_class,
- "original and copied events share the same event class pointer");
- bt_put(orig_event_class);
- bt_put(copy_event_class);
-
- /* validate stream */
- orig_stream = bt_ctf_event_get_stream(event);
- copy_stream = bt_ctf_event_get_stream(copy);
-
- if (!orig_stream) {
- ok(!copy_stream, "original and copied events have no stream");
- } else {
- ok(orig_stream == copy_stream,
- "original and copied events share the same stream pointer");
- }
- bt_put(orig_stream);
- bt_put(copy_stream);
-
- /* header */
- orig_field = bt_ctf_event_get_header(event);
- copy_field = bt_ctf_event_get_header(copy);
-
- if (!orig_field) {
- ok(!copy_field, "original and copied events have no header");
- } else {
- ok(orig_field != copy_field,
- "original and copied events headers are different pointers");
- }
-
- bt_put(orig_field);
- bt_put(copy_field);
-
- /* context */
- orig_field = bt_ctf_event_get_event_context(event);
- copy_field = bt_ctf_event_get_event_context(copy);
-
- if (!orig_field) {
- ok(!copy_field, "original and copied events have no context");
- } else {
- ok(orig_field != copy_field,
- "original and copied events contexts are different pointers");
- }
-
- bt_put(orig_field);
- bt_put(copy_field);
-
- /* payload */
- orig_field = bt_ctf_event_get_payload_field(event);
- copy_field = bt_ctf_event_get_payload_field(copy);
-
- if (!orig_field) {
- ok(!copy_field, "original and copied events have no payload");
- } else {
- ok(orig_field != copy_field,
- "original and copied events payloads are different pointers");
- }
-
- bt_put(orig_field);
- bt_put(copy_field);
-
- bt_put(copy);
-}
-
void append_simple_event(struct bt_ctf_stream_class *stream_class,
struct bt_ctf_stream *stream, struct bt_ctf_clock *clock)
{
ok(bt_ctf_clock_set_time(clock, current_time) == 0, "Set clock time");
/* Populate stream event context */
- stream_event_context = bt_ctf_stream_get_event_context(stream);
+ stream_event_context =
+ bt_ctf_event_get_stream_event_context(simple_event);
+ assert(stream_event_context);
stream_event_context_field = bt_ctf_field_structure_get_field(
stream_event_context, "common_event_context");
bt_ctf_field_unsigned_integer_set_value(stream_event_context_field, 42);
ok(!bt_ctf_event_set_event_context(simple_event, event_context),
"Set an event context successfully");
- event_copy_tests(simple_event);
ok(bt_ctf_stream_append_event(stream, simple_event) == 0,
"Append simple event to trace stream");
struct bt_ctf_field *uint_35_field, *int_16_field, *a_string_field,
*inner_structure_field, *complex_structure_field,
*a_sequence_field, *enum_variant_field, *enum_container_field,
- *variant_field, *an_array_field, *ret_field;
+ *variant_field, *an_array_field, *stream_event_ctx_field,
+ *stream_event_ctx_int_field, *ret_field;
uint64_t ret_unsigned_int;
int64_t ret_signed_int;
const char *ret_string;
bt_put(int_16_field);
}
+ stream_event_ctx_field = bt_ctf_event_get_stream_event_context(event);
+ assert(stream_event_ctx_field);
+ stream_event_ctx_int_field = bt_ctf_field_structure_get_field(
+ stream_event_ctx_field, "common_event_context");
+ BT_PUT(stream_event_ctx_field);
+ bt_ctf_field_unsigned_integer_set_value(stream_event_ctx_int_field, 17);
+ BT_PUT(stream_event_ctx_int_field);
+
bt_ctf_clock_set_time(clock, ++current_time);
ok(bt_ctf_stream_append_event(stream, event) == 0,
"Append a complex event to a stream");
"bt_ctf_field_type_get_byte_order handles NULL correctly");
ok(bt_ctf_field_type_get_type_id(NULL) ==
- CTF_TYPE_UNKNOWN,
+ BT_CTF_TYPE_ID_UNKNOWN,
"bt_ctf_field_type_get_type_id handles NULL correctly");
ok(bt_ctf_field_type_get_type_id(uint_12_type) ==
- CTF_TYPE_INTEGER,
+ BT_CTF_TYPE_ID_INTEGER,
"bt_ctf_field_type_get_type_id returns a correct value with an integer type");
ok(bt_ctf_field_type_integer_get_base(NULL) ==
BT_CTF_INTEGER_BASE_HEXADECIMAL,
"bt_ctf_field_type_integer_get_base returns a correct value");
- ok(bt_ctf_field_type_integer_set_encoding(NULL, CTF_STRING_ASCII) < 0,
+ ok(bt_ctf_field_type_integer_set_encoding(NULL,
+ BT_CTF_STRING_ENCODING_ASCII) < 0,
"bt_ctf_field_type_integer_set_encoding handles NULL correctly");
ok(bt_ctf_field_type_integer_set_encoding(uint_12_type,
- (enum ctf_string_encoding) 123) < 0,
+ (enum bt_ctf_string_encoding) 123) < 0,
"bt_ctf_field_type_integer_set_encoding handles invalid encodings correctly");
ok(bt_ctf_field_type_integer_set_encoding(uint_12_type,
- CTF_STRING_UTF8) == 0,
+ BT_CTF_STRING_ENCODING_UTF8) == 0,
"Set integer type encoding to UTF8");
- ok(bt_ctf_field_type_integer_get_encoding(NULL) == CTF_STRING_UNKNOWN,
+ ok(bt_ctf_field_type_integer_get_encoding(NULL) ==
+ BT_CTF_STRING_ENCODING_UNKNOWN,
"bt_ctf_field_type_integer_get_encoding handles NULL correctly");
- ok(bt_ctf_field_type_integer_get_encoding(uint_12_type) == CTF_STRING_UTF8,
+ ok(bt_ctf_field_type_integer_get_encoding(uint_12_type) ==
+ BT_CTF_STRING_ENCODING_UTF8,
"bt_ctf_field_type_integer_get_encoding returns a correct value");
int_16_type = bt_ctf_field_type_integer_create(16);
bt_ctf_field_type_sequence_create(int_16_type, "seq_len");
ok(sequence_type, "Create a sequence of int16_t type");
ok(bt_ctf_field_type_get_type_id(sequence_type) ==
- CTF_TYPE_SEQUENCE,
+ BT_CTF_TYPE_ID_SEQUENCE,
"bt_ctf_field_type_get_type_id returns a correct value with a sequence type");
ok(bt_ctf_field_type_sequence_get_length_field_name(NULL) == NULL,
string_type = bt_ctf_field_type_string_create();
ok(string_type, "Create a string type");
ok(bt_ctf_field_type_string_set_encoding(string_type,
- CTF_STRING_NONE),
+ BT_CTF_STRING_ENCODING_NONE),
"Reject invalid \"None\" string encoding");
ok(bt_ctf_field_type_string_set_encoding(string_type,
42),
"Reject invalid string encoding");
ok(bt_ctf_field_type_string_set_encoding(string_type,
- CTF_STRING_ASCII) == 0,
+ BT_CTF_STRING_ENCODING_ASCII) == 0,
"Set string encoding to ASCII");
ok(bt_ctf_field_type_string_get_encoding(NULL) ==
- CTF_STRING_UNKNOWN,
+ BT_CTF_STRING_ENCODING_UNKNOWN,
"bt_ctf_field_type_string_get_encoding handles NULL correctly");
ok(bt_ctf_field_type_string_get_encoding(string_type) ==
- CTF_STRING_ASCII,
+ BT_CTF_STRING_ENCODING_ASCII,
"bt_ctf_field_type_string_get_encoding returns the correct value");
structure_seq_type = bt_ctf_field_type_structure_create();
ok(bt_ctf_field_type_get_type_id(structure_seq_type) ==
- CTF_TYPE_STRUCT,
+ BT_CTF_TYPE_ID_STRUCT,
"bt_ctf_field_type_get_type_id returns a correct value with a structure type");
ok(structure_seq_type, "Create a structure type");
ok(bt_ctf_field_type_structure_add_field(structure_seq_type,
uint64_t ret_uint64;
int events_appended = 0;
struct bt_ctf_field *packet_context = NULL,
- *packet_context_field = NULL, *event_context = NULL;
+ *packet_context_field = NULL, *stream_event_context = NULL;
struct bt_ctf_field_type *ep_field_1_type = NULL;
struct bt_ctf_field_type *ep_a_string_type = NULL;
struct bt_ctf_field_type *ep_type = NULL;
"bt_ctf_event_get_payload_by_index handles an invalid index correctly");
bt_put(event);
- ok(bt_ctf_stream_get_event_context(NULL) == NULL,
- "bt_ctf_stream_get_event_context handles NULL correctly");
- event_context = bt_ctf_stream_get_event_context(stream);
- ok(event_context,
- "bt_ctf_stream_get_event_context returns a stream event context");
- ok(bt_ctf_stream_set_event_context(NULL, event_context) < 0,
- "bt_ctf_stream_set_event_context handles a NULL stream correctly");
- ok(bt_ctf_stream_set_event_context(stream, NULL) < 0,
- "bt_ctf_stream_set_event_context handles a NULL stream event context correctly");
- ok(!bt_ctf_stream_set_event_context(stream, event_context),
- "bt_ctf_stream_set_event_context correctly set a stream event context");
- ret_field = bt_ctf_field_create(ep_field_1_type);
- ok(bt_ctf_stream_set_event_context(stream, ret_field) < 0,
- "bt_ctf_stream_set_event_context rejects an event context of incorrect type");
- bt_put(ret_field);
-
for (i = 0; i < PACKET_RESIZE_TEST_LENGTH; i++) {
event = bt_ctf_event_create(event_class);
struct bt_ctf_field *integer =
bt_put(string);
/* Populate stream event context */
- integer = bt_ctf_field_structure_get_field(event_context,
+ stream_event_context =
+ bt_ctf_event_get_stream_event_context(event);
+ integer = bt_ctf_field_structure_get_field(stream_event_context,
"common_event_context");
+ BT_PUT(stream_event_context);
ret |= bt_ctf_field_unsigned_integer_set_value(integer,
i % 42);
bt_put(integer);
bt_put(string_type);
bt_put(packet_context);
bt_put(packet_context_field);
- bt_put(event_context);
+ bt_put(stream_event_context);
bt_put(event_class);
bt_put(ep_field_1_type);
bt_put(ep_a_string_type);
"bt_ctf_clock_get_time succeeds");
ok(get_time == DEFAULT_CLOCK_TIME,
"bt_ctf_clock_get_time returns the correct default time");
+ ok(bt_ctf_clock_get_value(clock) == DEFAULT_CLOCK_VALUE,
+ "bt_ctf_clock_get_value returns the correct default value");
+ ok(bt_ctf_clock_set_value(clock, current_time) == 0,
+ "Set clock value");
+ ok(bt_ctf_clock_get_value(clock) == current_time,
+ "bt_ctf_clock_get_value returns the correct value once it is set");
ok(bt_ctf_clock_set_time(clock, current_time) == 0,
"Set clock time");
ok(bt_ctf_clock_get_time(clock, &get_time) == 0,
"bt_ctf_clock_get_time succeeds");
- ok(get_time == current_time,
+ ok(get_time >= current_time - 1 && get_time <= current_time + 1,
"bt_ctf_clock_get_time returns the correct time once it is set");
ok(bt_ctf_writer_add_clock(writer, clock) == 0,
stream_class);
ok(ret_field_type,
"bt_ctf_stream_class_get_event_header_type returns an event header type");
- ok(bt_ctf_field_type_get_type_id(ret_field_type) == CTF_TYPE_STRUCT,
+ ok(bt_ctf_field_type_get_type_id(ret_field_type) == BT_CTF_TYPE_ID_STRUCT,
"Default event header type is a structure");
event_header_field_type =
bt_ctf_field_type_structure_get_field_type_by_name(
ok(event_header_field_type,
"Default event header type contains an \"id\" field");
ok(bt_ctf_field_type_get_type_id(
- event_header_field_type) == CTF_TYPE_INTEGER,
+ event_header_field_type) == BT_CTF_TYPE_ID_INTEGER,
"Default event header \"id\" field is an integer");
bt_put(event_header_field_type);
event_header_field_type =
ok(event_header_field_type,
"Default event header type contains a \"timestamp\" field");
ok(bt_ctf_field_type_get_type_id(
- event_header_field_type) == CTF_TYPE_INTEGER,
+ event_header_field_type) == BT_CTF_TYPE_ID_INTEGER,
"Default event header \"timestamp\" field is an integer");
bt_put(event_header_field_type);
bt_put(ret_field_type);
packet_header_type = bt_ctf_trace_get_packet_header_type(trace);
ok(packet_header_type,
"bt_ctf_trace_get_packet_header_type returns a packet header");
- ok(bt_ctf_field_type_get_type_id(packet_header_type) == CTF_TYPE_STRUCT,
+ ok(bt_ctf_field_type_get_type_id(packet_header_type) == BT_CTF_TYPE_ID_STRUCT,
"bt_ctf_trace_get_packet_header_type returns a packet header of type struct");
ret_field_type = bt_ctf_field_type_structure_get_field_type_by_name(
packet_header_type, "magic");
packet_context_type = bt_ctf_stream_class_get_packet_context_type(stream_class);
ok(packet_context_type,
"bt_ctf_stream_class_get_packet_context_type returns a packet context type.");
- ok(bt_ctf_field_type_get_type_id(packet_context_type) == CTF_TYPE_STRUCT,
+ ok(bt_ctf_field_type_get_type_id(packet_context_type) == BT_CTF_TYPE_ID_STRUCT,
"Packet context is a structure");
ok(bt_ctf_stream_class_set_packet_context_type(NULL, packet_context_type),