1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2f8ebb0cdSNamhyung Kim #include "tests.h" 3f8ebb0cdSNamhyung Kim #include "debug.h" 4f8ebb0cdSNamhyung Kim #include "symbol.h" 5f8ebb0cdSNamhyung Kim #include "sort.h" 6f8ebb0cdSNamhyung Kim #include "evsel.h" 7f8ebb0cdSNamhyung Kim #include "evlist.h" 8f8ebb0cdSNamhyung Kim #include "machine.h" 9*ec417ad4SIan Rogers #include "map.h" 10f8ebb0cdSNamhyung Kim #include "parse-events.h" 116e344a95SNamhyung Kim #include "hists_common.h" 12e0fcfb08SArnaldo Carvalho de Melo #include "util/mmap.h" 13a43783aeSArnaldo Carvalho de Melo #include <errno.h> 14877a7a11SArnaldo Carvalho de Melo #include <linux/kernel.h> 15f8ebb0cdSNamhyung Kim 16f8ebb0cdSNamhyung Kim struct sample { 17f8ebb0cdSNamhyung Kim u32 pid; 18f8ebb0cdSNamhyung Kim u64 ip; 19f8ebb0cdSNamhyung Kim struct thread *thread; 20f8ebb0cdSNamhyung Kim struct map *map; 21f8ebb0cdSNamhyung Kim struct symbol *sym; 22f8ebb0cdSNamhyung Kim }; 23f8ebb0cdSNamhyung Kim 246e344a95SNamhyung Kim /* For the numbers, see hists_common.c */ 25f8ebb0cdSNamhyung Kim static struct sample fake_common_samples[] = { 26f8ebb0cdSNamhyung Kim /* perf [kernel] schedule() */ 27a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_KERNEL_SCHEDULE, }, 28f8ebb0cdSNamhyung Kim /* perf [perf] main() */ 29a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_MAIN, }, 30f8ebb0cdSNamhyung Kim /* perf [perf] cmd_record() */ 31a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_CMD_RECORD, }, 32f8ebb0cdSNamhyung Kim /* bash [bash] xmalloc() */ 33a1891aa4SNamhyung Kim { .pid = FAKE_PID_BASH, .ip = FAKE_IP_BASH_XMALLOC, }, 34f8ebb0cdSNamhyung Kim /* bash [libc] malloc() */ 35a1891aa4SNamhyung Kim { .pid = FAKE_PID_BASH, .ip = FAKE_IP_LIBC_MALLOC, }, 36f8ebb0cdSNamhyung Kim }; 37f8ebb0cdSNamhyung Kim 38f8ebb0cdSNamhyung Kim static struct sample fake_samples[][5] = { 39f8ebb0cdSNamhyung Kim { 40f8ebb0cdSNamhyung Kim /* perf [perf] run_command() */ 41a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_PERF_RUN_COMMAND, }, 42f8ebb0cdSNamhyung Kim /* perf [libc] malloc() */ 43a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_LIBC_MALLOC, }, 44f8ebb0cdSNamhyung Kim /* perf [kernel] page_fault() */ 45a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_KERNEL_PAGE_FAULT, }, 46f8ebb0cdSNamhyung Kim /* perf [kernel] sys_perf_event_open() */ 47a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_KERNEL_SYS_PERF_EVENT_OPEN, }, 48f8ebb0cdSNamhyung Kim /* bash [libc] free() */ 49a1891aa4SNamhyung Kim { .pid = FAKE_PID_BASH, .ip = FAKE_IP_LIBC_FREE, }, 50f8ebb0cdSNamhyung Kim }, 51f8ebb0cdSNamhyung Kim { 52f8ebb0cdSNamhyung Kim /* perf [libc] free() */ 53a1891aa4SNamhyung Kim { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_LIBC_FREE, }, 54f8ebb0cdSNamhyung Kim /* bash [libc] malloc() */ 55a1891aa4SNamhyung Kim { .pid = FAKE_PID_BASH, .ip = FAKE_IP_LIBC_MALLOC, }, /* will be merged */ 56f8ebb0cdSNamhyung Kim /* bash [bash] xfee() */ 57a1891aa4SNamhyung Kim { .pid = FAKE_PID_BASH, .ip = FAKE_IP_BASH_XFREE, }, 58f8ebb0cdSNamhyung Kim /* bash [libc] realloc() */ 59a1891aa4SNamhyung Kim { .pid = FAKE_PID_BASH, .ip = FAKE_IP_LIBC_REALLOC, }, 60f8ebb0cdSNamhyung Kim /* bash [kernel] page_fault() */ 61a1891aa4SNamhyung Kim { .pid = FAKE_PID_BASH, .ip = FAKE_IP_KERNEL_PAGE_FAULT, }, 62f8ebb0cdSNamhyung Kim }, 63f8ebb0cdSNamhyung Kim }; 64f8ebb0cdSNamhyung Kim 6563503dbaSJiri Olsa static int add_hist_entries(struct evlist *evlist, struct machine *machine) 66f8ebb0cdSNamhyung Kim { 6732dcd021SJiri Olsa struct evsel *evsel; 68f8ebb0cdSNamhyung Kim struct addr_location al; 69f8ebb0cdSNamhyung Kim struct hist_entry *he; 70fd36f3ddSNamhyung Kim struct perf_sample sample = { .period = 1, .weight = 1, }; 71f8ebb0cdSNamhyung Kim size_t i = 0, k; 72f8ebb0cdSNamhyung Kim 73f8ebb0cdSNamhyung Kim /* 74f8ebb0cdSNamhyung Kim * each evsel will have 10 samples - 5 common and 5 distinct. 75f8ebb0cdSNamhyung Kim * However the second evsel also has a collapsed entry for 76f8ebb0cdSNamhyung Kim * "bash [libc] malloc" so total 9 entries will be in the tree. 77f8ebb0cdSNamhyung Kim */ 78e5cadb93SArnaldo Carvalho de Melo evlist__for_each_entry(evlist, evsel) { 794ea062edSArnaldo Carvalho de Melo struct hists *hists = evsel__hists(evsel); 804ea062edSArnaldo Carvalho de Melo 81f8ebb0cdSNamhyung Kim for (k = 0; k < ARRAY_SIZE(fake_common_samples); k++) { 82473398a2SArnaldo Carvalho de Melo sample.cpumode = PERF_RECORD_MISC_USER; 83ef89325fSAdrian Hunter sample.pid = fake_common_samples[k].pid; 8413ce34dfSNamhyung Kim sample.tid = fake_common_samples[k].pid; 85ef89325fSAdrian Hunter sample.ip = fake_common_samples[k].ip; 86bb3eb566SArnaldo Carvalho de Melo 87bb3eb566SArnaldo Carvalho de Melo if (machine__resolve(machine, &al, &sample) < 0) 88f8ebb0cdSNamhyung Kim goto out; 89f8ebb0cdSNamhyung Kim 900102ef3eSJiri Olsa he = hists__add_entry(hists, &al, NULL, 91ebf39d29SLeo Yan NULL, NULL, NULL, &sample, true); 92b91fc39fSArnaldo Carvalho de Melo if (he == NULL) { 93b91fc39fSArnaldo Carvalho de Melo addr_location__put(&al); 94f8ebb0cdSNamhyung Kim goto out; 95b91fc39fSArnaldo Carvalho de Melo } 96f8ebb0cdSNamhyung Kim 97f8ebb0cdSNamhyung Kim fake_common_samples[k].thread = al.thread; 98*ec417ad4SIan Rogers map__put(fake_common_samples[k].map); 99f8ebb0cdSNamhyung Kim fake_common_samples[k].map = al.map; 100f8ebb0cdSNamhyung Kim fake_common_samples[k].sym = al.sym; 101f8ebb0cdSNamhyung Kim } 102f8ebb0cdSNamhyung Kim 103f8ebb0cdSNamhyung Kim for (k = 0; k < ARRAY_SIZE(fake_samples[i]); k++) { 104ef89325fSAdrian Hunter sample.pid = fake_samples[i][k].pid; 10513ce34dfSNamhyung Kim sample.tid = fake_samples[i][k].pid; 106ef89325fSAdrian Hunter sample.ip = fake_samples[i][k].ip; 107bb3eb566SArnaldo Carvalho de Melo if (machine__resolve(machine, &al, &sample) < 0) 108f8ebb0cdSNamhyung Kim goto out; 109f8ebb0cdSNamhyung Kim 1100102ef3eSJiri Olsa he = hists__add_entry(hists, &al, NULL, 111ebf39d29SLeo Yan NULL, NULL, NULL, &sample, true); 112b91fc39fSArnaldo Carvalho de Melo if (he == NULL) { 113b91fc39fSArnaldo Carvalho de Melo addr_location__put(&al); 114f8ebb0cdSNamhyung Kim goto out; 115b91fc39fSArnaldo Carvalho de Melo } 116f8ebb0cdSNamhyung Kim 117f8ebb0cdSNamhyung Kim fake_samples[i][k].thread = al.thread; 118f8ebb0cdSNamhyung Kim fake_samples[i][k].map = al.map; 119f8ebb0cdSNamhyung Kim fake_samples[i][k].sym = al.sym; 120f8ebb0cdSNamhyung Kim } 121f8ebb0cdSNamhyung Kim i++; 122f8ebb0cdSNamhyung Kim } 123f8ebb0cdSNamhyung Kim 124f8ebb0cdSNamhyung Kim return 0; 125f8ebb0cdSNamhyung Kim 126f8ebb0cdSNamhyung Kim out: 127f8ebb0cdSNamhyung Kim pr_debug("Not enough memory for adding a hist entry\n"); 128f8ebb0cdSNamhyung Kim return -1; 129f8ebb0cdSNamhyung Kim } 130f8ebb0cdSNamhyung Kim 131*ec417ad4SIan Rogers static void put_fake_samples(void) 132*ec417ad4SIan Rogers { 133*ec417ad4SIan Rogers size_t i, j; 134*ec417ad4SIan Rogers 135*ec417ad4SIan Rogers for (i = 0; i < ARRAY_SIZE(fake_common_samples); i++) 136*ec417ad4SIan Rogers map__put(fake_common_samples[i].map); 137*ec417ad4SIan Rogers for (i = 0; i < ARRAY_SIZE(fake_samples); i++) { 138*ec417ad4SIan Rogers for (j = 0; j < ARRAY_SIZE(fake_samples[0]); j++) 139*ec417ad4SIan Rogers map__put(fake_samples[i][j].map); 140*ec417ad4SIan Rogers } 141*ec417ad4SIan Rogers } 142*ec417ad4SIan Rogers 143f8ebb0cdSNamhyung Kim static int find_sample(struct sample *samples, size_t nr_samples, 144f8ebb0cdSNamhyung Kim struct thread *t, struct map *m, struct symbol *s) 145f8ebb0cdSNamhyung Kim { 146f8ebb0cdSNamhyung Kim while (nr_samples--) { 147*ec417ad4SIan Rogers if (samples->thread == t && 148*ec417ad4SIan Rogers samples->map == m && 149f8ebb0cdSNamhyung Kim samples->sym == s) 150f8ebb0cdSNamhyung Kim return 1; 151f8ebb0cdSNamhyung Kim samples++; 152f8ebb0cdSNamhyung Kim } 153f8ebb0cdSNamhyung Kim return 0; 154f8ebb0cdSNamhyung Kim } 155f8ebb0cdSNamhyung Kim 156f8ebb0cdSNamhyung Kim static int __validate_match(struct hists *hists) 157f8ebb0cdSNamhyung Kim { 158f8ebb0cdSNamhyung Kim size_t count = 0; 1592eb3d689SDavidlohr Bueso struct rb_root_cached *root; 160f8ebb0cdSNamhyung Kim struct rb_node *node; 161f8ebb0cdSNamhyung Kim 162f8ebb0cdSNamhyung Kim /* 163f8ebb0cdSNamhyung Kim * Only entries from fake_common_samples should have a pair. 164f8ebb0cdSNamhyung Kim */ 16552225036SJiri Olsa if (hists__has(hists, need_collapse)) 166f8ebb0cdSNamhyung Kim root = &hists->entries_collapsed; 167f8ebb0cdSNamhyung Kim else 168f8ebb0cdSNamhyung Kim root = hists->entries_in; 169f8ebb0cdSNamhyung Kim 1702eb3d689SDavidlohr Bueso node = rb_first_cached(root); 171f8ebb0cdSNamhyung Kim while (node) { 172f8ebb0cdSNamhyung Kim struct hist_entry *he; 173f8ebb0cdSNamhyung Kim 174f8ebb0cdSNamhyung Kim he = rb_entry(node, struct hist_entry, rb_node_in); 175f8ebb0cdSNamhyung Kim 176f8ebb0cdSNamhyung Kim if (hist_entry__has_pairs(he)) { 177f8ebb0cdSNamhyung Kim if (find_sample(fake_common_samples, 178f8ebb0cdSNamhyung Kim ARRAY_SIZE(fake_common_samples), 179f8ebb0cdSNamhyung Kim he->thread, he->ms.map, he->ms.sym)) { 180f8ebb0cdSNamhyung Kim count++; 181f8ebb0cdSNamhyung Kim } else { 182f8ebb0cdSNamhyung Kim pr_debug("Can't find the matched entry\n"); 183f8ebb0cdSNamhyung Kim return -1; 184f8ebb0cdSNamhyung Kim } 185f8ebb0cdSNamhyung Kim } 186f8ebb0cdSNamhyung Kim 187f8ebb0cdSNamhyung Kim node = rb_next(node); 188f8ebb0cdSNamhyung Kim } 189f8ebb0cdSNamhyung Kim 190f8ebb0cdSNamhyung Kim if (count != ARRAY_SIZE(fake_common_samples)) { 191f8ebb0cdSNamhyung Kim pr_debug("Invalid count for matched entries: %zd of %zd\n", 192f8ebb0cdSNamhyung Kim count, ARRAY_SIZE(fake_common_samples)); 193f8ebb0cdSNamhyung Kim return -1; 194f8ebb0cdSNamhyung Kim } 195f8ebb0cdSNamhyung Kim 196f8ebb0cdSNamhyung Kim return 0; 197f8ebb0cdSNamhyung Kim } 198f8ebb0cdSNamhyung Kim 199f8ebb0cdSNamhyung Kim static int validate_match(struct hists *leader, struct hists *other) 200f8ebb0cdSNamhyung Kim { 201f8ebb0cdSNamhyung Kim return __validate_match(leader) || __validate_match(other); 202f8ebb0cdSNamhyung Kim } 203f8ebb0cdSNamhyung Kim 204f8ebb0cdSNamhyung Kim static int __validate_link(struct hists *hists, int idx) 205f8ebb0cdSNamhyung Kim { 206f8ebb0cdSNamhyung Kim size_t count = 0; 207f8ebb0cdSNamhyung Kim size_t count_pair = 0; 208f8ebb0cdSNamhyung Kim size_t count_dummy = 0; 2092eb3d689SDavidlohr Bueso struct rb_root_cached *root; 210f8ebb0cdSNamhyung Kim struct rb_node *node; 211f8ebb0cdSNamhyung Kim 212f8ebb0cdSNamhyung Kim /* 213f8ebb0cdSNamhyung Kim * Leader hists (idx = 0) will have dummy entries from other, 214f8ebb0cdSNamhyung Kim * and some entries will have no pair. However every entry 215f8ebb0cdSNamhyung Kim * in other hists should have (dummy) pair. 216f8ebb0cdSNamhyung Kim */ 21752225036SJiri Olsa if (hists__has(hists, need_collapse)) 218f8ebb0cdSNamhyung Kim root = &hists->entries_collapsed; 219f8ebb0cdSNamhyung Kim else 220f8ebb0cdSNamhyung Kim root = hists->entries_in; 221f8ebb0cdSNamhyung Kim 2222eb3d689SDavidlohr Bueso node = rb_first_cached(root); 223f8ebb0cdSNamhyung Kim while (node) { 224f8ebb0cdSNamhyung Kim struct hist_entry *he; 225f8ebb0cdSNamhyung Kim 226f8ebb0cdSNamhyung Kim he = rb_entry(node, struct hist_entry, rb_node_in); 227f8ebb0cdSNamhyung Kim 228f8ebb0cdSNamhyung Kim if (hist_entry__has_pairs(he)) { 229f8ebb0cdSNamhyung Kim if (!find_sample(fake_common_samples, 230f8ebb0cdSNamhyung Kim ARRAY_SIZE(fake_common_samples), 231f8ebb0cdSNamhyung Kim he->thread, he->ms.map, he->ms.sym) && 232f8ebb0cdSNamhyung Kim !find_sample(fake_samples[idx], 233f8ebb0cdSNamhyung Kim ARRAY_SIZE(fake_samples[idx]), 234f8ebb0cdSNamhyung Kim he->thread, he->ms.map, he->ms.sym)) { 235f8ebb0cdSNamhyung Kim count_dummy++; 236f8ebb0cdSNamhyung Kim } 237f8ebb0cdSNamhyung Kim count_pair++; 238f8ebb0cdSNamhyung Kim } else if (idx) { 239f8ebb0cdSNamhyung Kim pr_debug("A entry from the other hists should have pair\n"); 240f8ebb0cdSNamhyung Kim return -1; 241f8ebb0cdSNamhyung Kim } 242f8ebb0cdSNamhyung Kim 243f8ebb0cdSNamhyung Kim count++; 244f8ebb0cdSNamhyung Kim node = rb_next(node); 245f8ebb0cdSNamhyung Kim } 246f8ebb0cdSNamhyung Kim 247f8ebb0cdSNamhyung Kim /* 248f8ebb0cdSNamhyung Kim * Note that we have a entry collapsed in the other (idx = 1) hists. 249f8ebb0cdSNamhyung Kim */ 250f8ebb0cdSNamhyung Kim if (idx == 0) { 251f8ebb0cdSNamhyung Kim if (count_dummy != ARRAY_SIZE(fake_samples[1]) - 1) { 252f8ebb0cdSNamhyung Kim pr_debug("Invalid count of dummy entries: %zd of %zd\n", 253f8ebb0cdSNamhyung Kim count_dummy, ARRAY_SIZE(fake_samples[1]) - 1); 254f8ebb0cdSNamhyung Kim return -1; 255f8ebb0cdSNamhyung Kim } 256f8ebb0cdSNamhyung Kim if (count != count_pair + ARRAY_SIZE(fake_samples[0])) { 257f8ebb0cdSNamhyung Kim pr_debug("Invalid count of total leader entries: %zd of %zd\n", 258f8ebb0cdSNamhyung Kim count, count_pair + ARRAY_SIZE(fake_samples[0])); 259f8ebb0cdSNamhyung Kim return -1; 260f8ebb0cdSNamhyung Kim } 261f8ebb0cdSNamhyung Kim } else { 262f8ebb0cdSNamhyung Kim if (count != count_pair) { 263f8ebb0cdSNamhyung Kim pr_debug("Invalid count of total other entries: %zd of %zd\n", 264f8ebb0cdSNamhyung Kim count, count_pair); 265f8ebb0cdSNamhyung Kim return -1; 266f8ebb0cdSNamhyung Kim } 267f8ebb0cdSNamhyung Kim if (count_dummy > 0) { 268f8ebb0cdSNamhyung Kim pr_debug("Other hists should not have dummy entries: %zd\n", 269f8ebb0cdSNamhyung Kim count_dummy); 270f8ebb0cdSNamhyung Kim return -1; 271f8ebb0cdSNamhyung Kim } 272f8ebb0cdSNamhyung Kim } 273f8ebb0cdSNamhyung Kim 274f8ebb0cdSNamhyung Kim return 0; 275f8ebb0cdSNamhyung Kim } 276f8ebb0cdSNamhyung Kim 277f8ebb0cdSNamhyung Kim static int validate_link(struct hists *leader, struct hists *other) 278f8ebb0cdSNamhyung Kim { 279f8ebb0cdSNamhyung Kim return __validate_link(leader, 0) || __validate_link(other, 1); 280f8ebb0cdSNamhyung Kim } 281f8ebb0cdSNamhyung Kim 28233f44bfdSIan Rogers static int test__hists_link(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 283f8ebb0cdSNamhyung Kim { 284f8ebb0cdSNamhyung Kim int err = -1; 2854ea062edSArnaldo Carvalho de Melo struct hists *hists, *first_hists; 286876650e6SArnaldo Carvalho de Melo struct machines machines; 287f8ebb0cdSNamhyung Kim struct machine *machine = NULL; 28832dcd021SJiri Olsa struct evsel *evsel, *first; 2890f98b11cSJiri Olsa struct evlist *evlist = evlist__new(); 290f8ebb0cdSNamhyung Kim 291f8ebb0cdSNamhyung Kim if (evlist == NULL) 292f8ebb0cdSNamhyung Kim return -ENOMEM; 293f8ebb0cdSNamhyung Kim 294806731a9SAdrian Hunter err = parse_event(evlist, "cpu-clock"); 295f8ebb0cdSNamhyung Kim if (err) 296f8ebb0cdSNamhyung Kim goto out; 297806731a9SAdrian Hunter err = parse_event(evlist, "task-clock"); 298f8ebb0cdSNamhyung Kim if (err) 299f8ebb0cdSNamhyung Kim goto out; 300f8ebb0cdSNamhyung Kim 301b0500c16SWang Nan err = TEST_FAIL; 302f8ebb0cdSNamhyung Kim /* default sort order (comm,dso,sym) will be used */ 30340184c46SNamhyung Kim if (setup_sorting(NULL) < 0) 30455309985SNamhyung Kim goto out; 305f8ebb0cdSNamhyung Kim 306876650e6SArnaldo Carvalho de Melo machines__init(&machines); 307876650e6SArnaldo Carvalho de Melo 308f8ebb0cdSNamhyung Kim /* setup threads/dso/map/symbols also */ 309876650e6SArnaldo Carvalho de Melo machine = setup_fake_machine(&machines); 310f8ebb0cdSNamhyung Kim if (!machine) 311f8ebb0cdSNamhyung Kim goto out; 312f8ebb0cdSNamhyung Kim 313f8ebb0cdSNamhyung Kim if (verbose > 1) 314f8ebb0cdSNamhyung Kim machine__fprintf(machine, stderr); 315f8ebb0cdSNamhyung Kim 316f8ebb0cdSNamhyung Kim /* process sample events */ 317f8ebb0cdSNamhyung Kim err = add_hist_entries(evlist, machine); 318f8ebb0cdSNamhyung Kim if (err < 0) 319f8ebb0cdSNamhyung Kim goto out; 320f8ebb0cdSNamhyung Kim 321e5cadb93SArnaldo Carvalho de Melo evlist__for_each_entry(evlist, evsel) { 3224ea062edSArnaldo Carvalho de Melo hists = evsel__hists(evsel); 3234ea062edSArnaldo Carvalho de Melo hists__collapse_resort(hists, NULL); 324f8ebb0cdSNamhyung Kim 325f8ebb0cdSNamhyung Kim if (verbose > 2) 3264ea062edSArnaldo Carvalho de Melo print_hists_in(hists); 327f8ebb0cdSNamhyung Kim } 328f8ebb0cdSNamhyung Kim 329515dbe48SJiri Olsa first = evlist__first(evlist); 330515dbe48SJiri Olsa evsel = evlist__last(evlist); 331f8ebb0cdSNamhyung Kim 3324ea062edSArnaldo Carvalho de Melo first_hists = evsel__hists(first); 3334ea062edSArnaldo Carvalho de Melo hists = evsel__hists(evsel); 3344ea062edSArnaldo Carvalho de Melo 335f8ebb0cdSNamhyung Kim /* match common entries */ 3364ea062edSArnaldo Carvalho de Melo hists__match(first_hists, hists); 3374ea062edSArnaldo Carvalho de Melo err = validate_match(first_hists, hists); 338f8ebb0cdSNamhyung Kim if (err) 339f8ebb0cdSNamhyung Kim goto out; 340f8ebb0cdSNamhyung Kim 341f8ebb0cdSNamhyung Kim /* link common and/or dummy entries */ 3424ea062edSArnaldo Carvalho de Melo hists__link(first_hists, hists); 3434ea062edSArnaldo Carvalho de Melo err = validate_link(first_hists, hists); 344f8ebb0cdSNamhyung Kim if (err) 345f8ebb0cdSNamhyung Kim goto out; 346f8ebb0cdSNamhyung Kim 347f8ebb0cdSNamhyung Kim err = 0; 348f8ebb0cdSNamhyung Kim 349f8ebb0cdSNamhyung Kim out: 350f8ebb0cdSNamhyung Kim /* tear down everything */ 351c12995a5SJiri Olsa evlist__delete(evlist); 352f21d1815SNamhyung Kim reset_output_field(); 353876650e6SArnaldo Carvalho de Melo machines__exit(&machines); 354*ec417ad4SIan Rogers put_fake_samples(); 355f8ebb0cdSNamhyung Kim 356f8ebb0cdSNamhyung Kim return err; 357f8ebb0cdSNamhyung Kim } 358d68f0365SIan Rogers 359d68f0365SIan Rogers DEFINE_SUITE("Match and link multiple hists", hists_link); 360