linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Jin Yao <yao.jin@linux.intel.com>,
	John Garry <john.garry@huawei.com>,
	"Paul A . Clarke" <pc@us.ibm.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brendan Higgins <brendanhiggins@google.com>,
	Daniel Latypov <dlatypov@google.com>,
	David Gow <davidgow@google.com>
Cc: eranian@google.com, Ian Rogers <irogers@google.com>
Subject: [PATCH v2 11/22] perf test: Convert watch point tests to test cases.
Date: Wed, 13 Oct 2021 10:45:53 -0700	[thread overview]
Message-ID: <20211013174604.747276-12-irogers@google.com> (raw)
In-Reply-To: <20211013174604.747276-1-irogers@google.com>

Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/wp.c | 128 ++++++++++--------------------------------
 1 file changed, 30 insertions(+), 98 deletions(-)

diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index 904bdf2dcf81..2c0513257b15 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -62,8 +62,12 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
 	return fd;
 }
 
-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;
 	unsigned long tmp, tmp1 = rand();
 
@@ -79,10 +83,15 @@ static int wp_ro_test(void)
 
 	close(fd);
 	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;
 	unsigned long tmp, tmp1 = rand();
 
@@ -98,10 +107,15 @@ static int wp_wo_test(void)
 
 	close(fd);
 	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;
 	unsigned long tmp, tmp1 = rand();
 
@@ -118,10 +132,15 @@ static int wp_rw_test(void)
 
 	close(fd);
 	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;
 	unsigned long tmp = rand();
 	struct perf_event_attr new_attr;
@@ -163,105 +182,18 @@ static int wp_modify_test(void)
 
 	close(fd);
 	return 0;
-}
-
-static bool wp_ro_supported(void)
-{
-#if defined (__x86_64__) || defined (__i386__)
-	return false;
-#else
-	return true;
-#endif
-}
-
-static const char *wp_ro_skip_msg(void)
-{
-#if defined (__x86_64__) || defined (__i386__)
-	return "missing hardware support";
-#else
-	return 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 struct test_case wp_tests[] = {
+	TEST_CASE_REASON("Read Only Watchpoint", wp_ro, "missing hardware support"),
+	TEST_CASE_REASON("Write Only Watchpoint", wp_wo, "missing hardware support"),
+	TEST_CASE_REASON("Read / Write Watchpoint", wp_rw, "missing hardware support"),
+	TEST_CASE_REASON("Modify Watchpoint", wp_modify, "missing hardware support"),
+	{ .name = NULL, }
 };
 
-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 = {
 	.desc = "Watchpoint",
-	.func = test__wp,
-	.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,
-	},
+	.test_cases = wp_tests,
 };
-- 
2.33.0.882.g93a45727a2-goog


  parent reply	other threads:[~2021-10-13 17:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 17:45 [PATCH v2 00/22] Start aligning perf test with kunit style Ian Rogers
2021-10-13 17:45 ` [PATCH v2 01/22] perf test: Use macro for "suite" declarations Ian Rogers
2021-10-13 17:45 ` [PATCH v2 02/22] perf test: Use macro for "suite" definitions Ian Rogers
2021-10-13 17:45 ` [PATCH v2 03/22] perf test: Make each test/suite its own struct Ian Rogers
2021-10-13 17:45 ` [PATCH v2 04/22] perf test: Move each test suite struct to its test Ian Rogers
2021-10-13 17:45 ` [PATCH v2 05/22] perf test: Rename struct test to test_suite Ian Rogers
2021-10-13 17:45 ` [PATCH v2 06/22] perf test: Add helper functions for abstraction Ian Rogers
2021-10-20 12:34   ` Jiri Olsa
2021-10-25 22:35     ` Ian Rogers
2021-10-13 17:45 ` [PATCH v2 07/22] perf test: Add test case struct Ian Rogers
2021-10-13 17:45 ` [PATCH v2 08/22] perf test: Add skip reason to test case Ian Rogers
2021-10-13 17:45 ` [PATCH v2 09/22] perf test: Convert pfm tests to use test cases Ian Rogers
2021-10-13 17:45 ` [PATCH v2 10/22] perf test: Convert pmu event tests to " Ian Rogers
2021-10-13 17:45 ` Ian Rogers [this message]
2021-10-20 12:45   ` [PATCH v2 11/22] perf test: Convert watch point " Jiri Olsa
2021-11-13 21:11   ` Arnaldo Carvalho de Melo
2021-10-13 17:45 ` [PATCH v2 12/22] perf test: Convert clang " Ian Rogers
2021-10-13 17:45 ` [PATCH v2 13/22] perf test: Convert bpf " Ian Rogers
2021-10-13 17:45 ` [PATCH v2 14/22] perf test: Convert llvm " Ian Rogers
2021-10-13 17:45 ` [PATCH v2 15/22] perf test: Remove now unused subtest helpers Ian Rogers
2021-10-13 17:45 ` [PATCH v2 16/22] perf test: bp tests use test case Ian Rogers
2021-10-13 17:45 ` [PATCH v2 17/22] perf test: Convert time to tsc test to " Ian Rogers
2021-10-13 17:46 ` [PATCH v2 18/22] perf test: Remove non test case style support Ian Rogers
2021-10-13 17:46 ` [PATCH v2 19/22] perf test: BP tests, remove is_supported use Ian Rogers
2021-10-13 17:46 ` [PATCH v2 20/22] perf test: TSC test, " Ian Rogers
2021-10-13 17:46 ` [PATCH v2 21/22] perf test: Remove is_supported function Ian Rogers
2021-10-20 13:06   ` Jiri Olsa
2021-10-13 17:46 ` [PATCH v2 22/22] perf test: Remove skip_if_fail Ian Rogers
2021-10-20 12:14 ` [PATCH v2 00/22] Start aligning perf test with kunit style Jiri Olsa
2021-10-20 15:51   ` Ian Rogers
2021-10-28 23:52     ` Ian Rogers
2021-10-29 12:19       ` Jiri Olsa
2021-11-03 19:15         ` Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211013174604.747276-12-irogers@google.com \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=brendanhiggins@google.com \
    --cc=davidgow@google.com \
    --cc=dlatypov@google.com \
    --cc=eranian@google.com \
    --cc=john.garry@huawei.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=pc@us.ibm.com \
    --cc=peterz@infradead.org \
    --cc=yao.jin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).