1 // SPDX-License-Identifier: GPL-2.0
2 #include "util/map_symbol.h"
3 #include "util/mem-events.h"
4 #include "util/symbol.h"
5 #include "linux/perf_event.h"
6 #include "util/debug.h"
10 static int check(union perf_mem_data_src data_src
,
15 struct mem_info mi
= { .data_src
= data_src
};
19 n
= perf_mem__snp_scnprintf(out
, sizeof out
, &mi
);
20 n
+= perf_mem__lvl_scnprintf(out
+ n
, sizeof out
- n
, &mi
);
21 scnprintf(failure
, sizeof failure
, "unexpected %s", out
);
22 TEST_ASSERT_VAL(failure
, !strcmp(string
, out
));
26 int test__mem(struct test
*text __maybe_unused
, int subtest __maybe_unused
)
29 union perf_mem_data_src src
;
31 memset(&src
, 0, sizeof(src
));
33 src
.mem_lvl
= PERF_MEM_LVL_HIT
;
36 ret
|= check(src
, "N/AL4 hit");
40 ret
|= check(src
, "N/ARemote L4 hit");
42 src
.mem_lvl
= PERF_MEM_LVL_MISS
;
43 src
.mem_lvl_num
= PERF_MEM_LVLNUM_PMEM
;
46 ret
|= check(src
, "N/APMEM miss");
50 ret
|= check(src
, "N/ARemote PMEM miss");
52 src
.mem_snoopx
= PERF_MEM_SNOOPX_FWD
;
53 src
.mem_lvl_num
= PERF_MEM_LVLNUM_RAM
;
55 ret
|= check(src
, "FwdRemote RAM miss");