1 // SPDX-License-Identifier: GPL-2.0
2 #include "util/mem-events.h"
3 #include "util/symbol.h"
4 #include "linux/perf_event.h"
5 #include "util/debug.h"
9 static int check(union perf_mem_data_src data_src
,
14 struct mem_info mi
= { .data_src
= data_src
};
18 n
= perf_mem__snp_scnprintf(out
, sizeof out
, &mi
);
19 n
+= perf_mem__lvl_scnprintf(out
+ n
, sizeof out
- n
, &mi
);
20 scnprintf(failure
, sizeof failure
, "unexpected %s", out
);
21 TEST_ASSERT_VAL(failure
, !strcmp(string
, out
));
25 int test__mem(struct test
*text __maybe_unused
, int subtest __maybe_unused
)
28 union perf_mem_data_src src
;
30 memset(&src
, 0, sizeof(src
));
32 src
.mem_lvl
= PERF_MEM_LVL_HIT
;
35 ret
|= check(src
, "N/AL4 hit");
39 ret
|= check(src
, "N/ARemote L4 hit");
41 src
.mem_lvl
= PERF_MEM_LVL_MISS
;
42 src
.mem_lvl_num
= PERF_MEM_LVLNUM_PMEM
;
45 ret
|= check(src
, "N/APMEM miss");
49 ret
|= check(src
, "N/ARemote PMEM miss");
51 src
.mem_snoopx
= PERF_MEM_SNOOPX_FWD
;
52 src
.mem_lvl_num
= PERF_MEM_LVLNUM_RAM
;
54 ret
|= check(src
, "FwdRemote RAM miss");