linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jiri@mellanox.com, acme@redhat.com, jolsa@kernel.org,
	hpa@zytor.com, a.p.zijlstra@chello.nl, namhyung@kernel.org,
	tglx@linutronix.de, dsahern@gmail.com,
	linux-kernel@vger.kernel.org, mingo@kernel.org,
	rostedt@goodmis.org
Subject: [tip:perf/core] perf tests: Add is_printable_array test
Date: Mon, 18 Jul 2016 23:55:28 -0700	[thread overview]
Message-ID: <tip-988dd774dcbd9151c2a643fc7284c5c3c4d0adb7@git.kernel.org> (raw)
In-Reply-To: <1468685480-18951-4-git-send-email-jolsa@kernel.org>

Commit-ID:  988dd774dcbd9151c2a643fc7284c5c3c4d0adb7
Gitweb:     http://git.kernel.org/tip/988dd774dcbd9151c2a643fc7284c5c3c4d0adb7
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Sat, 16 Jul 2016 18:11:20 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 18 Jul 2016 19:50:35 -0300

perf tests: Add is_printable_array test

Add automated test for is_printable_array function.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1468685480-18951-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/Build                |  1 +
 tools/perf/tests/builtin-test.c       |  4 ++++
 tools/perf/tests/is_printable_array.c | 36 +++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h              |  1 +
 4 files changed, 42 insertions(+)

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 4158422..cb20ae1 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -40,6 +40,7 @@ perf-y += event_update.o
 perf-y += event-times.o
 perf-y += backward-ring-buffer.o
 perf-y += sdt.o
+perf-y += is_printable_array.o
 
 $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
 	$(call rule_mkdir)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 4dd2d05..10eb306 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -222,6 +222,10 @@ static struct test generic_tests[] = {
 		.func = test__sdt_event,
 	},
 	{
+		.desc = "Test is_printable_array function",
+		.func = test__is_printable_array,
+	},
+	{
 		.func = NULL,
 	},
 };
diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c
new file mode 100644
index 0000000..42e1339
--- /dev/null
+++ b/tools/perf/tests/is_printable_array.c
@@ -0,0 +1,36 @@
+#include <linux/compiler.h>
+#include "tests.h"
+#include "debug.h"
+#include "util.h"
+
+int test__is_printable_array(int subtest __maybe_unused)
+{
+	char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 };
+	char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 };
+	struct {
+		char		*buf;
+		unsigned int	 len;
+		int		 ret;
+	} t[] = {
+		{ (char *) "krava",	sizeof("krava"),	1 },
+		{ (char *) "krava",	sizeof("krava") - 1,	0 },
+		{ (char *) "",		sizeof(""),		1 },
+		{ (char *) "",		0,			0 },
+		{ NULL,			0,			0 },
+		{ buf1,			sizeof(buf1),		0 },
+		{ buf2,			sizeof(buf2),		0 },
+	};
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(t); i++) {
+		int ret;
+
+		ret = is_printable_array((char *) t[i].buf, t[i].len);
+		if (ret != t[i].ret) {
+			pr_err("failed: test %u\n", i);
+			return TEST_FAIL;
+		}
+	}
+
+	return TEST_OK;
+}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index a0288f8..9bfc0e0 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -89,6 +89,7 @@ int test__event_times(int subtest);
 int test__backward_ring_buffer(int subtest);
 int test__cpu_map_print(int subtest);
 int test__sdt_event(int subtest);
+int test__is_printable_array(int subtest);
 
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT

      parent reply	other threads:[~2016-07-19  6:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-16 16:11 [PATCHv3 0/3] perf python: Add support to access tracepoint fields Jiri Olsa
2016-07-16 16:11 ` [PATCH 1/3] perf script python: Fix string vs byte array resolving Jiri Olsa
2016-07-18 11:44   ` Jiri Pirko
2016-07-19  6:54   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-07-16 16:11 ` [PATCH 2/3] perf tools: Make is_printable_array global Jiri Olsa
2016-07-18 11:44   ` Jiri Pirko
2016-07-19  6:54   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-07-16 16:11 ` [PATCH 3/3] perf tests: Add is_printable_array test Jiri Olsa
2016-07-18 11:46   ` Jiri Pirko
2016-07-18 12:14     ` Jiri Olsa
2016-07-18 22:49       ` Arnaldo Carvalho de Melo
2016-07-19  6:55   ` tip-bot for Jiri Olsa [this message]

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=tip-988dd774dcbd9151c2a643fc7284c5c3c4d0adb7@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jiri@mellanox.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).