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

perf test maps: Additional maps__fixup_overlap_and_insert tests

Add additional test to the maps covering
maps__fixup_overlap_and_insert. Change the test suite to be for more
than just 1 test.

Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
36434959 245cfbcd

+83 -3
+1 -1
tools/perf/tests/builtin-test.c
··· 126 126 &suite__jit_write_elf, 127 127 &suite__pfm, 128 128 &suite__api_io, 129 - &suite__maps__merge_in, 129 + &suite__maps, 130 130 &suite__demangle_java, 131 131 &suite__demangle_ocaml, 132 132 &suite__demangle_rust,
+81 -1
tools/perf/tests/maps.c
··· 162 162 return TEST_OK; 163 163 } 164 164 165 - DEFINE_SUITE("maps__merge_in", maps__merge_in); 165 + static int test__maps__fixup_overlap_and_insert(struct test_suite *t __maybe_unused, 166 + int subtest __maybe_unused) 167 + { 168 + struct map_def initial_maps[] = { 169 + { "target_map", 1000, 2000 }, 170 + { "next_map", 3000, 4000 }, 171 + }; 172 + struct map_def insert_split = { "split_map", 1400, 1600 }; 173 + struct map_def expected_after_split[] = { 174 + { "target_map", 1000, 1400 }, 175 + { "split_map", 1400, 1600 }, 176 + { "target_map", 1600, 2000 }, 177 + { "next_map", 3000, 4000 }, 178 + }; 179 + 180 + struct map_def insert_eclipse = { "eclipse_map", 2500, 4500 }; 181 + struct map_def expected_final[] = { 182 + { "target_map", 1000, 1400 }, 183 + { "split_map", 1400, 1600 }, 184 + { "target_map", 1600, 2000 }, 185 + { "eclipse_map", 2500, 4500 }, 186 + /* "next_map" (3000-4000) is removed */ 187 + }; 188 + 189 + struct map *map_split, *map_eclipse; 190 + int ret; 191 + unsigned int i; 192 + struct maps *maps = maps__new(NULL); 193 + 194 + TEST_ASSERT_VAL("failed to create maps", maps); 195 + 196 + for (i = 0; i < ARRAY_SIZE(initial_maps); i++) { 197 + struct map *map = dso__new_map(initial_maps[i].name); 198 + 199 + TEST_ASSERT_VAL("failed to create map", map); 200 + map__set_start(map, initial_maps[i].start); 201 + map__set_end(map, initial_maps[i].end); 202 + TEST_ASSERT_VAL("failed to insert map", maps__insert(maps, map) == 0); 203 + map__put(map); 204 + } 205 + 206 + // Check splitting. 207 + map_split = dso__new_map(insert_split.name); 208 + TEST_ASSERT_VAL("failed to create split map", map_split); 209 + map__set_start(map_split, insert_split.start); 210 + map__set_end(map_split, insert_split.end); 211 + 212 + ret = maps__fixup_overlap_and_insert(maps, map_split); 213 + TEST_ASSERT_VAL("failed to fixup and insert split map", !ret); 214 + 215 + map__zput(map_split); 216 + ret = check_maps(expected_after_split, ARRAY_SIZE(expected_after_split), maps); 217 + TEST_ASSERT_VAL("split check failed", !ret); 218 + 219 + // Check cover 1 map with another. 220 + map_eclipse = dso__new_map(insert_eclipse.name); 221 + TEST_ASSERT_VAL("failed to create eclipse map", map_eclipse); 222 + map__set_start(map_eclipse, insert_eclipse.start); 223 + map__set_end(map_eclipse, insert_eclipse.end); 224 + 225 + ret = maps__fixup_overlap_and_insert(maps, map_eclipse); 226 + TEST_ASSERT_VAL("failed to fixup and insert eclipse map", !ret); 227 + 228 + map__zput(map_eclipse); 229 + ret = check_maps(expected_final, ARRAY_SIZE(expected_final), maps); 230 + TEST_ASSERT_VAL("eclipse check failed", !ret); 231 + 232 + maps__zput(maps); 233 + return TEST_OK; 234 + } 235 + 236 + static struct test_case tests__maps[] = { 237 + TEST_CASE("Test merge_in interface", maps__merge_in), 238 + TEST_CASE("Test fix up overlap interface", maps__fixup_overlap_and_insert), 239 + { .name = NULL, } 240 + }; 241 + 242 + struct test_suite suite__maps = { 243 + .desc = "Maps - per process mmaps abstraction", 244 + .test_cases = tests__maps, 245 + };
+1 -1
tools/perf/tests/tests.h
··· 160 160 DECLARE_SUITE(perf_hooks); 161 161 DECLARE_SUITE(unit_number__scnprint); 162 162 DECLARE_SUITE(mem2node); 163 - DECLARE_SUITE(maps__merge_in); 163 + DECLARE_SUITE(maps); 164 164 DECLARE_SUITE(time_utils); 165 165 DECLARE_SUITE(jit_write_elf); 166 166 DECLARE_SUITE(api_io);