summaryrefslogtreecommitdiff
path: root/src/kernel/core/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/core/test.c')
-rw-r--r--src/kernel/core/test.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/kernel/core/test.c b/src/kernel/core/test.c
new file mode 100644
index 0000000..77c7029
--- /dev/null
+++ b/src/kernel/core/test.c
@@ -0,0 +1,31 @@
+#include "test.h"
+#include "monitor.h"
+#include <mem/mem.h>
+#include "sys.h"
+
+#define TEST_KMALLOC(var, sz) monitor_write("kmalloc:"); monitor_writeHex(sz); void *var = kmalloc(sz); \
+ if (var < 0xE0000000) { monitor_write(":FAIL\t"); PANIC("A test failed."); } \
+ else monitor_write(":OK:"); monitor_writeHex(var); monitor_write("\t");
+#define TEST_KFREE(var) if (var != 0) { monitor_write("kfree:"); monitor_writeHex(var); kfree(var); monitor_write(":OK\t"); }
+
+void test_run() {
+ monitor_write("Run kmalloc() and kfree() unit tests:\n");
+ int i;
+ for (i = 1; i <= 5; i++) {
+ monitor_write("\nMALLOC TEST SERIES #"); monitor_writeDec(i); monitor_write(":\n");
+ TEST_KMALLOC(a, 32);
+ TEST_KMALLOC(b, 64);
+ TEST_KMALLOC(c, 256);
+ TEST_KMALLOC(d, 512);
+ TEST_KMALLOC(e, 1024);
+ TEST_KMALLOC(f, 4096);
+ TEST_KMALLOC(g, 16384);
+ TEST_KFREE(b);
+ TEST_KFREE(c);
+ TEST_KFREE(d);
+ TEST_KFREE(e);
+ TEST_KFREE(f);
+ TEST_KFREE(g);
+ }
+ monitor_write("\nUnit tests finished.\n");
+}