Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
On Sun, Jul 13, 2014 at 10:09:45PM +0200, Jiri Olsa wrote: > On Sun, Jul 13, 2014 at 01:49:59AM +0200, Andi Kleen wrote: > > > missing the tests/aliases.o file > > > > > > AR libperf.a > > > ar: tests/aliases.o: No such file or directory > > > > Fixed here (and in git) > > got it, would you be ok with following change? > using pr_* instead of fprintf calls.. Yes that's fine. Thanks. -Andi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
On Sun, Jul 13, 2014 at 01:49:59AM +0200, Andi Kleen wrote: > > missing the tests/aliases.o file > > > > AR libperf.a > > ar: tests/aliases.o: No such file or directory > > Fixed here (and in git) got it, would you be ok with following change? using pr_* instead of fprintf calls.. jirka --- diff --git a/tools/perf/tests/aliases.c b/tools/perf/tests/aliases.c index 08a5f01..f315fbc 100644 --- a/tools/perf/tests/aliases.c +++ b/tools/perf/tests/aliases.c @@ -25,7 +25,7 @@ static int test__event(const char *pmu, const char *name) * We only print on failure because common perf setups * have events that cannot be parsed. */ - fprintf(stderr, "invalid or unsupported event: '%s'\n", name); + pr_err("invalid or unsupported event: '%s'\n", name); ret = 0; failed++; } else @@ -42,7 +42,7 @@ int test__aliases(void) /* For now user must manually download */ if (0 && system("perf download > /dev/null") < 0) { /* Don't error out for this for now */ - fprintf(stderr, "perf download failed\n"); + pr_err("perf download failed\n"); } evlist = perf_evlist__new(); @@ -50,9 +50,9 @@ int test__aliases(void) return -ENOMEM; err = pmu_iterate_events(test__event); - fprintf(stderr, " Parsed %d events :", num_events); + pr_debug(" Parsed %d events :", num_events); if (failed > 0) - pr_debug(" %d events failed", failed); + pr_err(" %d events failed", failed); perf_evlist__delete(evlist); return err; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
On Sun, Jul 13, 2014 at 01:49:59AM +0200, Andi Kleen wrote: missing the tests/aliases.o file AR libperf.a ar: tests/aliases.o: No such file or directory Fixed here (and in git) got it, would you be ok with following change? using pr_* instead of fprintf calls.. jirka --- diff --git a/tools/perf/tests/aliases.c b/tools/perf/tests/aliases.c index 08a5f01..f315fbc 100644 --- a/tools/perf/tests/aliases.c +++ b/tools/perf/tests/aliases.c @@ -25,7 +25,7 @@ static int test__event(const char *pmu, const char *name) * We only print on failure because common perf setups * have events that cannot be parsed. */ - fprintf(stderr, invalid or unsupported event: '%s'\n, name); + pr_err(invalid or unsupported event: '%s'\n, name); ret = 0; failed++; } else @@ -42,7 +42,7 @@ int test__aliases(void) /* For now user must manually download */ if (0 system(perf download /dev/null) 0) { /* Don't error out for this for now */ - fprintf(stderr, perf download failed\n); + pr_err(perf download failed\n); } evlist = perf_evlist__new(); @@ -50,9 +50,9 @@ int test__aliases(void) return -ENOMEM; err = pmu_iterate_events(test__event); - fprintf(stderr, Parsed %d events :, num_events); + pr_debug( Parsed %d events :, num_events); if (failed 0) - pr_debug( %d events failed, failed); + pr_err( %d events failed, failed); perf_evlist__delete(evlist); return err; } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
On Sun, Jul 13, 2014 at 10:09:45PM +0200, Jiri Olsa wrote: On Sun, Jul 13, 2014 at 01:49:59AM +0200, Andi Kleen wrote: missing the tests/aliases.o file AR libperf.a ar: tests/aliases.o: No such file or directory Fixed here (and in git) got it, would you be ok with following change? using pr_* instead of fprintf calls.. Yes that's fine. Thanks. -Andi -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
> missing the tests/aliases.o file > > AR libperf.a > ar: tests/aliases.o: No such file or directory Fixed here (and in git) --- From: Andi Kleen Add a simple test case to perf test that runs perf download and parses all the available events, including json events. This needs adding an all event iterator to pmu.c v2: Rename identifiers v3: Only iterate cpu pmu to avoid bogus errors. Move pmu iterator to extra patch v4: Include aliases.c again Acked-by: Namhyung Kim Signed-off-by: Andi Kleen diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 0600425..6adb37f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -419,6 +419,7 @@ endif LIB_OBJS += $(OUTPUT)tests/code-reading.o LIB_OBJS += $(OUTPUT)tests/sample-parsing.o LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o +LIB_OBJS += $(OUTPUT)tests/aliases.o ifndef NO_DWARF_UNWIND ifeq ($(ARCH),$(filter $(ARCH),x86 arm)) LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o diff --git a/tools/perf/tests/aliases.c b/tools/perf/tests/aliases.c new file mode 100644 index 000..08a5f01 --- /dev/null +++ b/tools/perf/tests/aliases.c @@ -0,0 +1,58 @@ +/* Check if we can set up all aliases and can read JSON files */ +#include +#include "tests.h" +#include "pmu.h" +#include "evlist.h" +#include "parse-events.h" + +static struct perf_evlist *evlist; + +static int num_events; +static int failed; + +static int test__event(const char *pmu, const char *name) +{ + int ret; + + /* Not supported for now */ + if (strcmp(pmu, "cpu")) + return 0; + + ret = parse_events(evlist, name); + + if (ret) { + /* +* We only print on failure because common perf setups +* have events that cannot be parsed. +*/ + fprintf(stderr, "invalid or unsupported event: '%s'\n", name); + ret = 0; + failed++; + } else + num_events++; + return ret; +} + +int test__aliases(void) +{ + int err; + + /* Download JSON files */ + /* XXX assumes perf is installed */ + /* For now user must manually download */ + if (0 && system("perf download > /dev/null") < 0) { + /* Don't error out for this for now */ + fprintf(stderr, "perf download failed\n"); + } + + evlist = perf_evlist__new(); + if (evlist == NULL) + return -ENOMEM; + + err = pmu_iterate_events(test__event); + fprintf(stderr, " Parsed %d events :", num_events); + if (failed > 0) + pr_debug(" %d events failed", failed); + perf_evlist__delete(evlist); + return err; +} diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 6f8b01b..bb37ac2 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -154,6 +154,10 @@ static struct test { .func = test__hists_cumulate, }, { + .desc = "Test parsing JSON aliases", + .func = test__aliases, + }, + { .func = NULL, }, }; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index ed64790..ab92ad9 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -48,6 +48,7 @@ int test__mmap_thread_lookup(void); int test__thread_mg_share(void); int test__hists_output(void); int test__hists_cumulate(void); +int test__aliases(void); #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #ifdef HAVE_DWARF_UNWIND_SUPPORT -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
On Fri, Jul 11, 2014 at 04:59:24PM -0700, Andi Kleen wrote: > From: Andi Kleen > > Add a simple test case to perf test that runs perf download and parses > all the available events, including json events. > > This needs adding an all event iterator to pmu.c > > v2: Rename identifiers > v3: Only iterate cpu pmu to avoid bogus errors. > Move pmu iterator to extra patch > Acked-by: Namhyung Kim > Signed-off-by: Andi Kleen > --- > tools/perf/Makefile.perf| 1 + > tools/perf/tests/builtin-test.c | 4 > tools/perf/tests/tests.h| 1 + > 3 files changed, 6 insertions(+) > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > index 0600425..6adb37f 100644 > --- a/tools/perf/Makefile.perf > +++ b/tools/perf/Makefile.perf > @@ -419,6 +419,7 @@ endif > LIB_OBJS += $(OUTPUT)tests/code-reading.o > LIB_OBJS += $(OUTPUT)tests/sample-parsing.o > LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o > +LIB_OBJS += $(OUTPUT)tests/aliases.o missing the tests/aliases.o file AR libperf.a ar: tests/aliases.o: No such file or directory jirka -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
On Fri, Jul 11, 2014 at 04:59:24PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com Add a simple test case to perf test that runs perf download and parses all the available events, including json events. This needs adding an all event iterator to pmu.c v2: Rename identifiers v3: Only iterate cpu pmu to avoid bogus errors. Move pmu iterator to extra patch Acked-by: Namhyung Kim namhy...@kernel.org Signed-off-by: Andi Kleen a...@linux.intel.com --- tools/perf/Makefile.perf| 1 + tools/perf/tests/builtin-test.c | 4 tools/perf/tests/tests.h| 1 + 3 files changed, 6 insertions(+) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 0600425..6adb37f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -419,6 +419,7 @@ endif LIB_OBJS += $(OUTPUT)tests/code-reading.o LIB_OBJS += $(OUTPUT)tests/sample-parsing.o LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o +LIB_OBJS += $(OUTPUT)tests/aliases.o missing the tests/aliases.o file AR libperf.a ar: tests/aliases.o: No such file or directory jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
missing the tests/aliases.o file AR libperf.a ar: tests/aliases.o: No such file or directory Fixed here (and in git) --- From: Andi Kleen a...@linux.intel.com Add a simple test case to perf test that runs perf download and parses all the available events, including json events. This needs adding an all event iterator to pmu.c v2: Rename identifiers v3: Only iterate cpu pmu to avoid bogus errors. Move pmu iterator to extra patch v4: Include aliases.c again Acked-by: Namhyung Kim namhy...@kernel.org Signed-off-by: Andi Kleen a...@linux.intel.com diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 0600425..6adb37f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -419,6 +419,7 @@ endif LIB_OBJS += $(OUTPUT)tests/code-reading.o LIB_OBJS += $(OUTPUT)tests/sample-parsing.o LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o +LIB_OBJS += $(OUTPUT)tests/aliases.o ifndef NO_DWARF_UNWIND ifeq ($(ARCH),$(filter $(ARCH),x86 arm)) LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o diff --git a/tools/perf/tests/aliases.c b/tools/perf/tests/aliases.c new file mode 100644 index 000..08a5f01 --- /dev/null +++ b/tools/perf/tests/aliases.c @@ -0,0 +1,58 @@ +/* Check if we can set up all aliases and can read JSON files */ +#include stdlib.h +#include tests.h +#include pmu.h +#include evlist.h +#include parse-events.h + +static struct perf_evlist *evlist; + +static int num_events; +static int failed; + +static int test__event(const char *pmu, const char *name) +{ + int ret; + + /* Not supported for now */ + if (strcmp(pmu, cpu)) + return 0; + + ret = parse_events(evlist, name); + + if (ret) { + /* +* We only print on failure because common perf setups +* have events that cannot be parsed. +*/ + fprintf(stderr, invalid or unsupported event: '%s'\n, name); + ret = 0; + failed++; + } else + num_events++; + return ret; +} + +int test__aliases(void) +{ + int err; + + /* Download JSON files */ + /* XXX assumes perf is installed */ + /* For now user must manually download */ + if (0 system(perf download /dev/null) 0) { + /* Don't error out for this for now */ + fprintf(stderr, perf download failed\n); + } + + evlist = perf_evlist__new(); + if (evlist == NULL) + return -ENOMEM; + + err = pmu_iterate_events(test__event); + fprintf(stderr, Parsed %d events :, num_events); + if (failed 0) + pr_debug( %d events failed, failed); + perf_evlist__delete(evlist); + return err; +} diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 6f8b01b..bb37ac2 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -154,6 +154,10 @@ static struct test { .func = test__hists_cumulate, }, { + .desc = Test parsing JSON aliases, + .func = test__aliases, + }, + { .func = NULL, }, }; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index ed64790..ab92ad9 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -48,6 +48,7 @@ int test__mmap_thread_lookup(void); int test__thread_mg_share(void); int test__hists_output(void); int test__hists_cumulate(void); +int test__aliases(void); #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #ifdef HAVE_DWARF_UNWIND_SUPPORT -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
From: Andi Kleen Add a simple test case to perf test that runs perf download and parses all the available events, including json events. This needs adding an all event iterator to pmu.c v2: Rename identifiers v3: Only iterate cpu pmu to avoid bogus errors. Move pmu iterator to extra patch Acked-by: Namhyung Kim Signed-off-by: Andi Kleen --- tools/perf/Makefile.perf| 1 + tools/perf/tests/builtin-test.c | 4 tools/perf/tests/tests.h| 1 + 3 files changed, 6 insertions(+) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 0600425..6adb37f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -419,6 +419,7 @@ endif LIB_OBJS += $(OUTPUT)tests/code-reading.o LIB_OBJS += $(OUTPUT)tests/sample-parsing.o LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o +LIB_OBJS += $(OUTPUT)tests/aliases.o ifndef NO_DWARF_UNWIND ifeq ($(ARCH),$(filter $(ARCH),x86 arm)) LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 6f8b01b..bb37ac2 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -154,6 +154,10 @@ static struct test { .func = test__hists_cumulate, }, { + .desc = "Test parsing JSON aliases", + .func = test__aliases, + }, + { .func = NULL, }, }; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index ed64790..ab92ad9 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -48,6 +48,7 @@ int test__mmap_thread_lookup(void); int test__thread_mg_share(void); int test__hists_output(void); int test__hists_cumulate(void); +int test__aliases(void); #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #ifdef HAVE_DWARF_UNWIND_SUPPORT -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/11] perf, tools, test: Add test case for alias and JSON parsing
From: Andi Kleen a...@linux.intel.com Add a simple test case to perf test that runs perf download and parses all the available events, including json events. This needs adding an all event iterator to pmu.c v2: Rename identifiers v3: Only iterate cpu pmu to avoid bogus errors. Move pmu iterator to extra patch Acked-by: Namhyung Kim namhy...@kernel.org Signed-off-by: Andi Kleen a...@linux.intel.com --- tools/perf/Makefile.perf| 1 + tools/perf/tests/builtin-test.c | 4 tools/perf/tests/tests.h| 1 + 3 files changed, 6 insertions(+) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 0600425..6adb37f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -419,6 +419,7 @@ endif LIB_OBJS += $(OUTPUT)tests/code-reading.o LIB_OBJS += $(OUTPUT)tests/sample-parsing.o LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o +LIB_OBJS += $(OUTPUT)tests/aliases.o ifndef NO_DWARF_UNWIND ifeq ($(ARCH),$(filter $(ARCH),x86 arm)) LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 6f8b01b..bb37ac2 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -154,6 +154,10 @@ static struct test { .func = test__hists_cumulate, }, { + .desc = Test parsing JSON aliases, + .func = test__aliases, + }, + { .func = NULL, }, }; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index ed64790..ab92ad9 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -48,6 +48,7 @@ int test__mmap_thread_lookup(void); int test__thread_mg_share(void); int test__hists_output(void); int test__hists_cumulate(void); +int test__aliases(void); #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #ifdef HAVE_DWARF_UNWIND_SUPPORT -- 1.9.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/