Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / tests / unit / test_kernel_data.cpp
index 4451f65b7f1bd52f01e1621a9cf045983403eae1..2deaef72057050e4ea903f4e0c27864e4f78a892 100644 (file)
@@ -5,19 +5,18 @@
  *
  */
 
+#include <common/compat/errno.hpp>
+#include <common/defaults.hpp>
+
+#include <bin/lttng-sessiond/trace-kernel.hpp>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <time.h>
-
-#include <common/compat/errno.h>
-#include <bin/lttng-sessiond/trace-kernel.h>
-#include <common/defaults.h>
-
 #include <tap/tap.h>
+#include <time.h>
+#include <unistd.h>
 
-#define RANDOM_STRING_LEN      11
+#define RANDOM_STRING_LEN 11
 
 /* Number of TAP tests in this file */
 #define NUM_TESTS 11
 LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
 #endif
 
-static const char alphanum[] =
-       "0123456789"
-       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-       "abcdefghijklmnopqrstuvwxyz";
+static const char alphanum[] = "0123456789"
+                              "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                              "abcdefghijklmnopqrstuvwxyz";
 
 static struct ltt_kernel_session *kern;
 static char random_string[RANDOM_STRING_LEN];
@@ -40,7 +38,7 @@ static char random_string[RANDOM_STRING_LEN];
  * Return random string of 10 characters.
  * Not thread-safe.
  */
-static char *get_random_string(void)
+static char *get_random_string()
 {
        int i;
 
@@ -53,51 +51,42 @@ static char *get_random_string(void)
        return random_string;
 }
 
-static void test_create_one_kernel_session(void)
+static void test_create_one_kernel_session()
 {
        kern = trace_kernel_create_session();
-       ok(kern != NULL, "Create kernel session");
+       ok(kern != nullptr, "Create kernel session");
 
        if (!kern) {
                skip(1, "Kernel session is null");
                return;
        }
-       ok(kern->fd == -1 &&
-          kern->metadata_stream_fd == -1 &&
-          kern->consumer_fds_sent == 0 &&
-          kern->channel_count == 0 &&
-          kern->stream_count_global == 0 &&
-          kern->metadata == NULL,
+       ok(kern->fd == -1 && kern->metadata_stream_fd == -1 && kern->consumer_fds_sent == 0 &&
+                  kern->channel_count == 0 && kern->stream_count_global == 0 &&
+                  kern->metadata == nullptr,
           "Validate kernel session");
 }
 
-static void test_create_kernel_metadata(void)
+static void test_create_kernel_metadata()
 {
-       LTTNG_ASSERT(kern != NULL);
+       LTTNG_ASSERT(kern != nullptr);
 
        kern->metadata = trace_kernel_create_metadata();
-       ok(kern->metadata != NULL, "Create kernel metadata");
-
-       ok(kern->metadata->fd == -1 &&
-          kern->metadata->conf != NULL &&
-          kern->metadata->conf->attr.overwrite
-                       == DEFAULT_METADATA_OVERWRITE &&
-          kern->metadata->conf->attr.subbuf_size
-                       == default_get_metadata_subbuf_size() &&
-          kern->metadata->conf->attr.num_subbuf
-                       == DEFAULT_METADATA_SUBBUF_NUM &&
-          kern->metadata->conf->attr.switch_timer_interval
-                       == DEFAULT_METADATA_SWITCH_TIMER &&
-          kern->metadata->conf->attr.read_timer_interval
-                       == DEFAULT_METADATA_READ_TIMER &&
-          kern->metadata->conf->attr.output
-                       == LTTNG_EVENT_MMAP,
+       ok(kern->metadata != nullptr, "Create kernel metadata");
+
+       ok(kern->metadata->fd == -1 && kern->metadata->conf != nullptr &&
+                  kern->metadata->conf->attr.overwrite == DEFAULT_METADATA_OVERWRITE &&
+                  kern->metadata->conf->attr.subbuf_size == default_get_metadata_subbuf_size() &&
+                  kern->metadata->conf->attr.num_subbuf == DEFAULT_METADATA_SUBBUF_NUM &&
+                  kern->metadata->conf->attr.switch_timer_interval ==
+                          DEFAULT_METADATA_SWITCH_TIMER &&
+                  kern->metadata->conf->attr.read_timer_interval == DEFAULT_METADATA_READ_TIMER &&
+                  kern->metadata->conf->attr.output == LTTNG_EVENT_MMAP,
           "Validate kernel session metadata");
 
        trace_kernel_destroy_metadata(kern->metadata);
 }
 
-static void test_create_kernel_channel(void)
+static void test_create_kernel_channel()
 {
        struct ltt_kernel_channel *chan;
        struct lttng_channel attr;
@@ -108,17 +97,15 @@ static void test_create_kernel_channel(void)
        attr.attr.extended.ptr = &extended;
 
        chan = trace_kernel_create_channel(&attr);
-       ok(chan != NULL, "Create kernel channel");
+       ok(chan != nullptr, "Create kernel channel");
 
        if (!chan) {
                skip(1, "Channel is null");
                return;
        }
 
-       ok(chan->fd == -1 &&
-          chan->enabled == 1 &&
-          chan->stream_count == 0 &&
-          chan->channel->attr.overwrite  == attr.attr.overwrite,
+       ok(chan->fd == -1 && chan->enabled && chan->stream_count == 0 &&
+                  chan->channel->attr.overwrite == attr.attr.overwrite,
           "Validate kernel channel");
 
        /* Init list in order to avoid sefaults from cds_list_del */
@@ -126,20 +113,19 @@ static void test_create_kernel_channel(void)
        trace_kernel_destroy_channel(chan);
 }
 
-static void test_create_kernel_event(void)
+static void test_create_kernel_event()
 {
        enum lttng_error_code ret;
        struct ltt_kernel_event *event;
        struct lttng_event ev;
 
        memset(&ev, 0, sizeof(ev));
-       ok(!lttng_strncpy(ev.name, get_random_string(),
-                       RANDOM_STRING_LEN),
-               "Validate string length");
+       ok(!lttng_strncpy(ev.name, get_random_string(), RANDOM_STRING_LEN),
+          "Validate string length");
        ev.type = LTTNG_EVENT_TRACEPOINT;
        ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
 
-       ret = trace_kernel_create_event(&ev, NULL, NULL, &event);
+       ret = trace_kernel_create_event(&ev, nullptr, nullptr, &event);
        ok(ret == LTTNG_OK, "Create kernel event");
 
        if (!event) {
@@ -147,10 +133,9 @@ static void test_create_kernel_event(void)
                return;
        }
 
-       ok(event->fd == -1 &&
-          event->enabled == 1 &&
-          event->event->instrumentation == LTTNG_KERNEL_ABI_TRACEPOINT &&
-          strlen(event->event->name),
+       ok(event->fd == -1 && event->enabled &&
+                  event->event->instrumentation == LTTNG_KERNEL_ABI_TRACEPOINT &&
+                  strlen(event->event->name),
           "Validate kernel event");
 
        /* Init list in order to avoid sefaults from cds_list_del */
@@ -158,28 +143,26 @@ static void test_create_kernel_event(void)
        trace_kernel_destroy_event(event);
 }
 
-static void test_create_kernel_stream(void)
+static void test_create_kernel_stream()
 {
        struct ltt_kernel_stream *stream;
 
        stream = trace_kernel_create_stream("stream1", 0);
-       ok(stream != NULL, "Create kernel stream");
+       ok(stream != nullptr, "Create kernel stream");
 
        if (!stream) {
                skip(1, "Stream is null");
                return;
        }
 
-       ok(stream->fd == -1 &&
-          stream->state == 0,
-          "Validate kernel stream");
+       ok(stream->fd == -1 && stream->state == 0, "Validate kernel stream");
 
        /* Init list in order to avoid sefaults from cds_list_del */
        CDS_INIT_LIST_HEAD(&stream->list);
        trace_kernel_destroy_stream(stream);
 }
 
-int main(int argc, char **argv)
+int main()
 {
        plan_tests(NUM_TESTS);
 
This page took 0.026589 seconds and 4 git commands to generate.