All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
To: lttng-dev@lists.lttng.org
Cc: jgalar@efficios.com
Subject: [PATCH lttng-tools 1/3] Fix: test_kernel_data dereference of null pointer
Date: Tue, 17 Jan 2017 10:02:08 -0500	[thread overview]
Message-ID: <1484665330-22963-1-git-send-email-jonathan.rajotte-julien__38543.634574353$1484665386$gmane$org@efficios.com> (raw)

Skip tests when tested struct is null.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
---
 tests/unit/test_kernel_data.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tests/unit/test_kernel_data.c b/tests/unit/test_kernel_data.c
index 5bca684..6a35ea5 100644
--- a/tests/unit/test_kernel_data.c
+++ b/tests/unit/test_kernel_data.c
@@ -72,6 +72,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 &&
@@ -117,6 +121,11 @@ static void test_create_kernel_channel(void)
 	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 &&
@@ -143,6 +152,11 @@ static void test_create_kernel_event(void)
 	event = trace_kernel_create_event(&ev, NULL, NULL);
 	ok(event != NULL, "Create kernel event");
 
+	if (!event) {
+		skip(1, "Event is null");
+		return;
+	}
+
 	ok(event->fd == -1 &&
 	   event->enabled == 1 &&
 	   event->event->instrumentation == LTTNG_KERNEL_TRACEPOINT &&
@@ -161,6 +175,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");
-- 
2.7.4

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

             reply	other threads:[~2017-01-17 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17 15:02 Jonathan Rajotte [this message]
     [not found] <1484665330-22963-1-git-send-email-jonathan.rajotte-julien@efficios.com>
2017-01-17 15:05 ` [PATCH lttng-tools 1/3] Fix: test_kernel_data dereference of null pointer Jonathan Rajotte Julien
2017-01-26  0:32 ` Jérémie Galarneau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='1484665330-22963-1-git-send-email-jonathan.rajotte-julien__38543.634574353$1484665386$gmane$org@efficios.com' \
    --to=jonathan.rajotte-julien@efficios.com \
    --cc=jgalar@efficios.com \
    --cc=lttng-dev@lists.lttng.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.