aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-11-05 10:49:37 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-11-05 12:03:59 -0500
commit89f552d684925ef9f1dca8b4b2b18fb981dc3d8c (patch)
tree35cf5bf7230b018972741681cc60c8ab8e4d03f2 /tools
parentdf4c6de857774252702acc20d4b0eddb329d8808 (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/tests/attr.c89
1 files changed, 45 insertions, 44 deletions
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index aacad82634c6..1389d69d5fd1 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -44,7 +44,7 @@ void test_attr__init(void)
44 44
45#define BUFSIZE 1024 45#define BUFSIZE 1024
46 46
47#define WRITE_ASS(str, fmt, data) \ 47#define __WRITE_ASS(str, fmt, data) \
48do { \ 48do { \
49 char buf[BUFSIZE]; \ 49 char buf[BUFSIZE]; \
50 size_t size; \ 50 size_t size; \
@@ -58,6 +58,8 @@ do { \
58 \ 58 \
59} while (0) 59} while (0)
60 60
61#define WRITE_ASS(field, fmt) __WRITE_ASS(field, fmt, attr->field)
62
61static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu, 63static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,
62 int fd, int group_fd, unsigned long flags) 64 int fd, int group_fd, unsigned long flags)
63{ 65{
@@ -81,51 +83,50 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,
81 } 83 }
82 84
83 /* syscall arguments */ 85 /* syscall arguments */
84 WRITE_ASS(fd, "d", fd); 86 __WRITE_ASS(fd, "d", fd);
85 WRITE_ASS(group_fd, "d", group_fd); 87 __WRITE_ASS(group_fd, "d", group_fd);
86 WRITE_ASS(cpu, "d", cpu); 88 __WRITE_ASS(cpu, "d", cpu);
87 WRITE_ASS(pid, "d", pid); 89 __WRITE_ASS(pid, "d", pid);
88 WRITE_ASS(flags, "lu", flags); 90 __WRITE_ASS(flags, "lu", flags);
89 91
90 /* struct perf_event_attr */ 92 /* struct perf_event_attr */
91 WRITE_ASS(type, PRIu32, attr->type); 93 WRITE_ASS(type, PRIu32);
92 WRITE_ASS(size, PRIu32, attr->size); 94 WRITE_ASS(size, PRIu32);
93 WRITE_ASS(config, "llu", attr->config); 95 WRITE_ASS(config, "llu");
94 WRITE_ASS(sample_period, "llu", attr->sample_period); 96 WRITE_ASS(sample_period, "llu");
95 WRITE_ASS(sample_type, "llu", attr->sample_type); 97 WRITE_ASS(sample_type, "llu");
96 WRITE_ASS(read_format, "llu", attr->read_format); 98 WRITE_ASS(read_format, "llu");
97 WRITE_ASS(disabled, "d", attr->disabled); 99 WRITE_ASS(disabled, "d");
98 WRITE_ASS(inherit, "d", attr->inherit); 100 WRITE_ASS(inherit, "d");
99 WRITE_ASS(pinned, "d", attr->pinned); 101 WRITE_ASS(pinned, "d");
100 WRITE_ASS(exclusive, "d", attr->exclusive); 102 WRITE_ASS(exclusive, "d");
101 WRITE_ASS(exclude_user, "d", attr->exclude_user); 103 WRITE_ASS(exclude_user, "d");
102 WRITE_ASS(exclude_kernel, "d", attr->exclude_kernel); 104 WRITE_ASS(exclude_kernel, "d");
103 WRITE_ASS(exclude_hv, "d", attr->exclude_hv); 105 WRITE_ASS(exclude_hv, "d");
104 WRITE_ASS(exclude_idle, "d", attr->exclude_idle); 106 WRITE_ASS(exclude_idle, "d");
105 WRITE_ASS(mmap, "d", attr->mmap); 107 WRITE_ASS(mmap, "d");
106 WRITE_ASS(comm, "d", attr->comm); 108 WRITE_ASS(comm, "d");
107 WRITE_ASS(freq, "d", attr->freq); 109 WRITE_ASS(freq, "d");
108 WRITE_ASS(inherit_stat, "d", attr->inherit_stat); 110 WRITE_ASS(inherit_stat, "d");
109 WRITE_ASS(enable_on_exec, "d", attr->enable_on_exec); 111 WRITE_ASS(enable_on_exec, "d");
110 WRITE_ASS(task, "d", attr->task); 112 WRITE_ASS(task, "d");
111 WRITE_ASS(watermask, "d", attr->watermark); 113 WRITE_ASS(watermask, "d");
112 WRITE_ASS(precise_ip, "d", attr->precise_ip); 114 WRITE_ASS(precise_ip, "d");
113 WRITE_ASS(mmap_data, "d", attr->mmap_data); 115 WRITE_ASS(mmap_data, "d");
114 WRITE_ASS(sample_id_all, "d", attr->sample_id_all); 116 WRITE_ASS(sample_id_all, "d");
115 WRITE_ASS(exclude_host, "d", attr->exclude_host); 117 WRITE_ASS(exclude_host, "d");
116 WRITE_ASS(exclude_guest, "d", attr->exclude_guest); 118 WRITE_ASS(exclude_guest, "d");
117 WRITE_ASS(exclude_callchain_kernel, "d", 119 WRITE_ASS(exclude_callchain_kernel, "d");
118 attr->exclude_callchain_kernel); 120 WRITE_ASS(exclude_callchain_user, "d");
119 WRITE_ASS(exclude_callchain_user, "d", 121 WRITE_ASS(wakeup_events, PRIu32);
120 attr->exclude_callchain_user); 122 WRITE_ASS(bp_type, PRIu32);
121 WRITE_ASS(wakeup_events, PRIu32, attr->wakeup_events); 123 WRITE_ASS(config1, "llu");
122 WRITE_ASS(bp_type, PRIu32, attr->bp_type); 124 WRITE_ASS(config2, "llu");
123 WRITE_ASS(config1, "llu", attr->config1); 125 WRITE_ASS(branch_sample_type, "llu");
124 WRITE_ASS(config2, "llu", attr->config2); 126 WRITE_ASS(sample_regs_user, "llu");
125 WRITE_ASS(branch_sample_type, "llu", attr->branch_sample_type); 127 WRITE_ASS(sample_stack_user, PRIu32);
126 WRITE_ASS(sample_regs_user, "llu", attr->sample_regs_user); 128
127 WRITE_ASS(sample_stack_user, PRIu32, attr->sample_stack_user); 129 __WRITE_ASS(optional, "d", 0);
128 WRITE_ASS(optional, "d", 0);
129 130
130 fclose(file); 131 fclose(file);
131 return 0; 132 return 0;