From 7633e54663731256452d3e39d6b0cd4fb47065cf Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Thu, 8 Nov 2018 22:09:12 +0100 Subject: [PATCH] Add some way to test kernel --- Makefile | 6 +++++- tests/test.c | 11 +++++++++++ tests/test.h | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/test.c create mode 100644 tests/test.h diff --git a/Makefile b/Makefile index b27e4bf..768d515 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ LDFLAGS += -g -m32 -nostdlib -static -fno-common -fno-use-cxa-atexit -fno-except CFLAGS += -g -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-stack-protector CXXFLAGS += -g -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-rtti -fno-pie -SUBDIRS := core drivers +SUBDIRS := core drivers tests CPPFLAGS += $(foreach dir, $(SUBDIRS), -I$(dir)) @@ -37,6 +37,10 @@ core/irq_handler.o:core/irq_handler.c %.o:%.asm $(AS) $(ASFLAGS) -o $@ $< +self_test: CFLAGS += -DRUN_TEST +self_test: clean kernel + qemu-system-x86_64 -kernel kernel -serial stdio + test:kernel qemu-system-x86_64 -kernel $< diff --git a/tests/test.c b/tests/test.c new file mode 100644 index 0000000..4fad5e4 --- /dev/null +++ b/tests/test.c @@ -0,0 +1,11 @@ +#include "serial.h" +#include "vga.h" + +void run_test(){ + printf("Testing Serial"); + serialWrite('h'); + serialWrite('e'); + serialWrite('l'); + serialWrite('l'); + serialWrite('o'); +} diff --git a/tests/test.h b/tests/test.h new file mode 100644 index 0000000..3715a92 --- /dev/null +++ b/tests/test.h @@ -0,0 +1,3 @@ +#pragma once + +void run_test();