Skip to content

Commit 89f552d

Browse files
Jiri Olsaacmel
authored andcommitted
perf tests: Factor attr tests WRITE_ASS macro
Changing WRITE_ASS macro per Namhyung's comments, so the main usage case takes only attr field name and format string. Suggested-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1352130579-13451-3-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent df4c6de commit 89f552d

1 file changed

Lines changed: 45 additions & 44 deletions

File tree

‎tools/perf/tests/attr.c‎

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void test_attr__init(void)
4444

4545
#define BUFSIZE 1024
4646

47-
#define WRITE_ASS(str, fmt, data) \
47+
#define __WRITE_ASS(str, fmt, data) \
4848
do { \
4949
char buf[BUFSIZE]; \
5050
size_t size; \
@@ -58,6 +58,8 @@ do { \
5858
\
5959
} while (0)
6060

61+
#define WRITE_ASS(field, fmt) __WRITE_ASS(field, fmt, attr->field)
62+
6163
static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,
6264
int fd, int group_fd, unsigned long flags)
6365
{
@@ -81,51 +83,50 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,
8183
}
8284

8385
/* syscall arguments */
84-
WRITE_ASS(fd, "d", fd);
85-
WRITE_ASS(group_fd, "d", group_fd);
86-
WRITE_ASS(cpu, "d", cpu);
87-
WRITE_ASS(pid, "d", pid);
88-
WRITE_ASS(flags, "lu", flags);
86+
__WRITE_ASS(fd, "d", fd);
87+
__WRITE_ASS(group_fd, "d", group_fd);
88+
__WRITE_ASS(cpu, "d", cpu);
89+
__WRITE_ASS(pid, "d", pid);
90+
__WRITE_ASS(flags, "lu", flags);
8991

9092
/* struct perf_event_attr */
91-
WRITE_ASS(type, PRIu32, attr->type);
92-
WRITE_ASS(size, PRIu32, attr->size);
93-
WRITE_ASS(config, "llu", attr->config);
94-
WRITE_ASS(sample_period, "llu", attr->sample_period);
95-
WRITE_ASS(sample_type, "llu", attr->sample_type);
96-
WRITE_ASS(read_format, "llu", attr->read_format);
97-
WRITE_ASS(disabled, "d", attr->disabled);
98-
WRITE_ASS(inherit, "d", attr->inherit);
99-
WRITE_ASS(pinned, "d", attr->pinned);
100-
WRITE_ASS(exclusive, "d", attr->exclusive);
101-
WRITE_ASS(exclude_user, "d", attr->exclude_user);
102-
WRITE_ASS(exclude_kernel, "d", attr->exclude_kernel);
103-
WRITE_ASS(exclude_hv, "d", attr->exclude_hv);
104-
WRITE_ASS(exclude_idle, "d", attr->exclude_idle);
105-
WRITE_ASS(mmap, "d", attr->mmap);
106-
WRITE_ASS(comm, "d", attr->comm);
107-
WRITE_ASS(freq, "d", attr->freq);
108-
WRITE_ASS(inherit_stat, "d", attr->inherit_stat);
109-
WRITE_ASS(enable_on_exec, "d", attr->enable_on_exec);
110-
WRITE_ASS(task, "d", attr->task);
111-
WRITE_ASS(watermask, "d", attr->watermark);
112-
WRITE_ASS(precise_ip, "d", attr->precise_ip);
113-
WRITE_ASS(mmap_data, "d", attr->mmap_data);
114-
WRITE_ASS(sample_id_all, "d", attr->sample_id_all);
115-
WRITE_ASS(exclude_host, "d", attr->exclude_host);
116-
WRITE_ASS(exclude_guest, "d", attr->exclude_guest);
117-
WRITE_ASS(exclude_callchain_kernel, "d",
118-
attr->exclude_callchain_kernel);
119-
WRITE_ASS(exclude_callchain_user, "d",
120-
attr->exclude_callchain_user);
121-
WRITE_ASS(wakeup_events, PRIu32, attr->wakeup_events);
122-
WRITE_ASS(bp_type, PRIu32, attr->bp_type);
123-
WRITE_ASS(config1, "llu", attr->config1);
124-
WRITE_ASS(config2, "llu", attr->config2);
125-
WRITE_ASS(branch_sample_type, "llu", attr->branch_sample_type);
126-
WRITE_ASS(sample_regs_user, "llu", attr->sample_regs_user);
127-
WRITE_ASS(sample_stack_user, PRIu32, attr->sample_stack_user);
128-
WRITE_ASS(optional, "d", 0);
93+
WRITE_ASS(type, PRIu32);
94+
WRITE_ASS(size, PRIu32);
95+
WRITE_ASS(config, "llu");
96+
WRITE_ASS(sample_period, "llu");
97+
WRITE_ASS(sample_type, "llu");
98+
WRITE_ASS(read_format, "llu");
99+
WRITE_ASS(disabled, "d");
100+
WRITE_ASS(inherit, "d");
101+
WRITE_ASS(pinned, "d");
102+
WRITE_ASS(exclusive, "d");
103+
WRITE_ASS(exclude_user, "d");
104+
WRITE_ASS(exclude_kernel, "d");
105+
WRITE_ASS(exclude_hv, "d");
106+
WRITE_ASS(exclude_idle, "d");
107+
WRITE_ASS(mmap, "d");
108+
WRITE_ASS(comm, "d");
109+
WRITE_ASS(freq, "d");
110+
WRITE_ASS(inherit_stat, "d");
111+
WRITE_ASS(enable_on_exec, "d");
112+
WRITE_ASS(task, "d");
113+
WRITE_ASS(watermask, "d");
114+
WRITE_ASS(precise_ip, "d");
115+
WRITE_ASS(mmap_data, "d");
116+
WRITE_ASS(sample_id_all, "d");
117+
WRITE_ASS(exclude_host, "d");
118+
WRITE_ASS(exclude_guest, "d");
119+
WRITE_ASS(exclude_callchain_kernel, "d");
120+
WRITE_ASS(exclude_callchain_user, "d");
121+
WRITE_ASS(wakeup_events, PRIu32);
122+
WRITE_ASS(bp_type, PRIu32);
123+
WRITE_ASS(config1, "llu");
124+
WRITE_ASS(config2, "llu");
125+
WRITE_ASS(branch_sample_type, "llu");
126+
WRITE_ASS(sample_regs_user, "llu");
127+
WRITE_ASS(sample_stack_user, PRIu32);
128+
129+
__WRITE_ASS(optional, "d", 0);
129130

130131
fclose(file);
131132
return 0;

0 commit comments

Comments
 (0)