1 #include "util/mem-events.h"
2 #include "util/symbol.h"
3 #include "linux/perf_event.h"
4 #include "util/debug.h"
8 static int check(union perf_mem_data_src data_src
,
13 struct mem_info mi
= { .data_src
= data_src
};
17 n
= perf_mem__snp_scnprintf(out
, sizeof out
, &mi
);
18 n
+= perf_mem__lvl_scnprintf(out
+ n
, sizeof out
- n
, &mi
);
19 scnprintf(failure
, sizeof failure
, "unexpected %s", out
);
20 TEST_ASSERT_VAL(failure
, !strcmp(string
, out
));
24 int test__mem(struct test
*text __maybe_unused
, int subtest __maybe_unused
)
27 union perf_mem_data_src src
;
29 memset(&src
, 0, sizeof(src
));
31 src
.mem_lvl
= PERF_MEM_LVL_HIT
;
34 ret
|= check(src
, "N/AL4 hit");
38 ret
|= check(src
, "N/ARemote L4 hit");
40 src
.mem_lvl
= PERF_MEM_LVL_MISS
;
41 src
.mem_lvl_num
= PERF_MEM_LVLNUM_PMEM
;
44 ret
|= check(src
, "N/APMEM miss");
48 ret
|= check(src
, "N/ARemote PMEM miss");
50 src
.mem_snoopx
= PERF_MEM_SNOOPX_FWD
;
51 src
.mem_lvl_num
= PERF_MEM_LVLNUM_RAM
;
53 ret
|= check(src
, "FwdRemote RAM miss");