From: Jérémie Galarneau Date: Wed, 28 Jan 2015 22:31:38 +0000 (-0500) Subject: Test: Add a test that validates that empty streams are valid X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=fdf80f327cd463eacb1d8a209091733b0cea2073;p=deliverable%2Fbabeltrace.git Test: Add a test that validates that empty streams are valid 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 --- diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index 156e591c7..52106f2d6 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -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");