pfm.c (8be98d2f2a0a262f8bf8a0bc1fdf522b3c7aab17) pfm.c (d68f0365087395fe232e39ac9c8ee53627522c3c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Test support for libpfm4 event encodings.
4 *
5 * Copyright 2020 Google LLC.
6 */
7#include "tests.h"
8#include "util/debug.h"

--- 82 unchanged lines hidden (view full) ---

91 opt.value = evlist;
92 parse_libpfm_events_option(&opt,
93 table[i].events,
94 0);
95 TEST_ASSERT_EQUAL(table[i].events,
96 count_pfm_events(&evlist->core),
97 table[i].nr_events);
98 TEST_ASSERT_EQUAL(table[i].events,
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Test support for libpfm4 event encodings.
4 *
5 * Copyright 2020 Google LLC.
6 */
7#include "tests.h"
8#include "util/debug.h"

--- 82 unchanged lines hidden (view full) ---

91 opt.value = evlist;
92 parse_libpfm_events_option(&opt,
93 table[i].events,
94 0);
95 TEST_ASSERT_EQUAL(table[i].events,
96 count_pfm_events(&evlist->core),
97 table[i].nr_events);
98 TEST_ASSERT_EQUAL(table[i].events,
99 evlist->nr_groups,
99 evlist->core.nr_groups,
100 0);
101
102 evlist__delete(evlist);
103 }
104 return 0;
105}
106
107static int test__pfm_group(void)

--- 42 unchanged lines hidden (view full) ---

150 .nr_groups = 0,
151 },
152 {
153 .events =
154 "{instructions,cycles},{instructions,stereolab}",
155 .nr_events = 3,
156 .nr_groups = 1,
157 },
100 0);
101
102 evlist__delete(evlist);
103 }
104 return 0;
105}
106
107static int test__pfm_group(void)

--- 42 unchanged lines hidden (view full) ---

150 .nr_groups = 0,
151 },
152 {
153 .events =
154 "{instructions,cycles},{instructions,stereolab}",
155 .nr_events = 3,
156 .nr_groups = 1,
157 },
158 {
159 .events = "instructions}",
160 .nr_events = 1,
161 .nr_groups = 0,
162 },
163 {
164 .events = "{{instructions}}",
165 .nr_events = 0,
166 .nr_groups = 0,
167 },
158 };
159
160 for (i = 0; i < ARRAY_SIZE(table); i++) {
161 evlist = evlist__new();
162 if (evlist == NULL)
163 return -ENOMEM;
164
165 opt.value = evlist;
166 parse_libpfm_events_option(&opt,
167 table[i].events,
168 0);
169 TEST_ASSERT_EQUAL(table[i].events,
170 count_pfm_events(&evlist->core),
171 table[i].nr_events);
172 TEST_ASSERT_EQUAL(table[i].events,
168 };
169
170 for (i = 0; i < ARRAY_SIZE(table); i++) {
171 evlist = evlist__new();
172 if (evlist == NULL)
173 return -ENOMEM;
174
175 opt.value = evlist;
176 parse_libpfm_events_option(&opt,
177 table[i].events,
178 0);
179 TEST_ASSERT_EQUAL(table[i].events,
180 count_pfm_events(&evlist->core),
181 table[i].nr_events);
182 TEST_ASSERT_EQUAL(table[i].events,
173 evlist->nr_groups,
183 evlist->core.nr_groups,
174 table[i].nr_groups);
175
176 evlist__delete(evlist);
177 }
178 return 0;
179}
180#endif
181
184 table[i].nr_groups);
185
186 evlist__delete(evlist);
187 }
188 return 0;
189}
190#endif
191
182const char *test__pfm_subtest_get_desc(int i)
192static const char *test__pfm_subtest_get_desc(int i)
183{
184 if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
185 return NULL;
186 return pfm_testcase_table[i].desc;
187}
188
193{
194 if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
195 return NULL;
196 return pfm_testcase_table[i].desc;
197}
198
189int test__pfm_subtest_get_nr(void)
199static int test__pfm_subtest_get_nr(void)
190{
191 return (int)ARRAY_SIZE(pfm_testcase_table);
192}
193
200{
201 return (int)ARRAY_SIZE(pfm_testcase_table);
202}
203
194int test__pfm(struct test *test __maybe_unused, int i __maybe_unused)
204static int test__pfm(struct test *test __maybe_unused, int i __maybe_unused)
195{
196#ifdef HAVE_LIBPFM
197 if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
198 return TEST_FAIL;
199 return pfm_testcase_table[i].func();
200#else
201 return TEST_SKIP;
202#endif
203}
205{
206#ifdef HAVE_LIBPFM
207 if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
208 return TEST_FAIL;
209 return pfm_testcase_table[i].func();
210#else
211 return TEST_SKIP;
212#endif
213}
214
215struct test suite__pfm = {
216 .desc = "Test libpfm4 support",
217 .func = test__pfm,
218 .subtest = {
219 .skip_if_fail = true,
220 .get_nr = test__pfm_subtest_get_nr,
221 .get_desc = test__pfm_subtest_get_desc,
222 }
223};