Skip to content

Commit 691c4d9

Browse files
committed
Added Kernel Core Entry Tests
1 parent ff9422a commit 691c4d9

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

src/kernel/core.asm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
extern kernel_core_entry
66
extern reload_idt_table
7+
global kernel_core_entry_asm
78

89
[SECTION .text]
9-
; protected mode real entry point.
10+
; protected mode real entry point.
1011
CLI
1112
mov ax, 0x10
1213
mov es, ax
@@ -26,3 +27,9 @@ extern reload_idt_table
2627
STI
2728
pop eax
2829
jmp eax
30+
31+
; kernel_core_entry_asm currently exists only for tests.
32+
kernel_core_entry_asm:
33+
; __TEST_INJECT_KERNEL_CORE_ENTRY__: mov eax, 0x922E52FF
34+
; __TEST_INJECT_KERNEL_CORE_ENTRY__: HLT
35+
ret

src/kernel/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "kernel/process.c"
1414

1515
extern void kernel_enable_interrupts();
16+
extern void kernel_core_entry_asm();
1617

1718
char command[30];
1819
int send_int(int a,int b) {
@@ -26,6 +27,9 @@ void kernel_core_entry() {
2627
print_log("Initializing Kernel");
2728

2829
populate_and_load_idt_table();
30+
31+
kernel_core_entry_asm();
32+
2933
print_log("Kernel enabling interrupts");
3034
kernel_enable_interrupts();
3135
keyboard_init();

tests/kernel_core_entry_test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
TEST_INJECT_WORD="__TEST_INJECT_KERNEL_CORE_ENTRY__"
4+
TEST_MAGIC_WANT="922E52FF"
5+
6+
source tests/lib.sh
7+
8+
os_test_up "${TEST_INJECT_WORD:?}" || exit -1
9+
10+
# Test
11+
set -e
12+
echo "${SCREEN_CONTENT:?}" | grep "Initializing Kernel" || ( echo "Test Failed!" && exit -1 )
13+
echo "${SCREEN_CONTENT:?}" | grep "Loading IDT Table" || ( echo "Test Failed!" && exit -1 )
14+
wait ${QEMU_PID:?}
15+
echo "$0 passed!!!"

tests/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44
# Execute Tests
55
bash tests/bootloader_stage1_test.sh
66
bash tests/bootloader_stage2_test.sh
7+
bash tests/kernel_core_entry_test.sh
78

89
# Done
910
echo "All tests passed!"

0 commit comments

Comments
 (0)