All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 3/5] perf tests: Fix thread map test for -F option
Date: Tue, 28 Jun 2016 13:29:03 +0200	[thread overview]
Message-ID: <1467113345-12669-3-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1467113345-12669-1-git-send-email-jolsa@kernel.org>

I hit a bug when running test suite without forking
each test (-F option):

  $ perf test -Fv
  ...
  34: Test thread map                                          :
  --- start ---
  FAILED tests/thread-map.c:24 wrong comm
  ---- end ----
  Test thread map: FAILED!

The reason was the process name wasn't 'perf' as expected
by the test, because other tests set the name as well.

Setting it explicitly now.

Link: http://lkml.kernel.org/n/tip-bqapag0ljaiwmb7hlkw09zk5@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/thread-map.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index fccde848fe9c..cee2a2cdc933 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -1,13 +1,20 @@
 #include <sys/types.h>
 #include <unistd.h>
+#include <sys/prctl.h>
 #include "tests.h"
 #include "thread_map.h"
 #include "debug.h"
 
+#define NAME	(const char *) "perf"
+#define NAMEUL	(unsigned long) NAME
+
 int test__thread_map(int subtest __maybe_unused)
 {
 	struct thread_map *map;
 
+	TEST_ASSERT_VAL("failed to set process name",
+			!prctl(PR_SET_NAME, NAMEUL, 0, 0, 0));
+
 	/* test map on current pid */
 	map = thread_map__new_by_pid(getpid());
 	TEST_ASSERT_VAL("failed to alloc map", map);
@@ -19,7 +26,7 @@ int test__thread_map(int subtest __maybe_unused)
 			thread_map__pid(map, 0) == getpid());
 	TEST_ASSERT_VAL("wrong comm",
 			thread_map__comm(map, 0) &&
-			!strcmp(thread_map__comm(map, 0), "perf"));
+			!strcmp(thread_map__comm(map, 0), NAME));
 	TEST_ASSERT_VAL("wrong refcnt",
 			atomic_read(&map->refcnt) == 1);
 	thread_map__put(map);
@@ -51,7 +58,7 @@ static int process_event(struct perf_tool *tool __maybe_unused,
 
 	TEST_ASSERT_VAL("wrong nr",   map->nr == 1);
 	TEST_ASSERT_VAL("wrong pid",  map->entries[0].pid == (u64) getpid());
-	TEST_ASSERT_VAL("wrong comm", !strcmp(map->entries[0].comm, "perf"));
+	TEST_ASSERT_VAL("wrong comm", !strcmp(map->entries[0].comm, NAME));
 
 	threads = thread_map__new_event(&event->thread_map);
 	TEST_ASSERT_VAL("failed to alloc map", threads);
@@ -61,7 +68,7 @@ static int process_event(struct perf_tool *tool __maybe_unused,
 			thread_map__pid(threads, 0) == getpid());
 	TEST_ASSERT_VAL("wrong comm",
 			thread_map__comm(threads, 0) &&
-			!strcmp(thread_map__comm(threads, 0), "perf"));
+			!strcmp(thread_map__comm(threads, 0), NAME));
 	TEST_ASSERT_VAL("wrong refcnt",
 			atomic_read(&threads->refcnt) == 1);
 	thread_map__put(threads);
@@ -72,6 +79,9 @@ int test__thread_map_synthesize(int subtest __maybe_unused)
 {
 	struct thread_map *threads;
 
+	TEST_ASSERT_VAL("failed to set process name",
+			!prctl(PR_SET_NAME, NAMEUL, 0, 0, 0));
+
 	/* test map on current pid */
 	threads = thread_map__new_by_pid(getpid());
 	TEST_ASSERT_VAL("failed to alloc map", threads);
-- 
2.4.11

  parent reply	other threads:[~2016-06-28 11:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-28 11:29 [PATCH 1/5] perf test: Add -F/--dont-fork option Jiri Olsa
2016-06-28 11:29 ` [PATCH 2/5] perf tools: Allow to reset open files counter Jiri Olsa
2016-06-29 16:05   ` Nilay Vaish
2016-06-30 13:27     ` Nilay Vaish
2016-07-01  6:48   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-06-28 11:29 ` Jiri Olsa [this message]
2016-06-29 16:06   ` [PATCH 3/5] perf tests: Fix thread map test for -F option Nilay Vaish
2016-06-30 13:27     ` Nilay Vaish
2016-07-01  6:49   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-06-28 11:29 ` [PATCH 4/5] perf tools: Change cpu_map__fprintf output Jiri Olsa
2016-07-01  6:49   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-06-28 11:29 ` [PATCH 5/5] perf tools: Transform nodes string info to struct Jiri Olsa
2016-06-30 21:20   ` Arnaldo Carvalho de Melo
2016-07-01  6:17     ` Jiri Olsa
2016-06-29 16:04 ` [PATCH 1/5] perf test: Add -F/--dont-fork option Nilay Vaish
2016-06-29 16:07   ` Arnaldo Carvalho de Melo
2016-06-30 13:26     ` Nilay Vaish
2016-06-30 21:12 ` Arnaldo Carvalho de Melo
2016-07-01  6:49 ` [tip:perf/core] " tip-bot for Jiri Olsa

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=1467113345-12669-3-git-send-email-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.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.