27 #include <linux/types.h> 28 #include <linux/kernel.h> 29 #include <sys/param.h> 30 #include <sys/types.h> 34 #include <subcmd/exec-cmd.h> 37 #define ENV "PERF_TEST_ATTR" 50 #define __WRITE_ASS(str, fmt, data) \ 55 size = snprintf(buf, BUFSIZE, #str "=%"fmt "\n", data); \ 56 if (1 != fwrite(buf, size, 1, file)) { \ 57 perror("test attr - failed to write event file"); \ 64 #define WRITE_ASS(field, fmt) __WRITE_ASS(field, fmt, attr->field) 67 int fd,
int group_fd,
unsigned long flags)
75 snprintf(path,
PATH_MAX,
"%s/event-%d-%llu-%d",
dir,
76 attr->type, attr->config, fd);
78 file = fopen(path,
"w+");
80 perror(
"test attr - failed to open event file");
84 if (fprintf(file,
"[event-%d-%llu-%d]\n",
85 attr->type, attr->config, fd) < 0) {
86 perror(
"test attr - failed to write event file");
125 WRITE_ASS(exclude_callchain_kernel,
"d");
146 int fd,
int group_fd,
unsigned long flags)
148 int errno_saved = errno;
150 if ((fd != -1) &&
store_event(attr, pid, cpu, fd, group_fd, flags)) {
151 pr_err(
"test attr FAILED");
173 scnprintf(cmd, 3*
PATH_MAX, PYTHON
" %s/attr.py -d %s/attr/ -p %s %.*s",
174 d, d, perf, vcnt, v);
186 if (!lstat(
"./tests", &st))
187 return run_dir(
"./tests",
"./perf");
190 snprintf(path_dir,
PATH_MAX,
"%s/tests", get_argv_exec_path());
191 snprintf(path_perf,
PATH_MAX,
"%s/perf", BINDIR);
193 if (!lstat(path_dir, &st) &&
194 !lstat(path_perf, &st))
195 return run_dir(path_dir, path_perf);
#define WRITE_ASS(field, fmt)
void test_attr__init(void)
#define __WRITE_ASS(str, fmt, data)
static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu, int fd, int group_fd, unsigned long flags)
int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
void test_attr__ready(void)
void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, int fd, int group_fd, unsigned long flags)
static int run_dir(const char *d, const char *perf)