From 98babf91dcf166bc7644a3d70a90dac272f12a75 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Sat, 13 Aug 2022 16:44:04 +0200 Subject: Reorder repo into module and tests --- test/eviction.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/eviction.c (limited to 'test/eviction.c') diff --git a/test/eviction.c b/test/eviction.c new file mode 100644 index 0000000..23e3430 --- /dev/null +++ b/test/eviction.c @@ -0,0 +1,39 @@ +#include "cachepc_user.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, const char **argv) +{ + uint16_t counts[64]; + size_t i, len; + int fd, ret; + + fd = open("/proc/cachepc", O_RDONLY); + + ret = ioctl(fd, CACHEPC_IOCTL_EVICTION_TEST, NULL); + if (ret == -1) err(1, "ioctl fail"); + + len = read(fd, counts, sizeof(counts)); + assert(len == sizeof(counts)); + + for (i = 0; i < 64; i++) { + if (i % 16 == 0 && i) + printf("\n"); + if (counts[i] > 0) + printf("\x1b[91m"); + printf("%2i ", i); + if (counts[i] > 0) + printf("\x1b[0m"); + } + printf("\n"); + + close(fd); +} -- cgit v1.2.3-71-gd317