X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Funit%2Ftest_kernel_data.c;h=444ae86ae200aad7bb0ef2755465972678d06f8b;hp=5b82672d73206d5045dfd35a8d9c097b29238857;hb=d42266a417afa6e8ca6024590b8282002aebca07;hpb=645328ae989e5f50a3a49c1ac34b2fee287a3d7b diff --git a/tests/unit/test_kernel_data.c b/tests/unit/test_kernel_data.c index 5b82672d7..444ae86ae 100644 --- a/tests/unit/test_kernel_data.c +++ b/tests/unit/test_kernel_data.c @@ -1,22 +1,10 @@ /* - * Copyright (c) 2011 David Goulet + * Copyright (C) 2011 David Goulet * - * 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 - * as published by the Free Software Foundation; only version 2 - * of the License. + * SPDX-License-Identifier: GPL-2.0-only * - * 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. */ -#define _GNU_SOURCE #include #include #include @@ -33,14 +21,12 @@ #define RANDOM_STRING_LEN 11 /* Number of TAP tests in this file */ -#define NUM_TESTS 10 +#define NUM_TESTS 11 /* For error.h */ int lttng_opt_quiet = 1; int lttng_opt_verbose; - -int ust_consumerd32_fd; -int ust_consumerd64_fd; +int lttng_opt_mi; static const char alphanum[] = "0123456789" @@ -72,6 +58,10 @@ static void test_create_one_kernel_session(void) kern = trace_kernel_create_session(); ok(kern != NULL, "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 && @@ -91,17 +81,17 @@ static void test_create_kernel_metadata(void) ok(kern->metadata->fd == -1 && kern->metadata->conf != NULL && kern->metadata->conf->attr.overwrite - == DEFAULT_CHANNEL_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_KERNEL_CHANNEL_SWITCH_TIMER && + == DEFAULT_METADATA_SWITCH_TIMER && kern->metadata->conf->attr.read_timer_interval - == DEFAULT_KERNEL_CHANNEL_READ_TIMER && + == DEFAULT_METADATA_READ_TIMER && kern->metadata->conf->attr.output - == DEFAULT_KERNEL_CHANNEL_OUTPUT, + == LTTNG_EVENT_MMAP, "Validate kernel session metadata"); trace_kernel_destroy_metadata(kern->metadata); @@ -111,12 +101,20 @@ static void test_create_kernel_channel(void) { struct ltt_kernel_channel *chan; struct lttng_channel attr; + struct lttng_channel_extended extended; memset(&attr, 0, sizeof(attr)); + memset(&extended, 0, sizeof(extended)); + attr.attr.extended.ptr = &extended; chan = trace_kernel_create_channel(&attr); ok(chan != NULL, "Create kernel channel"); + if (!chan) { + skip(1, "Channel is null"); + return; + } + ok(chan->fd == -1 && chan->enabled == 1 && chan->stream_count == 0 && @@ -130,16 +128,24 @@ static void test_create_kernel_channel(void) static void test_create_kernel_event(void) { + enum lttng_error_code ret; struct ltt_kernel_event *event; struct lttng_event ev; memset(&ev, 0, sizeof(ev)); - strncpy(ev.name, get_random_string(), LTTNG_KERNEL_SYM_NAME_LEN); + 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; - event = trace_kernel_create_event(&ev); - ok(event != NULL, "Create kernel event"); + ret = trace_kernel_create_event(&ev, NULL, NULL, &event); + ok(ret == LTTNG_OK, "Create kernel event"); + + if (!event) { + skip(1, "Event is null"); + return; + } ok(event->fd == -1 && event->enabled == 1 && @@ -159,6 +165,11 @@ static void test_create_kernel_stream(void) stream = trace_kernel_create_stream("stream1", 0); ok(stream != NULL, "Create kernel stream"); + if (!stream) { + skip(1, "Stream is null"); + return; + } + ok(stream->fd == -1 && stream->state == 0, "Validate kernel stream");