+void test_set_clock_non_writer_stream_class(void)
+{
+ struct bt_ctf_clock *clock;
+ struct bt_ctf_trace *trace;
+ struct bt_ctf_stream_class *sc;
+ int ret;
+
+ clock = bt_ctf_clock_create("the_clock");
+ assert(clock);
+
+ trace = bt_ctf_trace_create();
+ assert(trace);
+
+ sc = bt_ctf_stream_class_create(NULL);
+ assert(sc);
+
+ ret = bt_ctf_stream_class_set_clock(sc, clock);
+ assert(ret == 0);
+
+ ret = bt_ctf_trace_add_stream_class(trace, sc);
+ ok(ret < 0,
+ "bt_ctf_trace_add_stream_class() fails with a stream class with a registered clock");
+
+ bt_put(clock);
+ bt_put(trace);
+ bt_put(sc);
+}
+
+static
+void test_static_trace(void)
+{
+ struct bt_ctf_trace *trace;
+ struct bt_ctf_stream_class *stream_class;
+ struct bt_ctf_stream_class *stream_class2;
+ struct bt_ctf_stream *stream;
+ struct bt_ctf_clock_class *clock_class;
+ int ret;
+
+ trace = bt_ctf_trace_create();
+ assert(trace);
+ ret = bt_ctf_trace_set_native_byte_order(trace,
+ BT_CTF_BYTE_ORDER_LITTLE_ENDIAN);
+ assert(ret == 0);
+ stream_class = bt_ctf_stream_class_create(NULL);
+ assert(stream_class);
+ ret = bt_ctf_stream_class_set_packet_context_type(stream_class, NULL);
+ assert(ret == 0);
+ ret = bt_ctf_trace_add_stream_class(trace, stream_class);
+ assert(ret == 0);
+ stream = bt_ctf_stream_create(stream_class, "hello");
+ ok(stream, "bt_ctf_stream_create() succeeds with a non-static trace");
+ bt_put(stream);
+ ok(!bt_ctf_trace_is_static(trace),
+ "bt_ctf_trace_is_static() returns the expected value");
+ ok(bt_ctf_trace_set_is_static(trace) == 0,
+ "bt_ctf_trace_set_is_static() succeeds");
+ ok(bt_ctf_trace_is_static(trace),
+ "bt_ctf_trace_is_static() returns the expected value");
+ clock_class = bt_ctf_clock_class_create("yes");
+ assert(clock_class);
+ stream_class2 = bt_ctf_stream_class_create(NULL);
+ assert(stream_class2);
+ ok(bt_ctf_trace_add_stream_class(trace, stream_class2),
+ "bt_ctf_trace_add_stream_class() fails with a static trace");
+ ok(bt_ctf_trace_add_clock_class(trace, clock_class),
+ "bt_ctf_trace_add_clock_class() fails with a static trace");
+ ok(!bt_ctf_stream_create(stream_class, "hello2"),
+ "bt_ctf_stream_create() fails with a static trace");
+
+ bt_put(trace);
+ bt_put(stream_class);
+ bt_put(stream_class2);
+ bt_put(clock_class);
+}
+
+static
+void test_trace_uuid(void)
+{
+ struct bt_ctf_trace *trace;
+ const unsigned char uuid[] = {
+ 0x35, 0x92, 0x63, 0xab, 0xb4, 0xbe, 0x40, 0xb4,
+ 0xb2, 0x60, 0xd3, 0xf1, 0x3b, 0xb0, 0xd8, 0x59,
+ };
+ const unsigned char *ret_uuid;
+
+ trace = bt_ctf_trace_create();
+ assert(trace);
+ ok(!bt_ctf_trace_get_uuid(NULL),
+ "bt_ctf_trace_get_uuid() handles NULL");
+ ok(!bt_ctf_trace_get_uuid(trace),
+ "bt_ctf_trace_get_uuid() returns NULL initially");
+ ok(bt_ctf_trace_set_uuid(NULL, uuid),
+ "bt_ctf_trace_set_uuid() handles NULL (trace)");
+ ok(bt_ctf_trace_set_uuid(trace, NULL),
+ "bt_ctf_trace_set_uuid() handles NULL (UUID)");
+ ok(bt_ctf_trace_set_uuid(trace, uuid) == 0,
+ "bt_ctf_trace_set_uuid() succeeds with a valid UUID");
+ ret_uuid = bt_ctf_trace_get_uuid(trace);
+ ok(ret_uuid, "bt_ctf_trace_get_uuid() returns a UUID");
+ ok(memcmp(uuid, ret_uuid, 16) == 0,
+ "bt_ctf_trace_get_uuid() returns the expected UUID");
+
+ bt_put(trace);
+}
+