diff options
-rw-r--r-- | tools/perf/Makefile | 9 | ||||
-rw-r--r-- | tools/perf/perf.h | 1 | ||||
-rw-r--r-- | tools/perf/tests/attr.c | 35 | ||||
-rw-r--r-- | tools/perf/tests/builtin-test.c | 4 |
4 files changed, 49 insertions, 0 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 1da87a30c73a..4ffcd02404f8 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -898,6 +898,11 @@ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS | |||
898 | '-DPREFIX="$(prefix_SQ)"' \ | 898 | '-DPREFIX="$(prefix_SQ)"' \ |
899 | $< | 899 | $< |
900 | 900 | ||
901 | $(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS | ||
902 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ | ||
903 | '-DBINDIR="$(bindir_SQ)"' \ | ||
904 | $< | ||
905 | |||
901 | $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS | 906 | $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS |
902 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< | 907 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< |
903 | 908 | ||
@@ -1062,6 +1067,10 @@ install: all try-install-man | |||
1062 | $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin' | 1067 | $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin' |
1063 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d' | 1068 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d' |
1064 | $(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' | 1069 | $(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' |
1070 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' | ||
1071 | $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' | ||
1072 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' | ||
1073 | $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' | ||
1065 | 1074 | ||
1066 | install-python_ext: | 1075 | install-python_ext: |
1067 | $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' | 1076 | $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' |
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 00472646b3bf..054182e41dca 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -178,6 +178,7 @@ extern bool test_attr__enabled; | |||
178 | void test_attr__init(void); | 178 | void test_attr__init(void); |
179 | void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, | 179 | void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, |
180 | int fd, int group_fd, unsigned long flags); | 180 | int fd, int group_fd, unsigned long flags); |
181 | int test_attr__run(void); | ||
181 | 182 | ||
182 | static inline int | 183 | static inline int |
183 | sys_perf_event_open(struct perf_event_attr *attr, | 184 | sys_perf_event_open(struct perf_event_attr *attr, |
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 55e9a873a5cb..aacad82634c6 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c | |||
@@ -26,9 +26,12 @@ | |||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include "../perf.h" | 27 | #include "../perf.h" |
28 | #include "util.h" | 28 | #include "util.h" |
29 | #include "exec_cmd.h" | ||
29 | 30 | ||
30 | #define ENV "PERF_TEST_ATTR" | 31 | #define ENV "PERF_TEST_ATTR" |
31 | 32 | ||
33 | extern int verbose; | ||
34 | |||
32 | bool test_attr__enabled; | 35 | bool test_attr__enabled; |
33 | 36 | ||
34 | static char *dir; | 37 | static char *dir; |
@@ -138,3 +141,35 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, | |||
138 | 141 | ||
139 | errno = errno_saved; | 142 | errno = errno_saved; |
140 | } | 143 | } |
144 | |||
145 | static int run_dir(const char *d, const char *perf) | ||
146 | { | ||
147 | char cmd[3*PATH_MAX]; | ||
148 | |||
149 | snprintf(cmd, 3*PATH_MAX, "python %s/attr.py -d %s/attr/ -p %s %s", | ||
150 | d, d, perf, verbose ? "-v" : ""); | ||
151 | |||
152 | return system(cmd); | ||
153 | } | ||
154 | |||
155 | int test_attr__run(void) | ||
156 | { | ||
157 | struct stat st; | ||
158 | char path_perf[PATH_MAX]; | ||
159 | char path_dir[PATH_MAX]; | ||
160 | |||
161 | /* First try developement tree tests. */ | ||
162 | if (!lstat("./tests", &st)) | ||
163 | return run_dir("./tests", "./perf"); | ||
164 | |||
165 | /* Then installed path. */ | ||
166 | snprintf(path_dir, PATH_MAX, "%s/tests", perf_exec_path()); | ||
167 | snprintf(path_perf, PATH_MAX, "%s/perf", BINDIR); | ||
168 | |||
169 | if (!lstat(path_dir, &st) && | ||
170 | !lstat(path_perf, &st)) | ||
171 | return run_dir(path_dir, path_perf); | ||
172 | |||
173 | fprintf(stderr, " (ommitted)"); | ||
174 | return 0; | ||
175 | } | ||
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index f6c642415c44..1aa9e9927043 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -1455,6 +1455,10 @@ static struct test { | |||
1455 | .func = test__syscall_open_tp_fields, | 1455 | .func = test__syscall_open_tp_fields, |
1456 | }, | 1456 | }, |
1457 | { | 1457 | { |
1458 | .desc = "struct perf_event_attr setup", | ||
1459 | .func = test_attr__run, | ||
1460 | }, | ||
1461 | { | ||
1458 | .func = NULL, | 1462 | .func = NULL, |
1459 | }, | 1463 | }, |
1460 | }; | 1464 | }; |