[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1419405333-27952-13-git-send-email-namhyung@kernel.org>
Date: Wed, 24 Dec 2014 16:15:08 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Jiri Olsa <jolsa@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>,
Stephane Eranian <eranian@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Andi Kleen <andi@...stfloor.org>,
Frederic Weisbecker <fweisbec@...il.com>
Subject: [PATCH 12/37] perf tools: Add a test case for thread comm handling
The new test case checks various thread comm handling like overridding
and time sorting.
Cc: Frederic Weisbecker <fweisbec@...il.com>
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/Makefile.perf | 1 +
tools/perf/tests/builtin-test.c | 4 ++++
tools/perf/tests/tests.h | 1 +
tools/perf/tests/thread-comm.c | 47 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+)
create mode 100644 tools/perf/tests/thread-comm.c
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 763e68fb5767..e4528a4a3a8c 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -447,6 +447,7 @@ endif
LIB_OBJS += $(OUTPUT)tests/mmap-thread-lookup.o
LIB_OBJS += $(OUTPUT)tests/thread-mg-share.o
LIB_OBJS += $(OUTPUT)tests/switch-tracking.o
+LIB_OBJS += $(OUTPUT)tests/thread-comm.o
BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 4b7d9ab0f049..1b463d82a71a 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -167,6 +167,10 @@ static struct test {
.func = test__fdarray__add,
},
{
+ .desc = "Test thread comm handling",
+ .func = test__thread_comm,
+ },
+ {
.func = NULL,
},
};
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 00e776a87a9c..43ac17780629 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -51,6 +51,7 @@ int test__hists_cumulate(void);
int test__switch_tracking(void);
int test__fdarray__filter(void);
int test__fdarray__add(void);
+int test__thread_comm(void);
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/thread-comm.c b/tools/perf/tests/thread-comm.c
new file mode 100644
index 000000000000..b81a429a6305
--- /dev/null
+++ b/tools/perf/tests/thread-comm.c
@@ -0,0 +1,47 @@
+#include "tests.h"
+#include "machine.h"
+#include "thread.h"
+#include "debug.h"
+
+int test__thread_comm(void)
+{
+ struct machines machines;
+ struct machine *machine;
+ struct thread *t;
+
+ /*
+ * This test is to check whether it can retrieve a correct
+ * comm for a given time. When multi-file data storage is
+ * enabled, those task/comm events are processed first so the
+ * later sample should find a matching comm properly.
+ */
+ machines__init(&machines);
+ machine = &machines.host;
+
+ t = machine__findnew_thread(machine, 100, 100);
+ TEST_ASSERT_VAL("wrong init thread comm",
+ !strcmp(thread__comm_str(t), ":100"));
+
+ thread__set_comm(t, "perf-test1", 10000);
+ TEST_ASSERT_VAL("failed to override thread comm",
+ !strcmp(thread__comm_str(t), "perf-test1"));
+
+ thread__set_comm(t, "perf-test2", 20000);
+ thread__set_comm(t, "perf-test3", 30000);
+ thread__set_comm(t, "perf-test4", 40000);
+
+ TEST_ASSERT_VAL("failed to find timed comm",
+ !strcmp(thread__comm_time_str(t, 20000), "perf-test2"));
+ TEST_ASSERT_VAL("failed to find timed comm",
+ !strcmp(thread__comm_time_str(t, 35000), "perf-test3"));
+ TEST_ASSERT_VAL("failed to find timed comm",
+ !strcmp(thread__comm_time_str(t, 50000), "perf-test4"));
+
+ thread__set_comm(t, "perf-test1.5", 15000);
+ TEST_ASSERT_VAL("failed to sort timed comm",
+ !strcmp(thread__comm_time_str(t, 15000), "perf-test1.5"));
+
+ machine__delete_threads(machine);
+ machines__exit(&machines);
+ return 0;
+}
--
2.1.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists