[PATCH 13/13] perf test: Add attr tests under builtin test command

From: Jiri Olsa
Date: Fri Aug 24 2012 - 05:01:34 EST


The test attr suite is run only if it's run under perf source
directory, because test attr files are not installed.

If run elsewhere, tests are ommited (notification is displayed)
and finished as successfull.

Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/builtin-test.c | 4 ++++
tools/perf/perf.h | 1 +
tools/perf/util/test-attr.c | 14 ++++++++++++++
3 files changed, 19 insertions(+)

diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 381d5ab..f2d3c50 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -1135,6 +1135,10 @@ static struct test {
.func = dso__test_data,
},
{
+ .desc = "Test perf attr",
+ .func = test_attr__run,
+ },
+ {
.func = NULL,
},
};
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index a67bb75..2039774 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -174,6 +174,7 @@ void test_attr__init(void);
int test_attr__open(struct perf_event_attr *attr,
pid_t pid, int cpu, int group_fd,
unsigned long flags);
+int test_attr__run(void);

static inline int
sys_perf_event_open(struct perf_event_attr *attr,
diff --git a/tools/perf/util/test-attr.c b/tools/perf/util/test-attr.c
index dd83954..eb610f7 100644
--- a/tools/perf/util/test-attr.c
+++ b/tools/perf/util/test-attr.c
@@ -126,3 +126,17 @@ int test_attr__open(struct perf_event_attr *attr,

return fd;
}
+
+int test_attr__run(void)
+{
+ struct stat st;
+ const char *run;
+
+ run = "python ./util/test-attr.py -d ./util/test-attr/ -p ./perf";
+
+ if (!lstat("./util/", &st))
+ return system(run);
+
+ fprintf(stderr, " (ommitted)");
+ return 0;
+}
--
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/