summaryrefslogtreecommitdiff
path: root/src/kernel/core/test.c
blob: fa26c7b9fa1a6de94a42bc58883898af986757e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "test.h"
#include "monitor.h"
#include <mem/mem.h>
#include "sys.h"

#define TEST_KMALLOC(var, sz) void *var = kmalloc(sz); ASSERT(var > 0xE0000000);
#define TEST_KFREE(var) if (var != 0) { kfree(var); }

void test_run() {
	monitor_write("Unit tests:\n\tkmalloc:");
	int i;
	for (i = 1; i <= 7; i++) {
		monitor_write(" #"); monitor_writeDec(i);
		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("\n >> Tests OK\n");
}