aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMarvin Borner2020-08-30 09:59:03 +0200
committerMarvin Borner2020-08-30 09:59:03 +0200
commitf73592503981eaacf1836f0d0049bed2f989212e (patch)
treeb10ec58e932a94022c36fe6e1de2b7bbc20fc838 /kernel
parente15051fd2d1d65af315ac4004256d5bc56a6dc67 (diff)
Added kernel testing suit
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile9
-rw-r--r--kernel/features/event.c8
-rw-r--r--kernel/test.c34
3 files changed, 47 insertions, 4 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 07f985a..da6a26c 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -26,6 +26,7 @@ CFLAGS = $(CSFLAGS) -Wall -Wextra -nostdlib -nostdinc -ffreestanding -fno-builti
ASFLAGS = -f elf32
all: compile bootloader
+test: compile_test bootloader
%.o: %.c
@$(CC) -c $(CFLAGS) $< -o $@
@@ -41,3 +42,11 @@ compile: $(COBJS)
@mkdir -p ../build/
@$(LD) -N -ekernel_main -Ttext 0x00050000 -o ../build/kernel.bin -L../build/ $+ -lk --oformat binary
@$(CC) $(CFLAGS) -o ../build/debug.o -L../build/ $+ -lk
+
+compile_test: CFLAGS += -Dtest -Wl,-etest_all
+compile_test: $(COBJS:main.o=test.o)
+ @mkdir -p ../build/
+ @$(LD) -N -etest_all -Ttext 0x00050000 -o ../build/kernel.bin -L../build/ $+ -lk --oformat binary
+ @$(CC) $(CFLAGS) -o ../build/debug.o -L../build/ $+ -lk
+
+.PHONY: test compile_test
diff --git a/kernel/features/event.c b/kernel/features/event.c
index 5436ef5..71c0ad9 100644
--- a/kernel/features/event.c
+++ b/kernel/features/event.c
@@ -29,14 +29,14 @@ void event_unregister(enum message_type id, struct proc *proc)
{
assert(id < sizeof(event_table) / sizeof(*event_table));
- struct event_descriptor *desc = malloc(sizeof(*desc));
- desc->id = id;
- desc->proc = proc;
+ struct event_descriptor desc;
+ desc.id = id;
+ desc.proc = proc;
struct node *iterator = event_table[id]->head;
do {
struct event_descriptor *desc_comp = iterator->data;
- if (desc_comp->id == desc->id && desc_comp->proc == desc->proc)
+ if (desc_comp->id == desc.id && desc_comp->proc == desc.proc)
list_remove(event_table[id], iterator);
} while ((iterator = iterator->next) != NULL);
}
diff --git a/kernel/test.c b/kernel/test.c
new file mode 100644
index 0000000..b328a2c
--- /dev/null
+++ b/kernel/test.c
@@ -0,0 +1,34 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#include <assert.h>
+#include <boot.h>
+#include <cpu.h>
+#include <fs.h>
+#include <keyboard.h>
+#include <load.h>
+#include <mem.h>
+#include <mouse.h>
+#include <serial.h>
+#include <syscall.h>
+#include <timer.h>
+
+void test_all(struct vid_info *vid_info)
+{
+ heap_init(0x00f00000);
+ boot_passed = vid_info;
+
+ // Serial connection
+ serial_install();
+ serial_print("\nConnected testing.\n");
+ assert(vid_info && vid_info->mode && vid_info->vbe);
+
+ // Install drivers
+ interrupts_install();
+ timer_install();
+ keyboard_install();
+ mouse_install();
+
+ ls_root();
+
+ idle();
+}