summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2018-06-11 05:34:22 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-06-25 10:59:36 -0400
commit16ddcfbf7f3d07aa781e26b39f2c28636a4ed2fd (patch)
tree43a1bfc176a8681639f56b5058e4975f4fba9926 /tools/perf
parent933ccf2002aaef1037cb676622a694f5390c3d59 (diff)
perf tests: Add valid callback for parse-events test
Adding optional 'valid' callback for events tests in parse-events object, so we don't try to parse PMUs, which are not supported. Following line is displayed for skipped test: running test 52 'intel_pt//u'... SKIP Committer note: Use named initializers in the struct evlist_test variable to avoid breaking the build on centos:5, 6 and others with a similar gcc: cc1: warnings being treated as errors tests/parse-events.c: In function 'test_pmu_events': tests/parse-events.c:1817: error: missing initializer tests/parse-events.c:1817: error: (near initialization for 'e.type') Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Cc: Kim Phillips <kim.phillips@arm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Richter <tmricht@linux.ibm.com> Link: http://lkml.kernel.org/r/20180611093422.1005-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/tests/parse-events.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 9751e7563a45..61211918bfba 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1309,6 +1309,11 @@ static int test__checkevent_config_cache(struct perf_evlist *evlist)
1309 return 0; 1309 return 0;
1310} 1310}
1311 1311
1312static bool test__intel_pt_valid(void)
1313{
1314 return !!perf_pmu__find("intel_pt");
1315}
1316
1312static int test__intel_pt(struct perf_evlist *evlist) 1317static int test__intel_pt(struct perf_evlist *evlist)
1313{ 1318{
1314 struct perf_evsel *evsel = perf_evlist__first(evlist); 1319 struct perf_evsel *evsel = perf_evlist__first(evlist);
@@ -1375,6 +1380,7 @@ struct evlist_test {
1375 const char *name; 1380 const char *name;
1376 __u32 type; 1381 __u32 type;
1377 const int id; 1382 const int id;
1383 bool (*valid)(void);
1378 int (*check)(struct perf_evlist *evlist); 1384 int (*check)(struct perf_evlist *evlist);
1379}; 1385};
1380 1386
@@ -1648,6 +1654,7 @@ static struct evlist_test test__events[] = {
1648 }, 1654 },
1649 { 1655 {
1650 .name = "intel_pt//u", 1656 .name = "intel_pt//u",
1657 .valid = test__intel_pt_valid,
1651 .check = test__intel_pt, 1658 .check = test__intel_pt,
1652 .id = 52, 1659 .id = 52,
1653 }, 1660 },
@@ -1690,6 +1697,11 @@ static int test_event(struct evlist_test *e)
1690 struct perf_evlist *evlist; 1697 struct perf_evlist *evlist;
1691 int ret; 1698 int ret;
1692 1699
1700 if (e->valid && !e->valid()) {
1701 pr_debug("... SKIP");
1702 return 0;
1703 }
1704
1693 evlist = perf_evlist__new(); 1705 evlist = perf_evlist__new();
1694 if (evlist == NULL) 1706 if (evlist == NULL)
1695 return -ENOMEM; 1707 return -ENOMEM;
@@ -1716,10 +1728,11 @@ static int test_events(struct evlist_test *events, unsigned cnt)
1716 for (i = 0; i < cnt; i++) { 1728 for (i = 0; i < cnt; i++) {
1717 struct evlist_test *e = &events[i]; 1729 struct evlist_test *e = &events[i];
1718 1730
1719 pr_debug("running test %d '%s'\n", e->id, e->name); 1731 pr_debug("running test %d '%s'", e->id, e->name);
1720 ret1 = test_event(e); 1732 ret1 = test_event(e);
1721 if (ret1) 1733 if (ret1)
1722 ret2 = ret1; 1734 ret2 = ret1;
1735 pr_debug("\n");
1723 } 1736 }
1724 1737
1725 return ret2; 1738 return ret2;
@@ -1801,7 +1814,7 @@ static int test_pmu_events(void)
1801 } 1814 }
1802 1815
1803 while (!ret && (ent = readdir(dir))) { 1816 while (!ret && (ent = readdir(dir))) {
1804 struct evlist_test e; 1817 struct evlist_test e = { .id = 0, };
1805 char name[2 * NAME_MAX + 1 + 12 + 3]; 1818 char name[2 * NAME_MAX + 1 + 12 + 3];
1806 1819
1807 /* Names containing . are special and cannot be used directly */ 1820 /* Names containing . are special and cannot be used directly */