diff options
-rw-r--r-- | tools/perf/Makefile | 4 | ||||
-rw-r--r-- | tools/perf/tests/builtin-test.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/python-use.c | 23 | ||||
-rw-r--r-- | tools/perf/tests/tests.h | 1 |
4 files changed, 32 insertions, 0 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index c9f72b18e787..d0d79574403a 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -488,6 +488,7 @@ LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o | |||
488 | LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o | 488 | LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o |
489 | LIB_OBJS += $(OUTPUT)tests/pmu.o | 489 | LIB_OBJS += $(OUTPUT)tests/pmu.o |
490 | LIB_OBJS += $(OUTPUT)tests/hists_link.o | 490 | LIB_OBJS += $(OUTPUT)tests/hists_link.o |
491 | LIB_OBJS += $(OUTPUT)tests/python-use.o | ||
491 | 492 | ||
492 | BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o | 493 | BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o |
493 | BUILTIN_OBJS += $(OUTPUT)builtin-bench.o | 494 | BUILTIN_OBJS += $(OUTPUT)builtin-bench.o |
@@ -955,6 +956,9 @@ $(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS | |||
955 | '-DBINDIR="$(bindir_SQ)"' \ | 956 | '-DBINDIR="$(bindir_SQ)"' \ |
956 | $< | 957 | $< |
957 | 958 | ||
959 | $(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS | ||
960 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DPYTHONPATH='"$(OUTPUT)/python"' $< | ||
961 | |||
958 | $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS | 962 | $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS |
959 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< | 963 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< |
960 | 964 | ||
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 479d10484a74..a164e4cd5f42 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -73,6 +73,10 @@ static struct test { | |||
73 | .func = test__hists_link, | 73 | .func = test__hists_link, |
74 | }, | 74 | }, |
75 | { | 75 | { |
76 | .desc = "Try 'use perf' in python, checking link problems", | ||
77 | .func = test__python_use, | ||
78 | }, | ||
79 | { | ||
76 | .func = NULL, | 80 | .func = NULL, |
77 | }, | 81 | }, |
78 | }; | 82 | }; |
diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c new file mode 100644 index 000000000000..15301f4ac3f1 --- /dev/null +++ b/tools/perf/tests/python-use.c | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * Just test if we can load the python binding. | ||
3 | */ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include "tests.h" | ||
8 | |||
9 | extern int verbose; | ||
10 | |||
11 | int test__python_use(void) | ||
12 | { | ||
13 | char *cmd; | ||
14 | int ret; | ||
15 | |||
16 | if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | python %s", | ||
17 | PYTHONPATH, verbose ? "" : "2> /dev/null") < 0) | ||
18 | return -1; | ||
19 | |||
20 | ret = system(cmd) ? -1 : 0; | ||
21 | free(cmd); | ||
22 | return ret; | ||
23 | } | ||
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 0bf106978094..0ded425b17d6 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h | |||
@@ -16,5 +16,6 @@ int test__attr(void); | |||
16 | int test__dso_data(void); | 16 | int test__dso_data(void); |
17 | int test__parse_events(void); | 17 | int test__parse_events(void); |
18 | int test__hists_link(void); | 18 | int test__hists_link(void); |
19 | int test__python_use(void); | ||
19 | 20 | ||
20 | #endif /* TESTS_H */ | 21 | #endif /* TESTS_H */ |