mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-23 18:07:03 +00:00
3067eaa7ce
Add some simple tests to perf test to test data source printing. v2: Make the tests actually checked for the correct name of Forward v3: Adjust to new encoding Committer notes: Avoid the in place declaration to make this build with older compilers, for instance, in Debian 7 we get: tests/mem.c: In function 'test__mem': tests/mem.c:30:5: error: missing initializer [-Werror=missing-field-initializers] tests/mem.c:30:5: error: (near initialization for '(anonymous).<anonymous>.mem_snoop') [-Werror=missing-field-initializers] So just zero a struct, then go on building the unions as needed, reusing settings from the previous test, i.e. local -> remote, etc. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/20170816222156.19953-5-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
#include "util/mem-events.h"
|
|
#include "util/symbol.h"
|
|
#include "linux/perf_event.h"
|
|
#include "util/debug.h"
|
|
#include "tests.h"
|
|
#include <string.h>
|
|
|
|
static int check(union perf_mem_data_src data_src,
|
|
const char *string)
|
|
{
|
|
char out[100];
|
|
char failure[100];
|
|
struct mem_info mi = { .data_src = data_src };
|
|
|
|
int n;
|
|
|
|
n = perf_mem__snp_scnprintf(out, sizeof out, &mi);
|
|
n += perf_mem__lvl_scnprintf(out + n, sizeof out - n, &mi);
|
|
snprintf(failure, sizeof failure, "unexpected %s", out);
|
|
TEST_ASSERT_VAL(failure, !strcmp(string, out));
|
|
return 0;
|
|
}
|
|
|
|
int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)
|
|
{
|
|
int ret = 0;
|
|
union perf_mem_data_src src;
|
|
|
|
memset(&src, 0, sizeof(src));
|
|
|
|
src.mem_lvl = PERF_MEM_LVL_HIT;
|
|
src.mem_lvl_num = 4;
|
|
|
|
ret |= check(src, "N/AL4 hit");
|
|
|
|
src.mem_remote = 1;
|
|
|
|
ret |= check(src, "N/ARemote L4 hit");
|
|
|
|
src.mem_lvl = PERF_MEM_LVL_MISS;
|
|
src.mem_lvl_num = PERF_MEM_LVLNUM_PMEM;
|
|
src.mem_remote = 0;
|
|
|
|
ret |= check(src, "N/APMEM miss");
|
|
|
|
src.mem_remote = 1;
|
|
|
|
ret |= check(src, "N/ARemote PMEM miss");
|
|
|
|
src.mem_snoopx = PERF_MEM_SNOOPX_FWD;
|
|
src.mem_lvl_num = PERF_MEM_LVLNUM_RAM;
|
|
|
|
ret |= check(src , "FwdRemote RAM miss");
|
|
|
|
return ret;
|
|
}
|