diff options
author | Marvin Borner | 2020-08-31 23:09:35 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-31 23:09:35 +0200 |
commit | d79b7492910d4a77b8c3a70f28c5ea4c81a0b2e5 (patch) | |
tree | 3e7c6c864d984e1f0fc2533f4d4202833b6625a7 | |
parent | 00adfffc296476f3fe247ce3f341c9f5addd190d (diff) |
Abstracted tests from boot process
-rw-r--r-- | kernel/Makefile | 13 | ||||
-rw-r--r-- | kernel/main.c | 6 | ||||
-rw-r--r-- | kernel/test.c | 25 |
3 files changed, 18 insertions, 26 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index bdf89ff..a907986 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,8 +1,6 @@ # MIT License, Copyright (c) 2020 Marvin Borner -COBJS = main.o \ - test.o \ - drivers/interrupts.o \ +COBJS = drivers/interrupts.o \ drivers/interrupts_asm.o \ drivers/keyboard.o \ drivers/mouse.o \ @@ -39,12 +37,15 @@ bootloader: @mkdir -p ../build/ @$(AS) -f bin entry.asm -o ../build/boot.bin -compile: $(COBJS) +compile: main.o $(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 -compile_test: compile +compile_test: CFLAGS += -Dtest -Wl,-etest_all +compile_test: test.o $(COBJS) + @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/main.c b/kernel/main.c index 759343e..7d87be5 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -9,15 +9,10 @@ #include <mouse.h> #include <serial.h> #include <syscall.h> -#include <test.h> #include <timer.h> void kernel_main(struct vid_info *vid_info) { -#ifdef test - test_all(vid_info); -#else - heap_init(0x00f00000); boot_passed = vid_info; @@ -41,5 +36,4 @@ void kernel_main(struct vid_info *vid_info) proc_init(); idle(); -#endif } diff --git a/kernel/test.c b/kernel/test.c index 6a69cb6..1960a5a 100644 --- a/kernel/test.c +++ b/kernel/test.c @@ -35,22 +35,18 @@ void test_math() void test_conv() { - char buf0[3] = { 0 }; - char buf1[3] = { 0 }; - char buf2[1] = { 0 }; - char buf3[7] = { 0 }; - char buf4[5] = { 0 }; - char buf5[2] = { 0 }; - strcpy(buf0, "42"); - strcpy(buf1, "42"); - equals(atoi(buf0), 42); + char buf1[1] = { 0 }; + char buf2[7] = { 0 }; + char buf3[5] = { 0 }; + char buf4[3] = { 0 }; + equals(atoi("42"), 42); equals_str(htoa(0x42), "42"); - equals(htoi(buf1), 0x42); + equals(htoi("42"), 0x42); equals_str(itoa(42), "42"); - equals_str(conv_base(42, buf2, 0, 0), ""); - equals_str(conv_base(42, buf3, 2, 0), "101010"); - equals_str(conv_base(424242, buf4, 36, 0), "93ci"); - equals_str(conv_base(0xffffffff, buf5, 10, 1), "-1"); + equals_str(conv_base(42, buf1, 0, 0), ""); + equals_str(conv_base(42, buf2, 2, 0), "101010"); + equals_str(conv_base(424242, buf3, 36, 0), "93ci"); + equals_str(conv_base(0xffffffff, buf4, 10, 1), "-1"); } void test_mem() @@ -73,6 +69,7 @@ void test_mem() equals_str(memset(buf2, 'x', 5), "xxxxx"); } +// TODO: Move to other file (top!) void test_all(struct vid_info *vid_info) { // Serial connection |