perf test: Convert watch point tests to test cases.
Use null terminated array of test cases rather than the previous sub test functions. Committer notes: On s/390x we don't use __event(), so wrap it with __s390x__ Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Sohaib Mohamed <sohaib.amhmd@gmail.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Brendan Higgins <brendanhiggins@google.com> Cc: Daniel Latypov <dlatypov@google.com> Cc: David Gow <davidgow@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: John Garry <john.garry@huawei.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Clarke <pc@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: https://lore.kernel.org/r/20211104064208.3156807-12-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Родитель
2a74fe8283
Коммит
e47c6ecaae
|
@ -48,6 +48,7 @@ static void get__perf_event_attr(struct perf_event_attr *attr, int wp_type,
|
||||||
attr->exclude_hv = 1;
|
attr->exclude_hv = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __s390x__
|
||||||
static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
|
static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -61,9 +62,14 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int wp_ro_test(void)
|
static int test__wp_ro(struct test_suite *test __maybe_unused,
|
||||||
|
int subtest __maybe_unused)
|
||||||
{
|
{
|
||||||
|
#if defined(__s390x__) || defined(__x86_64__) || defined(__i386__)
|
||||||
|
return TEST_SKIP;
|
||||||
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
unsigned long tmp, tmp1 = rand();
|
unsigned long tmp, tmp1 = rand();
|
||||||
|
|
||||||
|
@ -79,10 +85,15 @@ static int wp_ro_test(void)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wp_wo_test(void)
|
static int test__wp_wo(struct test_suite *test __maybe_unused,
|
||||||
|
int subtest __maybe_unused)
|
||||||
{
|
{
|
||||||
|
#if defined(__s390x__)
|
||||||
|
return TEST_SKIP;
|
||||||
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
unsigned long tmp, tmp1 = rand();
|
unsigned long tmp, tmp1 = rand();
|
||||||
|
|
||||||
|
@ -98,10 +109,15 @@ static int wp_wo_test(void)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wp_rw_test(void)
|
static int test__wp_rw(struct test_suite *test __maybe_unused,
|
||||||
|
int subtest __maybe_unused)
|
||||||
{
|
{
|
||||||
|
#if defined(__s390x__)
|
||||||
|
return TEST_SKIP;
|
||||||
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
unsigned long tmp, tmp1 = rand();
|
unsigned long tmp, tmp1 = rand();
|
||||||
|
|
||||||
|
@ -118,10 +134,15 @@ static int wp_rw_test(void)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wp_modify_test(void)
|
static int test__wp_modify(struct test_suite *test __maybe_unused,
|
||||||
|
int subtest __maybe_unused)
|
||||||
{
|
{
|
||||||
|
#if defined(__s390x__)
|
||||||
|
return TEST_SKIP;
|
||||||
|
#else
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
unsigned long tmp = rand();
|
unsigned long tmp = rand();
|
||||||
struct perf_event_attr new_attr;
|
struct perf_event_attr new_attr;
|
||||||
|
@ -163,105 +184,18 @@ static int wp_modify_test(void)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
static bool wp_ro_supported(void)
|
|
||||||
{
|
|
||||||
#if defined (__x86_64__) || defined (__i386__)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *wp_ro_skip_msg(void)
|
static struct test_case wp_tests[] = {
|
||||||
{
|
TEST_CASE_REASON("Read Only Watchpoint", wp_ro, "missing hardware support"),
|
||||||
#if defined (__x86_64__) || defined (__i386__)
|
TEST_CASE_REASON("Write Only Watchpoint", wp_wo, "missing hardware support"),
|
||||||
return "missing hardware support";
|
TEST_CASE_REASON("Read / Write Watchpoint", wp_rw, "missing hardware support"),
|
||||||
#else
|
TEST_CASE_REASON("Modify Watchpoint", wp_modify, "missing hardware support"),
|
||||||
return NULL;
|
{ .name = NULL, }
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
const char *desc;
|
|
||||||
int (*target_func)(void);
|
|
||||||
bool (*is_supported)(void);
|
|
||||||
const char *(*skip_msg)(void);
|
|
||||||
} wp_testcase_table[] = {
|
|
||||||
{
|
|
||||||
.desc = "Read Only Watchpoint",
|
|
||||||
.target_func = &wp_ro_test,
|
|
||||||
.is_supported = &wp_ro_supported,
|
|
||||||
.skip_msg = &wp_ro_skip_msg,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.desc = "Write Only Watchpoint",
|
|
||||||
.target_func = &wp_wo_test,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.desc = "Read / Write Watchpoint",
|
|
||||||
.target_func = &wp_rw_test,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.desc = "Modify Watchpoint",
|
|
||||||
.target_func = &wp_modify_test,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int test__wp_subtest_get_nr(void)
|
|
||||||
{
|
|
||||||
return (int)ARRAY_SIZE(wp_testcase_table);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *test__wp_subtest_get_desc(int i)
|
|
||||||
{
|
|
||||||
if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
|
|
||||||
return NULL;
|
|
||||||
return wp_testcase_table[i].desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *test__wp_subtest_skip_reason(int i)
|
|
||||||
{
|
|
||||||
if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
|
|
||||||
return NULL;
|
|
||||||
if (!wp_testcase_table[i].skip_msg)
|
|
||||||
return NULL;
|
|
||||||
return wp_testcase_table[i].skip_msg();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test__wp(struct test_suite *test __maybe_unused, int i)
|
|
||||||
{
|
|
||||||
if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
|
|
||||||
return TEST_FAIL;
|
|
||||||
|
|
||||||
if (wp_testcase_table[i].is_supported &&
|
|
||||||
!wp_testcase_table[i].is_supported())
|
|
||||||
return TEST_SKIP;
|
|
||||||
|
|
||||||
return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The s390 so far does not have support for
|
|
||||||
* instruction breakpoint using the perf_event_open() system call.
|
|
||||||
*/
|
|
||||||
static bool test__wp_is_supported(void)
|
|
||||||
{
|
|
||||||
#if defined(__s390x__)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
struct test_suite suite__wp = {
|
struct test_suite suite__wp = {
|
||||||
.desc = "Watchpoint",
|
.desc = "Watchpoint",
|
||||||
.func = test__wp,
|
.test_cases = wp_tests,
|
||||||
.is_supported = test__wp_is_supported,
|
|
||||||
.subtest = {
|
|
||||||
.skip_if_fail = false,
|
|
||||||
.get_nr = test__wp_subtest_get_nr,
|
|
||||||
.get_desc = test__wp_subtest_get_desc,
|
|
||||||
.skip_reason = test__wp_subtest_skip_reason,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче