Commit 6e5508a2 authored by Jiri Olsa's avatar Jiri Olsa Committed by Stefan Bader

perf tests: Add valid callback for parse-events test

BugLink: https://bugs.launchpad.net/bugs/1840081

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: default avatarJiri 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
(backported from commit 16ddcfbf)
[smb: drop intel_pt hunks as the test does not yet exist]
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 62797cbe
...@@ -1354,6 +1354,7 @@ struct evlist_test { ...@@ -1354,6 +1354,7 @@ struct evlist_test {
const char *name; const char *name;
__u32 type; __u32 type;
const int id; const int id;
bool (*valid)(void);
int (*check)(struct perf_evlist *evlist); int (*check)(struct perf_evlist *evlist);
}; };
...@@ -1644,6 +1645,11 @@ static int test_event(struct evlist_test *e) ...@@ -1644,6 +1645,11 @@ static int test_event(struct evlist_test *e)
struct perf_evlist *evlist; struct perf_evlist *evlist;
int ret; int ret;
if (e->valid && !e->valid()) {
pr_debug("... SKIP");
return 0;
}
evlist = perf_evlist__new(); evlist = perf_evlist__new();
if (evlist == NULL) if (evlist == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1669,10 +1675,11 @@ static int test_events(struct evlist_test *events, unsigned cnt) ...@@ -1669,10 +1675,11 @@ static int test_events(struct evlist_test *events, unsigned cnt)
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
struct evlist_test *e = &events[i]; struct evlist_test *e = &events[i];
pr_debug("running test %d '%s'\n", e->id, e->name); pr_debug("running test %d '%s'", e->id, e->name);
ret1 = test_event(e); ret1 = test_event(e);
if (ret1) if (ret1)
ret2 = ret1; ret2 = ret1;
pr_debug("\n");
} }
return ret2; return ret2;
...@@ -1754,7 +1761,7 @@ static int test_pmu_events(void) ...@@ -1754,7 +1761,7 @@ static int test_pmu_events(void)
} }
while (!ret && (ent = readdir(dir))) { while (!ret && (ent = readdir(dir))) {
struct evlist_test e; struct evlist_test e = { .id = 0, };
char name[2 * NAME_MAX + 1 + 12 + 3]; char name[2 * NAME_MAX + 1 + 12 + 3];
if (!strcmp(ent->d_name, ".") || if (!strcmp(ent->d_name, ".") ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment