staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / perf / tests / mem.c
blobefe3397824d2cd60a2b71201b437babf23747e0a
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"
6 #include "tests.h"
7 #include <string.h>
9 static int check(union perf_mem_data_src data_src,
10 const char *string)
12 char out[100];
13 char failure[100];
14 struct mem_info mi = { .data_src = data_src };
16 int n;
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));
22 return 0;
25 int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)
27 int ret = 0;
28 union perf_mem_data_src src;
30 memset(&src, 0, sizeof(src));
32 src.mem_lvl = PERF_MEM_LVL_HIT;
33 src.mem_lvl_num = 4;
35 ret |= check(src, "N/AL4 hit");
37 src.mem_remote = 1;
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;
43 src.mem_remote = 0;
45 ret |= check(src, "N/APMEM miss");
47 src.mem_remote = 1;
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");
56 return ret;