summaryrefslogtreecommitdiffstats
path: root/test/eviction.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-08-13 16:44:04 +0200
committerLouis Burda <quent.burda@gmail.com>2022-08-13 16:45:08 +0200
commit98babf91dcf166bc7644a3d70a90dac272f12a75 (patch)
tree529acab95367ae6ed35eddf0731ee82f73c94842 /test/eviction.c
parent88d598bc2894c28d8dd9c2259c5c8cbe2ec7ce55 (diff)
downloadcachepc-98babf91dcf166bc7644a3d70a90dac272f12a75.tar.gz
cachepc-98babf91dcf166bc7644a3d70a90dac272f12a75.zip
Reorder repo into module and tests
Diffstat (limited to 'test/eviction.c')
-rw-r--r--test/eviction.c39
1 files changed, 39 insertions, 0 deletions
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 <stdlib.h>
+#include <stdio.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <assert.h>
+#include <unistd.h>
+#include <stropts.h>
+
+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);
+}