perf test: Check for linking problems in the python binding
Commit-ID: 54359d3340241b4cf53e42ecd5c429d7ba6fbef3 Gitweb: http://git.kernel.org/tip/54359d3340241b4cf53e42ecd5c429d7ba6fbef3 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Fri, 14 Dec 2012 13:06:13 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 24 Jan 2013 16:40:09 -0300
perf test: Check for linking problems in the python binding
It just will add the O= builddir to PYTHONPATH and try to 'use perf', which will, in verbose mode show the python backtrace with the missing symbols, such as in the problem fixed in the patch after this one:
# perf test -v 15
15: Try 'use perf' in python, checking link problems :
--- start ---
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/acme/git/build/perf//python/perf.so: undefined symbol: test_attr__enabled
---- end ----
Try 'use perf' in python, checking link problems: FAILED!
#Loooong overdue, done.
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/Makefile | 4 ++++ tools/perf/tests/builtin-test.c | 4 ++++ tools/perf/tests/python-use.c | 23 +++++++++++++++++++++++ tools/perf/tests/tests.h | 1 + 4 files changed, 32 insertions(+)
tools/perf/Makefile +4 -0
@@ -488,6 +488,7 @@ LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o LIB_OBJS += $(OUTPUT)tests/pmu.o LIB_OBJS += $(OUTPUT)tests/hists_link.o +LIB_OBJS += $(OUTPUT)tests/python-use.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
@@ -955,6 +956,9 @@ $(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS '-DBINDIR="$(bindir_SQ)"' \ $< +$(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPYTHONPATH='"$(OUTPUT)/python"' $< + $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
tools/perf/tests/builtin-test.c +4 -0
@@ -73,6 +73,10 @@ static struct test { .func = test__hists_link, }, { + .desc = "Try 'use perf' in python, checking link problems", + .func = test__python_use, + }, + { .func = NULL, }, };
tools/perf/tests/python-use.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Just test if we can load the python binding. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include "tests.h" + +extern int verbose; + +int test__python_use (void ) +{ +char *cmd; +int ret; + +if (asprintf (&cmd,"echo \"import sys ; sys.path.append('%s'); import perf\" | python %s" , +PYTHONPATH , verbose ?"" :"2> /dev/null" ) <0 ) +return -1 ; + + ret =system (cmd) ?-1 :0 ; +free (cmd); +return ret; +}
tools/perf/tests/tests.h +1 -0
@@ -16,5 +16,6 @@ int test__attr(void);int test__dso_data (void );int test__parse_events (void );int test__hists_link (void ); +int test__python_use (void );#endif /* TESTS_H */