Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf cpumap: Add more tests for CPU map merging

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.

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241107125308.41226-3-leo.yan@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Leo Yan and committed by
Arnaldo Carvalho de Melo
fb953dfa a9d22175

+29 -5
+29 -5
tools/perf/tests/cpumap.c
··· 156 156 return 0; 157 157 } 158 158 159 - static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 159 + static int __test__cpu_map_merge(const char *lhs, const char *rhs, int nr, const char *expected) 160 160 { 161 - struct perf_cpu_map *a = perf_cpu_map__new("4,2,1"); 162 - struct perf_cpu_map *b = perf_cpu_map__new("4,5,7"); 161 + struct perf_cpu_map *a = perf_cpu_map__new(lhs); 162 + struct perf_cpu_map *b = perf_cpu_map__new(rhs); 163 163 char buf[100]; 164 164 165 165 perf_cpu_map__merge(&a, b); 166 - TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(a) == 5); 166 + TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(a) == nr); 167 167 cpu_map__snprint(a, buf, sizeof(buf)); 168 - TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7")); 168 + TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, expected)); 169 169 perf_cpu_map__put(b); 170 170 perf_cpu_map__put(a); 171 171 return 0; 172 + } 173 + 174 + static int test__cpu_map_merge(struct test_suite *test __maybe_unused, 175 + int subtest __maybe_unused) 176 + { 177 + int ret; 178 + 179 + ret = __test__cpu_map_merge("4,2,1", "4,5,7", 5, "1-2,4-5,7"); 180 + if (ret) 181 + return ret; 182 + ret = __test__cpu_map_merge("1-8", "6-9", 9, "1-9"); 183 + if (ret) 184 + return ret; 185 + ret = __test__cpu_map_merge("1-8,12-20", "6-9,15", 18, "1-9,12-20"); 186 + if (ret) 187 + return ret; 188 + ret = __test__cpu_map_merge("4,2,1", "1", 3, "1-2,4"); 189 + if (ret) 190 + return ret; 191 + ret = __test__cpu_map_merge("1", "4,2,1", 3, "1-2,4"); 192 + if (ret) 193 + return ret; 194 + ret = __test__cpu_map_merge("1", "1", 1, "1"); 195 + return ret; 172 196 } 173 197 174 198 static int __test__cpu_map_intersect(const char *lhs, const char *rhs, int nr, const char *expected)