Test: Add a test that validates that empty streams are valid
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 28 Jan 2015 22:31:38 +0000 (17:31 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 28 Jan 2015 22:31:38 +0000 (17:31 -0500)
Empty streams should be backed by a file of size 0 and be readable
by a CTF reader. This test validates that the problem described in
28362f2b is fixed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/lib/test_ctf_writer.c

index 156e591c7a9e6b46241e356d3d60320be9a961e4..52106f2d6e581044a0dbd230fec9744ffe66044f 100644 (file)
@@ -1480,6 +1480,43 @@ end:
        bt_ctf_event_class_put(event_class);
 }
 
+void test_empty_stream(struct bt_ctf_writer *writer)
+{
+       int ret = 0;
+       struct bt_ctf_trace *trace = NULL;
+       struct bt_ctf_clock *clock = NULL;
+       struct bt_ctf_stream_class *stream_class = NULL;
+       struct bt_ctf_stream *stream = NULL;
+
+       trace = bt_ctf_writer_get_trace(writer);
+       if (!trace) {
+               diag("Failed to get trace from writer");
+               ret = -1;
+               goto end;
+       }
+
+       stream_class = bt_ctf_stream_class_create("empty_stream");
+       if (!stream_class) {
+               diag("Failed to create stream class");
+               ret = -1;
+               goto end;
+       }
+
+       stream = bt_ctf_writer_create_stream(writer, stream_class);
+       if (!stream) {
+               diag("Failed to create writer stream");
+               ret = -1;
+               goto end;
+       }
+end:
+       ok(ret == 0,
+               "Created a stream class with default attributes and an empty stream");
+       bt_ctf_trace_put(trace);
+       bt_ctf_clock_put(clock);
+       bt_ctf_stream_put(stream);
+       bt_ctf_stream_class_put(stream_class);
+}
+
 int main(int argc, char **argv)
 {
        char trace_path[] = "/tmp/ctfwriter_XXXXXX";
@@ -1915,6 +1952,8 @@ int main(int argc, char **argv)
 
        append_complex_event(stream_class, stream1, clock);
 
+       test_empty_stream(writer);
+
        metadata_string = bt_ctf_writer_get_metadata_string(writer);
        ok(metadata_string, "Get metadata string");
 
This page took 0.028375 seconds and 4 git commands to generate.