Skip to content

Commit 000ae33

Browse files
Namhyung Kimacmel
authored andcommitted
perf tests: Check python path on attr and binding test
Current perf test code tries to execute python version 2 in order to test attributes on perf_event_open syscall. However it's not default python version anymore a system can have python v3 only or v2 with a different name (e.g. python2). So if there's no such python interpreter with the name 'python', the test would fail like this (yes, it's happened on my new archlinux laptop :). 13: struct perf_event_attr setup :sh: python: command not found FAILED! As we can pass name of the python interpreter on make, use it for the attr test also. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1355729101-31317-1-git-send-email-namhyung@kernel.org [ committer note: Added the same mechanism to the python binding test ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 82ce75d commit 000ae33

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎tools/perf/Makefile‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,14 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
953953

954954
$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS
955955
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
956-
'-DBINDIR="$(bindir_SQ)"' \
956+
'-DBINDIR="$(bindir_SQ)"' -DPYTHON='"$(PYTHON_WORD)"' \
957957
$<
958958

959959
$(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS
960-
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPYTHONPATH='"$(OUTPUT)/python"' $<
960+
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
961+
-DPYTHONPATH='"$(OUTPUT)/python"' \
962+
-DPYTHON='"$(PYTHON_WORD)"' \
963+
$<
961964

962965
$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
963966
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<

‎tools/perf/tests/attr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int run_dir(const char *d, const char *perf)
144144
{
145145
char cmd[3*PATH_MAX];
146146

147-
snprintf(cmd, 3*PATH_MAX, "python %s/attr.py -d %s/attr/ -p %s %s",
147+
snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %s",
148148
d, d, perf, verbose ? "-v" : "");
149149

150150
return system(cmd);

‎tools/perf/tests/python-use.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ int test__python_use(void)
1313
char *cmd;
1414
int ret;
1515

16-
if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | python %s",
17-
PYTHONPATH, verbose ? "" : "2> /dev/null") < 0)
16+
if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
17+
PYTHONPATH, PYTHON, verbose ? "" : "2> /dev/null") < 0)
1818
return -1;
1919

2020
ret = system(cmd) ? -1 : 0;

0 commit comments

Comments
 (0)