]> git.karo-electronics.de Git - linux-beck.git/commitdiff
perf tests: Move perf_evsel__tp_sched_test into separate object
authorJiri Olsa <jolsa@redhat.com>
Sat, 10 Nov 2012 00:46:48 +0000 (01:46 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 14 Nov 2012 19:50:02 +0000 (16:50 -0300)
Separating perf_evsel__tp_sched_test test from the builtin-test into
evsel-tp-sched object.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1352508412-16914-9-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Makefile
tools/perf/tests/builtin-test.c
tools/perf/tests/evsel-tp-sched.c [new file with mode: 0644]
tools/perf/tests/tests.h

index ad6fcb5f582cf1dc369aa9a4723c644ad08b5ad7..e510b53eb8df41ecc81c9bfcd5a0ac0ea97b465e 100644 (file)
@@ -438,6 +438,7 @@ LIB_OBJS += $(OUTPUT)tests/mmap-basic.o
 LIB_OBJS += $(OUTPUT)tests/perf-record.o
 LIB_OBJS += $(OUTPUT)tests/rdpmc.o
 LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o
+LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o
 LIB_OBJS += $(OUTPUT)tests/util.o
 
 BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
index 93f5e9176e68f0b308e72aae6292c5d0a4939835..c66caa79c622960c15dfd3e1fcc67446a9cdb372 100644 (file)
@@ -35,87 +35,6 @@ static int test__perf_pmu(void)
        return perf_pmu__test();
 }
 
-static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
-                                 int size, bool should_be_signed)
-{
-       struct format_field *field = perf_evsel__field(evsel, name);
-       int is_signed;
-       int ret = 0;
-
-       if (field == NULL) {
-               pr_debug("%s: \"%s\" field not found!\n", evsel->name, name);
-               return -1;
-       }
-
-       is_signed = !!(field->flags | FIELD_IS_SIGNED);
-       if (should_be_signed && !is_signed) {
-               pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
-                        evsel->name, name, is_signed, should_be_signed);
-               ret = -1;
-       }
-
-       if (field->size != size) {
-               pr_debug("%s: \"%s\" size (%d) should be %d!\n",
-                        evsel->name, name, field->size, size);
-               ret = -1;
-       }
-
-       return ret;
-}
-
-static int perf_evsel__tp_sched_test(void)
-{
-       struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch", 0);
-       int ret = 0;
-
-       if (evsel == NULL) {
-               pr_debug("perf_evsel__new\n");
-               return -1;
-       }
-
-       if (perf_evsel__test_field(evsel, "prev_comm", 16, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "prev_pid", 4, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "prev_prio", 4, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "prev_state", 8, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "next_comm", 16, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "next_pid", 4, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "next_prio", 4, true))
-               ret = -1;
-
-       perf_evsel__delete(evsel);
-
-       evsel = perf_evsel__newtp("sched", "sched_wakeup", 0);
-
-       if (perf_evsel__test_field(evsel, "comm", 16, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "pid", 4, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "prio", 4, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "success", 4, true))
-               ret = -1;
-
-       if (perf_evsel__test_field(evsel, "target_cpu", 4, true))
-               ret = -1;
-
-       return ret;
-}
-
 static int test__syscall_open_tp_fields(void)
 {
        struct perf_record_opts opts = {
@@ -276,7 +195,7 @@ static struct test {
        },
        {
                .desc = "Check parsing of sched tracepoints fields",
-               .func = perf_evsel__tp_sched_test,
+               .func = test__perf_evsel__tp_sched_test,
        },
        {
                .desc = "Generate and check syscalls:sys_enter_open event fields",
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
new file mode 100644 (file)
index 0000000..a5d2fcc
--- /dev/null
@@ -0,0 +1,84 @@
+#include "evsel.h"
+#include "tests.h"
+#include "event-parse.h"
+
+static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
+                                 int size, bool should_be_signed)
+{
+       struct format_field *field = perf_evsel__field(evsel, name);
+       int is_signed;
+       int ret = 0;
+
+       if (field == NULL) {
+               pr_debug("%s: \"%s\" field not found!\n", evsel->name, name);
+               return -1;
+       }
+
+       is_signed = !!(field->flags | FIELD_IS_SIGNED);
+       if (should_be_signed && !is_signed) {
+               pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
+                        evsel->name, name, is_signed, should_be_signed);
+               ret = -1;
+       }
+
+       if (field->size != size) {
+               pr_debug("%s: \"%s\" size (%d) should be %d!\n",
+                        evsel->name, name, field->size, size);
+               ret = -1;
+       }
+
+       return ret;
+}
+
+int test__perf_evsel__tp_sched_test(void)
+{
+       struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch", 0);
+       int ret = 0;
+
+       if (evsel == NULL) {
+               pr_debug("perf_evsel__new\n");
+               return -1;
+       }
+
+       if (perf_evsel__test_field(evsel, "prev_comm", 16, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "prev_pid", 4, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "prev_prio", 4, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "prev_state", 8, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "next_comm", 16, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "next_pid", 4, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "next_prio", 4, true))
+               ret = -1;
+
+       perf_evsel__delete(evsel);
+
+       evsel = perf_evsel__newtp("sched", "sched_wakeup", 0);
+
+       if (perf_evsel__test_field(evsel, "comm", 16, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "pid", 4, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "prio", 4, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "success", 4, true))
+               ret = -1;
+
+       if (perf_evsel__test_field(evsel, "target_cpu", 4, true))
+               ret = -1;
+
+       return ret;
+}
index 5897dd13efa3ecbf24d72a028cdcc1c16c46d825..1ef265d84a6ec61cb48428e8f5b6afbb37bb71d3 100644 (file)
@@ -9,6 +9,7 @@ int test__basic_mmap(void);
 int test__PERF_RECORD(void);
 int test__rdpmc(void);
 int test__perf_evsel__roundtrip_name_test(void);
+int test__perf_evsel__tp_sched_test(void);
 
 /* Util */
 int trace_event__id(const char *evname);