X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Flib%2Ftest_ctf_writer.c;h=7720719e9074a6c86d54480e35edcb3af6df0d58;hb=6809e2273311a45d144e1be669aa643adcc8698c;hp=826c530d84041aaab4414fceb1195be77de16c4b;hpb=1ff9582c1a6b75ddfde2d01a6afb23311858a049;p=babeltrace.git diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index 826c530d..7720719e 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -286,6 +286,7 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, int64_t ret_range_start_int64_t, ret_range_end_int64_t; uint64_t ret_range_start_uint64_t, ret_range_end_uint64_t; struct bt_ctf_clock *ret_clock; + struct bt_ctf_event_class *ret_event_class; ok(uint_12_type, "Create an unsigned integer type"); @@ -431,6 +432,30 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, bt_ctf_stream_class_add_event_class(stream_class, simple_event_class); + ok(bt_ctf_stream_class_get_event_class_count(NULL) < 0, + "bt_ctf_stream_class_get_event_class_count handles NULL correctly"); + ok(bt_ctf_stream_class_get_event_class_count(stream_class) == 1, + "bt_ctf_stream_class_get_event_class_count returns a correct number of event classes"); + ok(bt_ctf_stream_class_get_event_class(NULL, 0) == NULL, + "bt_ctf_stream_class_get_event_class handles NULL correctly"); + ok(bt_ctf_stream_class_get_event_class(stream_class, 8724) == NULL, + "bt_ctf_stream_class_get_event_class handles invalid indexes correctly"); + ret_event_class = bt_ctf_stream_class_get_event_class(stream_class, 0); + ok(ret_event_class == simple_event_class, + "bt_ctf_stream_class_get_event_class returns the correct event class"); + bt_ctf_event_class_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_ctf_event_class_put(ret_event_class); + simple_event = bt_ctf_event_create(simple_event_class); ok(simple_event, "Instantiate an event containing a single integer field"); @@ -1236,6 +1261,7 @@ void packet_resize_test(struct bt_ctf_stream_class *stream_class, struct bt_ctf_event *event; struct bt_ctf_field *ret_field; struct bt_ctf_field_type *ret_field_type; + uint64_t ret_uint64; ret |= bt_ctf_event_class_add_field(event_class, integer_type, "field_1"); @@ -1284,10 +1310,26 @@ void packet_resize_test(struct bt_ctf_stream_class *stream_class, break; } } + + ok(bt_ctf_stream_get_discarded_events_count(NULL, &ret_uint64) == -1, + "bt_ctf_stream_get_discarded_events_count handles a NULL stream correctly"); + ok(bt_ctf_stream_get_discarded_events_count(stream, NULL) == -1, + "bt_ctf_stream_get_discarded_events_count handles a NULL return pointer correctly"); + ret = bt_ctf_stream_get_discarded_events_count(stream, &ret_uint64); + ok(ret == 0 && ret_uint64 == 0, + "bt_ctf_stream_get_discarded_events_count returns a correct number of discarded events when none were discarded"); + bt_ctf_stream_append_discarded_events(stream, 1000); + ret = bt_ctf_stream_get_discarded_events_count(stream, &ret_uint64); + ok(ret == 0 && ret_uint64 == 1000, + "bt_ctf_stream_get_discarded_events_count returns a correct number of discarded events when some were discarded"); + end: ok(ret == 0, "Append 100 000 events to a stream"); ok(bt_ctf_stream_flush(stream) == 0, "Flush a stream that forces a packet resize"); + ret = bt_ctf_stream_get_discarded_events_count(stream, &ret_uint64); + ok(ret == 0 && ret_uint64 == 1000, + "bt_ctf_stream_get_discarded_events_count returns a correct number of discarded events after a flush"); bt_ctf_field_type_put(integer_type); bt_ctf_field_type_put(string_type); bt_ctf_event_class_put(event_class); @@ -1313,6 +1355,7 @@ int main(int argc, char **argv) struct bt_ctf_clock *clock, *ret_clock; struct bt_ctf_stream_class *stream_class; struct bt_ctf_stream *stream1; + const char *ret_string; if (argc < 3) { printf("Usage: tests-ctf-writer path_to_ctf_parser_test path_to_babeltrace\n"); @@ -1470,6 +1513,13 @@ int main(int argc, char **argv) /* Define a stream class */ stream_class = bt_ctf_stream_class_create("test_stream"); + + ok(bt_ctf_stream_class_get_name(NULL) == NULL, + "bt_ctf_stream_class_get_name handles NULL correctly"); + ret_string = bt_ctf_stream_class_get_name(stream_class); + ok(!strcmp(ret_string, "test_stream"), + "bt_ctf_stream_class_get_name returns a correct stream class name"); + ok(bt_ctf_stream_class_get_clock(stream_class) == NULL, "bt_ctf_stream_class_get_clock returns NULL when a clock was not set"); ok(bt_ctf_stream_class_get_clock(NULL) == NULL,