From: Adrian Hunter <adrian.hunter@intel.com>
To: Leo Yan <leo.yan@arm.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
"Liang, Kan" <kan.liang@linux.intel.com>,
James Clark <james.clark@linaro.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] perf cpumap: Add more tests for CPU map merging
Date: Fri, 15 Nov 2024 10:44:22 +0200 [thread overview]
Message-ID: <7fa7942e-82a4-49f1-914b-ac8d76a0de2c@intel.com> (raw)
In-Reply-To: <20241107125308.41226-3-leo.yan@arm.com>
On 7/11/24 14:53, Leo Yan wrote:
> Add additional tests for CPU map merging to cover more cases.
>
> These tests include different types of arguments, such as when one CPU
> map is a subset of another, as well as cases with or without overlap
> between the two maps.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> tools/perf/tests/cpumap.c | 34 +++++++++++++++++++++++++++++-----
> 1 file changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c
> index 7f189d57232f..f8187a801b8e 100644
> --- a/tools/perf/tests/cpumap.c
> +++ b/tools/perf/tests/cpumap.c
> @@ -156,21 +156,45 @@ static int test__cpu_map_print(struct test_suite *test __maybe_unused, int subte
> return 0;
> }
>
> -static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
> +static int __test__cpu_map_merge(const char *lhs, const char *rhs, int nr, const char *expected)
> {
> - struct perf_cpu_map *a = perf_cpu_map__new("4,2,1");
> - struct perf_cpu_map *b = perf_cpu_map__new("4,5,7");
> + struct perf_cpu_map *a = perf_cpu_map__new(lhs);
> + struct perf_cpu_map *b = perf_cpu_map__new(rhs);
> char buf[100];
>
> perf_cpu_map__merge(&a, b);
> - TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(a) == 5);
> + TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(a) == nr);
> cpu_map__snprint(a, buf, sizeof(buf));
> - TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7"));
> + TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, expected));
> perf_cpu_map__put(b);
> perf_cpu_map__put(a);
> return 0;
> }
>
> +static int test__cpu_map_merge(struct test_suite *test __maybe_unused,
> + int subtest __maybe_unused)
> +{
> + int ret;
> +
> + ret = __test__cpu_map_merge("4,2,1", "4,5,7", 5, "1-2,4-5,7");
> + if (ret)
> + return ret;
> + ret = __test__cpu_map_merge("1-8", "6-9", 9, "1-9");
> + if (ret)
> + return ret;
> + ret = __test__cpu_map_merge("1-8,12-20", "6-9,15", 18, "1-9,12-20");
> + if (ret)
> + return ret;
> + ret = __test__cpu_map_merge("4,2,1", "1", 3, "1-2,4");
> + if (ret)
> + return ret;
> + ret = __test__cpu_map_merge("1", "4,2,1", 3, "1-2,4");
> + if (ret)
> + return ret;
> + ret = __test__cpu_map_merge("1", "1", 1, "1");
> + return ret;
> +}
> +
> static int __test__cpu_map_intersect(const char *lhs, const char *rhs, int nr, const char *expected)
> {
> struct perf_cpu_map *a = perf_cpu_map__new(lhs);
next prev parent reply other threads:[~2024-11-15 8:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 12:53 [PATCH v2 0/3] perf cpumap: Refactor perf_cpu_map__merge() Leo Yan
2024-11-07 12:53 ` [PATCH v2 1/3] libperf " Leo Yan
2024-11-15 8:38 ` Adrian Hunter
2024-11-07 12:53 ` [PATCH v2 2/3] perf cpumap: Add more tests for CPU map merging Leo Yan
2024-11-15 8:44 ` Adrian Hunter [this message]
2024-11-07 12:53 ` [PATCH v2 3/3] perf cpumap: Add checking for reference counter Leo Yan
2024-11-15 8:49 ` Adrian Hunter
2024-12-09 15:02 ` Arnaldo Carvalho de Melo
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=7fa7942e-82a4-49f1-914b-ac8d76a0de2c@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=namhyung@kernel.org \
/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).