Move to kernel style SPDX license identifiers
[babeltrace.git] / tests / ctf-writer / ctf_writer.c
index b41a068c10a8c953affdf3c230270709e58d82bf..c8fab1b7ce48695c8a68abe5788b4ccda3e8653e 100644 (file)
@@ -1,33 +1,18 @@
 /*
- * test_ctf_writer.c
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * CTF Writer test
- *
- * Copyright 2013 - 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; under version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Copyright (C) 2013-2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  */
 
-#include <babeltrace2/ctf-writer/writer.h>
-#include <babeltrace2/ctf-writer/clock.h>
-#include <babeltrace2/ctf-writer/clock-class.h>
-#include <babeltrace2/ctf-writer/stream.h>
-#include <babeltrace2/ctf-writer/event.h>
-#include <babeltrace2/ctf-writer/event-types.h>
-#include <babeltrace2/ctf-writer/event-fields.h>
-#include <babeltrace2/ctf-writer/stream-class.h>
-#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2-ctf-writer/writer.h>
+#include <babeltrace2-ctf-writer/clock.h>
+#include <babeltrace2-ctf-writer/clock-class.h>
+#include <babeltrace2-ctf-writer/stream.h>
+#include <babeltrace2-ctf-writer/event.h>
+#include <babeltrace2-ctf-writer/event-types.h>
+#include <babeltrace2-ctf-writer/event-fields.h>
+#include <babeltrace2-ctf-writer/stream-class.h>
+#include <babeltrace2-ctf-writer/trace.h>
 #include <babeltrace2/babeltrace.h>
 #include <glib.h>
 #include <unistd.h>
@@ -97,7 +82,7 @@ void validate_trace(char *parser_path, char *trace_path)
 {
        int ret = 0;
        gint exit_status;
-       char *argv[] = {parser_path, trace_path, "-o", "dummy", NULL};
+       const char *argv[] = {parser_path, trace_path, "-o", "dummy", NULL};
 
        if (!parser_path || !trace_path) {
                ret = -1;
@@ -105,7 +90,7 @@ void validate_trace(char *parser_path, char *trace_path)
        }
 
        if (!g_spawn_sync(NULL,
-                       argv,
+                       (gchar **) argv,
                        NULL,
                        G_SPAWN_STDOUT_TO_DEV_NULL,
                        NULL,
@@ -247,7 +232,7 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
        ok(bt_ctf_field_type_enumeration_signed_get_mapping_by_index(enum_type, 6, &ret_char,
                &ret_range_start_int64_t, &ret_range_end_int64_t) == 0,
                "bt_ctf_field_type_enumeration_signed_get_mapping_by_index returns a value");
-       ok(!strcmp(ret_char, mapping_name_test),
+       ok(strcmp(ret_char, mapping_name_test) == 0,
                "bt_ctf_field_type_enumeration_signed_get_mapping_by_index returns a correct mapping name");
        ok(ret_range_start_int64_t == 42,
                "bt_ctf_field_type_enumeration_signed_get_mapping_by_index returns a correct mapping start");
@@ -289,7 +274,7 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
        ok(bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index(enum_type_unsigned, 4, &ret_char,
                &ret_range_start_uint64_t, &ret_range_end_uint64_t) == 0,
                "bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index returns a value");
-       ok(!strcmp(ret_char, mapping_name_test),
+       ok(strcmp(ret_char, mapping_name_test) == 0,
                "bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index returns a correct mapping name");
        ok(ret_range_start_uint64_t == 42,
                "bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index returns a correct mapping start");
@@ -580,7 +565,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
        bt_ctf_object_put_ref(ret_field_type);
 
        ret_string = bt_ctf_field_type_variant_get_tag_name(variant_type);
-       ok(ret_string ? !strcmp(ret_string, "variant_selector") : 0,
+       ok(ret_string ? strcmp(ret_string, "variant_selector") == 0 : 0,
                "bt_ctf_field_type_variant_get_tag_name returns the correct variant tag name");
        ret_field_type = bt_ctf_field_type_variant_get_field_type_by_name(
                variant_type, "INT16_TYPE");
@@ -598,7 +583,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
                "bt_ctf_field_type_variant_get_field handles a NULL field type correctly");
        ok(bt_ctf_field_type_variant_get_field_by_index(variant_type, &ret_string, &ret_field_type, 1) == 0,
                "bt_ctf_field_type_variant_get_field returns a field");
-       ok(!strcmp("INT16_TYPE", ret_string),
+       ok(strcmp("INT16_TYPE", ret_string) == 0,
                "bt_ctf_field_type_variant_get_field returns a correct field name");
        ok(ret_field_type == int_16_type,
                "bt_ctf_field_type_variant_get_field returns a correct field type");
@@ -635,7 +620,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
                "Add composite structure to an event");
 
        ret_string = bt_ctf_event_class_get_name(event_class);
-       ok(!strcmp(ret_string, complex_test_event_string),
+       ok(strcmp(ret_string, complex_test_event_string) == 0,
                "bt_ctf_event_class_get_name returns a correct name");
        ok(bt_ctf_event_class_get_id(event_class) < 0,
                "bt_ctf_event_class_get_id returns a negative value when not set");
@@ -659,11 +644,11 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
                "bt_ctf_event_class_set_log_level succeeds with a valid log level");
        ok(bt_ctf_event_class_get_log_level(event_class) == BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO,
                "bt_ctf_event_class_get_log_level returns the expected log level");
-       ok(bt_ctf_event_class_set_emf_uri(NULL, "http://diamon.org/babeltrace/"),
+       ok(bt_ctf_event_class_set_emf_uri(NULL, "https://babeltrace.org/"),
                "bt_ctf_event_class_set_emf_uri handles a NULL event class correctly");
-       ok(!bt_ctf_event_class_set_emf_uri(event_class, "http://diamon.org/babeltrace/"),
+       ok(!bt_ctf_event_class_set_emf_uri(event_class, "https://babeltrace.org/"),
                "bt_ctf_event_class_set_emf_uri succeeds with a valid EMF URI");
-       ok(strcmp(bt_ctf_event_class_get_emf_uri(event_class), "http://diamon.org/babeltrace/") == 0,
+       ok(strcmp(bt_ctf_event_class_get_emf_uri(event_class), "https://babeltrace.org/") == 0,
                "bt_ctf_event_class_get_emf_uri returns the expected EMF URI");
        ok(!bt_ctf_event_class_set_emf_uri(event_class, NULL),
                "bt_ctf_event_class_set_emf_uri succeeds with NULL (to reset)");
@@ -681,7 +666,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
                "bt_ctf_event_class_get_stream_class returns the correct stream class");
        bt_ctf_object_put_ref(ret_stream_class);
 
-       ok(bt_ctf_event_class_get_field_by_name(event_class, "truie") == NULL,
+       ok(!bt_ctf_event_class_get_field_by_name(event_class, "truie"),
                "bt_ctf_event_class_get_field_by_name handles an invalid field name correctly");
        ret_field_type = bt_ctf_event_class_get_field_by_name(event_class,
                "complex_structure");
@@ -758,7 +743,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
 
        ret_string = bt_ctf_field_string_get_value(a_string_field);
        ok(ret_string, "bt_ctf_field_string_get_value returns a string");
-       ok(ret_string ? !strcmp(ret_string, test_string_cat) : 0,
+       ok(ret_string ? strcmp(ret_string, test_string_cat) == 0 : 0,
                "bt_ctf_field_string_get_value returns a correct value");
        bt_ctf_field_integer_unsigned_set_value(uint_35_field,
                SEQUENCE_TEST_LENGTH);
@@ -836,7 +821,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
 }
 
 static
-void type_field_tests()
+void type_field_tests(void)
 {
        struct bt_ctf_field *uint_12;
        struct bt_ctf_field *int_16;
@@ -933,7 +918,7 @@ void type_field_tests()
 
        ret_string = bt_ctf_field_type_sequence_get_length_field_name(
                sequence_type);
-       ok(!strcmp(ret_string, "seq_len"),
+       ok(strcmp(ret_string, "seq_len") == 0,
                "bt_ctf_field_type_sequence_get_length_field_name returns the correct value");
        returned_type = bt_ctf_field_type_sequence_get_element_field_type(
                sequence_type);
@@ -982,7 +967,7 @@ void type_field_tests()
        ok(bt_ctf_field_type_structure_get_field(structure_seq_type,
                &ret_string, &returned_type, 1) == 0,
                "bt_ctf_field_type_structure_get_field returns a field");
-       ok(!strcmp(ret_string, "a_sequence"),
+       ok(strcmp(ret_string, "a_sequence") == 0,
                "bt_ctf_field_type_structure_get_field returns a correct field name");
        ok(returned_type == sequence_type,
                "bt_ctf_field_type_structure_get_field returns a correct field type");
@@ -1217,7 +1202,7 @@ void test_empty_stream(struct bt_ctf_writer *writer)
        ret = bt_ctf_stream_class_set_event_header_type(stream_class, NULL);
        BT_ASSERT(ret == 0);
 
-       ok(bt_ctf_stream_class_get_trace(stream_class) == NULL,
+       ok(!bt_ctf_stream_class_get_trace(stream_class),
                "bt_ctf_stream_class_get_trace returns NULL when stream class is orphaned");
 
        stream = bt_ctf_writer_create_stream(writer, stream_class);
@@ -1711,13 +1696,13 @@ int main(int argc, char **argv)
                name.machine);
 
        /* Define a clock and add it to the trace */
-       ok(bt_ctf_clock_create("signed") == NULL,
+       ok(!bt_ctf_clock_create("signed"),
                "Illegal clock name rejected");
        clock = bt_ctf_clock_create(clock_name);
        ok(clock, "Clock created sucessfully");
        returned_clock_name = bt_ctf_clock_get_name(clock);
        ok(returned_clock_name, "bt_ctf_clock_get_name returns a clock name");
-       ok(returned_clock_name ? !strcmp(returned_clock_name, clock_name) : 0,
+       ok(returned_clock_name ? strcmp(returned_clock_name, clock_name) == 0 : 0,
                "Returned clock name is valid");
 
        returned_clock_description = bt_ctf_clock_get_description(clock);
@@ -1729,7 +1714,7 @@ int main(int argc, char **argv)
        ok(returned_clock_description,
                "bt_ctf_clock_get_description returns a description.");
        ok(returned_clock_description ?
-               !strcmp(returned_clock_description, clock_description) : 0,
+               strcmp(returned_clock_description, clock_description) == 0 : 0,
                "Returned clock description is valid");
 
        ok(bt_ctf_clock_get_frequency(clock) == DEFAULT_CLOCK_FREQ,
@@ -1795,12 +1780,12 @@ int main(int argc, char **argv)
        /* Define a stream class */
        stream_class = bt_ctf_stream_class_create("test_stream");
        ret_string = bt_ctf_stream_class_get_name(stream_class);
-       ok(ret_string && !strcmp(ret_string, "test_stream"),
+       ok(ret_string && strcmp(ret_string, "test_stream") == 0,
                "bt_ctf_stream_class_get_name returns a correct stream class name");
 
-       ok(bt_ctf_stream_class_get_clock(stream_class) == NULL,
+       ok(!bt_ctf_stream_class_get_clock(stream_class),
                "bt_ctf_stream_class_get_clock returns NULL when a clock was not set");
-       ok(bt_ctf_stream_class_get_clock(NULL) == NULL,
+       ok(!bt_ctf_stream_class_get_clock(NULL),
                "bt_ctf_stream_class_get_clock handles NULL correctly");
 
        ok(stream_class, "Create stream class");
@@ -2001,7 +1986,7 @@ int main(int argc, char **argv)
                "Changes to a stream class that was already instantiated fail");
 
        /* Populate the custom packet header field only once for all tests */
-       ok(bt_ctf_stream_get_packet_header(NULL) == NULL,
+       ok(!bt_ctf_stream_get_packet_header(NULL),
                "bt_ctf_stream_get_packet_header handles NULL correctly");
        packet_header = bt_ctf_stream_get_packet_header(stream1);
        ok(packet_header,
This page took 0.027351 seconds and 4 git commands to generate.