summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-06-30 11:11:54 -0400
committerJakob Kaivo <jkk@ung.org>2020-06-30 11:11:54 -0400
commitd5ecd8fe69115c8587e16a2110bbb92790050b52 (patch)
tree5ba7232ad68046d65c57edb6bb599a4ac909ca88 /test
parent6e97e2feaa49fd741720bf0872a87be876a6747b (diff)
add some simple tests
Diffstat (limited to 'test')
-rw-r--r--test/overflow.c13
-rw-r--r--test/underflow.c13
-rw-r--r--test/zero.c13
3 files changed, 39 insertions, 0 deletions
diff --git a/test/overflow.c b/test/overflow.c
new file mode 100644
index 0000000..8bb1681
--- /dev/null
+++ b/test/overflow.c
@@ -0,0 +1,13 @@
+#define _POSIX_C_SOURCE 200809L
+#include <stdio.h>
+#include <unistd.h>
+#include "mapalloc.h"
+
+int main(void)
+{
+ char *ptr = map_malloc(1);
+ long pagesize = sysconf(_SC_PAGESIZE);
+ printf("ptr: %p, pagesize %ld\n", ptr, pagesize);
+ ptr[pagesize] = '\0';
+ printf("shouldn't get here\n");
+}
diff --git a/test/underflow.c b/test/underflow.c
new file mode 100644
index 0000000..f23aa6d
--- /dev/null
+++ b/test/underflow.c
@@ -0,0 +1,13 @@
+#define _POSIX_C_SOURCE 200809L
+#include <stdio.h>
+#include <unistd.h>
+#include "mapalloc.h"
+
+int main(void)
+{
+ char *ptr = map_malloc(1);
+ long pagesize = sysconf(_SC_PAGESIZE);
+ printf("ptr: %p, pagesize %ld\n", ptr, pagesize);
+ ptr[-1] = '\0';
+ printf("shouldn't get here\n");
+}
diff --git a/test/zero.c b/test/zero.c
new file mode 100644
index 0000000..7be3ad2
--- /dev/null
+++ b/test/zero.c
@@ -0,0 +1,13 @@
+#define _POSIX_C_SOURCE 200809L
+#include <stdio.h>
+#include <unistd.h>
+#include "mapalloc.h"
+
+int main(void)
+{
+ char *ptr = map_malloc(0);
+ long pagesize = sysconf(_SC_PAGESIZE);
+ printf("ptr: %p, pagesize %ld\n", ptr, pagesize);
+ ptr[0] = '\0';
+ printf("shouldn't get here\n");
+}