Skip to content

Commit 2674907

Browse files
authored
Merge pull request #32 from HexiumOS/dev
2 parents c5ba06f + dd595b0 commit 2674907

File tree

18 files changed

+289
-31
lines changed

18 files changed

+289
-31
lines changed

.github/workflows/makefile.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ jobs:
3333
- name: Verify xorriso installation
3434
run: xorriso -version
3535

36-
- name: Run build
37-
run: make
36+
- name: Install qemu
37+
run: sudo apt-get install qemu-system
38+
39+
- name: Run build & test
40+
run: make test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.iso
55
*.img
66
*.hdd
7+
/hexium_os-tests

GNUmakefile

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ run-x86_64: ovmf/ovmf-code-$(KARCH).fd ovmf/ovmf-vars-$(KARCH).fd $(IMAGE_NAME).
2828
-cdrom $(IMAGE_NAME).iso \
2929
$(QEMUFLAGS)
3030

31+
.PHONY: test
32+
test: test-iso
33+
@set -e; \
34+
FAILED=0; \
35+
echo "\n\n\n--------RUNNING KERNEL INTEGRATION TESTS-------\n\n"; \
36+
for iso in hexium_os-tests/*.iso; do \
37+
echo "==============================="; \
38+
echo "Running integration test: $$iso"; \
39+
echo "-------------------------------"; \
40+
if qemu-system-x86_64 \
41+
-cdrom "$$iso" \
42+
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
43+
-serial stdio -display none; \
44+
then \
45+
echo "✅ Integration Test passed: $$iso"; \
46+
elif [ $$? -eq 33 ]; then \
47+
echo "✅ Integration Test passed (exit 33): $$iso"; \
48+
else \
49+
echo "❌ Integration Test failed: $$iso"; \
50+
FAILED=1; \
51+
fi; \
52+
echo ""; \
53+
done; \
54+
exit $$FAILED
55+
3156
ovmf/ovmf-code-$(KARCH).fd:
3257
mkdir -p ovmf
3358
curl -Lo $@ https://github.com/osdev0/edk2-ovmf-nightly/releases/latest/download/ovmf-code-$(KARCH).fd
@@ -45,6 +70,10 @@ limine/limine:
4570
kernel:
4671
$(MAKE) -C kernel
4772

73+
.PHONY: kernel-test
74+
kernel-test:
75+
$(MAKE) -C kernel test
76+
4877
.PHONY: ramfs
4978
ramfs:
5079
mkdir -p initrd/
@@ -69,10 +98,33 @@ $(IMAGE_NAME).iso: limine/limine kernel ramfs
6998
./limine/limine bios-install $(IMAGE_NAME).iso
7099
rm -rf iso_root
71100

101+
.PHONY: test-iso
102+
test-iso: limine/limine ramfs kernel-test
103+
mkdir -p hexium_os-tests
104+
for testbin in kernel/kernel-test/*; do \
105+
testname=$$(basename $$testbin); \
106+
isodir=iso_root_$$testname; \
107+
mkdir -p $$isodir/boot/limine $$isodir/EFI/BOOT; \
108+
cp -v $$testbin $$isodir/boot/kernel; \
109+
cp -v ramfs.img $$isodir/boot/; \
110+
cp -v limine.conf $$isodir/boot/limine/; \
111+
cp -v limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin $$isodir/boot/limine/; \
112+
cp -v limine/BOOTX64.EFI $$isodir/EFI/BOOT/; \
113+
cp -v limine/BOOTIA32.EFI $$isodir/EFI/BOOT/; \
114+
xorriso -as mkisofs -b boot/limine/limine-bios-cd.bin \
115+
-no-emul-boot -boot-load-size 4 -boot-info-table \
116+
--efi-boot boot/limine/limine-uefi-cd.bin \
117+
-efi-boot-part --efi-boot-image --protective-msdos-label \
118+
$$isodir -o hexium_os-tests/hexium_os-$$testname.iso; \
119+
./limine/limine bios-install hexium_os-tests/hexium_os-$$testname.iso; \
120+
rm -rf $$isodir; \
121+
done
122+
72123
.PHONY: clean
73124
clean:
74125
$(MAKE) -C kernel clean
75-
rm -rf iso_root $(IMAGE_NAME).iso
126+
rm -rf iso_root *.iso
127+
rm -rf hexium_os-tests
76128

77129
.PHONY: distclean
78130
distclean: clean

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ make run
5757
## **:open_file_folder: Project Structure**
5858

5959
```bash
60-
/docs/ # Documentation
60+
/initrd/ # The initial ramdisk
61+
/userspace/ # Userspace programs
6162
/kernel/src/ # Kernel source code
6263
/kernel/target/ # Kernel output directory
6364
/limine # Limine and UEFI binaries (generated)

kernel/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/kernel
22
/target
3+
/kernel-test
4+
.test-log.txt

kernel/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ pc-keyboard = "0.7.0"
1818
x86 = "0.52.0"
1919
x86_64 = "0.14.2"
2020
uart_16550 = "0.3.2"
21+
22+
[[test]]
23+
name="should_panic"
24+
harness=false

kernel/GNUmakefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,26 @@ all:
2828
RUSTFLAGS="-C relocation-model=static" cargo build --target $(RUST_TARGET) --profile $(RUST_PROFILE)
2929
cp target/$(RUST_TARGET)/$(RUST_PROFILE_SUBDIR)/hexium_os kernel
3030

31+
test:
32+
mkdir -p kernel-test
33+
RUSTFLAGS="-C relocation-model=static" cargo test --no-run --target $(RUST_TARGET) --profile $(RUST_PROFILE) --color always \
34+
2>&1 | tee .test-log.txt
35+
@grep -o 'target/[^ )]*' .test-log.txt | while read -r path; do \
36+
if [ -x "$$path" ]; then \
37+
echo "Copying $$path to kernel-test/"; \
38+
cp "$$path" kernel-test/; \
39+
else \
40+
echo "Skipping non-executable: $$path"; \
41+
fi \
42+
done
43+
44+
@rm .test-log.txt
45+
3146
.PHONY: clean
3247
clean:
3348
cargo clean
3449
rm -rf kernel
50+
rm -rf kernel-test
3551

3652
.PHONY: distclean
3753
distclean: clean

kernel/src/devices/keyboard/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ pub async fn trace_keypresses() {
9696
if let Some(key) = keyboard.process_keyevent(key_event) {
9797
match key {
9898
DecodedKey::Unicode(character) => {
99-
trace!("Received keyboard interrupt with key: {}\n", character)
99+
trace!("Received keyboard interrupt with key: {}", character)
100100
}
101101
DecodedKey::RawKey(key) => {
102-
trace!("Received keyboard interrupt with key: {:?}\n", key)
102+
trace!("Received keyboard interrupt with key: {:?}", key)
103103
}
104104
}
105105
}

kernel/src/fs/ramfs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ impl RamFs {
2020

2121
impl FileSystem for RamFs {
2222
fn mount(&mut self, _path: &str) -> Result<(), ()> {
23-
info!("RamFs mounted\n");
23+
info!("RamFs mounted");
2424
Ok(())
2525
}
2626

2727
fn unmount(&mut self) -> Result<(), String> {
28-
info!("RamFs unmounted\n");
28+
info!("RamFs unmounted");
2929
Ok(())
3030
}
3131

@@ -60,7 +60,7 @@ pub fn init(vfs: &mut VFS) {
6060
if let Some(module_response) = boot::MODULE_REQUEST.get_response() {
6161
let modules = module_response.modules();
6262
if !modules.is_empty() {
63-
trace!("Ramdisk information:\n");
63+
trace!("Ramdisk information:");
6464
print!(" Ramdisk address: {:?}\n", modules[0].addr());
6565
print!(" Ramdisk size (bytes): {:?}\n", modules[0].size());
6666
print!(" Ramdisk module path: {:?}\n", modules[0].path());

kernel/src/interrupts/idt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn init() {
2929
}
3030

3131
extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
32-
debug!("EXCEPTION: BREAKPOINT\n{:#?}\n", stack_frame);
32+
debug!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
3333
}
3434

3535
extern "x86-interrupt" fn double_fault_handler(

0 commit comments

Comments
 (0)