ir: add trace UUID getter and setter
[babeltrace.git] / tests / lib / test_ctf_writer.c
index 7ea4b5831638b646108c1a712d7296f9c38b0d50..f6224f5c8f9977e9b02f29f512eb789b5a147625 100644 (file)
@@ -61,7 +61,7 @@
 #define DEFAULT_CLOCK_TIME 0
 #define DEFAULT_CLOCK_VALUE 0
 
-#define NR_TESTS 611
+#define NR_TESTS 614
 
 static int64_t current_time = 42;
 
@@ -434,17 +434,6 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
                "bt_ctf_stream_class_get_event_class_by_id returns a correct event class");
        bt_put(ret_event_class);
 
-       ok(bt_ctf_stream_class_get_event_class_by_name(NULL, "some event name") == NULL,
-               "bt_ctf_stream_class_get_event_class_by_name handles a NULL stream class correctly");
-       ok(bt_ctf_stream_class_get_event_class_by_name(stream_class, NULL) == NULL,
-               "bt_ctf_stream_class_get_event_class_by_name handles a NULL event class name correctly");
-       ok(bt_ctf_stream_class_get_event_class_by_name(stream_class, "some event name") == NULL,
-               "bt_ctf_stream_class_get_event_class_by_name handles non-existing event class names correctly");
-       ret_event_class = bt_ctf_stream_class_get_event_class_by_name(stream_class, "Simple Event");
-       ok(ret_event_class == simple_event_class,
-               "bt_ctf_stream_class_get_event_class_by_name returns a correct event class");
-       bt_put(ret_event_class);
-
        simple_event = bt_ctf_event_create(simple_event_class);
        ok(simple_event,
                "Instantiate an event containing a single integer field");
@@ -2500,8 +2489,8 @@ void append_existing_event_class(struct bt_ctf_stream_class *stream_class)
 
        event_class = bt_ctf_event_class_create("Simple Event");
        assert(event_class);
-       ok(bt_ctf_stream_class_add_event_class(stream_class, event_class),
-               "two event classes with the same name cannot cohabit within the same stream class");
+       ok(bt_ctf_stream_class_add_event_class(stream_class, event_class) == 0,
+               "two event classes with the same name may cohabit within the same stream class");
        bt_put(event_class);
 
        event_class = bt_ctf_event_class_create("different name, ok");
@@ -2819,6 +2808,36 @@ void test_static_trace(void)
        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);
+}
+
 int main(int argc, char **argv)
 {
        char trace_path[] = "/tmp/ctfwriter_XXXXXX";
@@ -3474,6 +3493,8 @@ int main(int argc, char **argv)
 
        test_static_trace();
 
+       test_trace_uuid();
+
        metadata_string = bt_ctf_writer_get_metadata_string(writer);
        ok(metadata_string, "Get metadata string");
 
This page took 0.026639 seconds and 4 git commands to generate.