forked from rcore-os/zCore
tests: update Makefile
This commit is contained in:
parent
7763b9d4e0
commit
180081bae7
6
Makefile
6
Makefile
|
@ -98,9 +98,3 @@ baremetal-test-img: prebuilt/linux/$(ROOTFS_TAR) rcore-fs-fuse
|
||||||
@cp prebuilt/linux/libc-libos.so rootfs/lib/ld-musl-x86_64.so.1
|
@cp prebuilt/linux/libc-libos.so rootfs/lib/ld-musl-x86_64.so.1
|
||||||
@echo Resizing $(ARCH).img
|
@echo Resizing $(ARCH).img
|
||||||
@qemu-img resize $(OUT_IMG) +5M
|
@qemu-img resize $(OUT_IMG) +5M
|
||||||
|
|
||||||
baremetal-test:
|
|
||||||
@make -C zCore baremetal-test MODE=release LINUX=1 | tee stdout-baremetal-test
|
|
||||||
|
|
||||||
baremetal-test-rv64:
|
|
||||||
@make -C zCore baremetal-test-rv64 ARCH=riscv64 MODE=release LINUX=1 ROOTPROC=$(ROOTPROC) | tee -a stdout-baremetal-test-rv64 | tee stdout-rv64
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
mod event_listener;
|
mod event_listener;
|
||||||
mod id_allocator;
|
mod id_allocator;
|
||||||
mod irq_manager;
|
mod irq_manager;
|
||||||
|
|
|
@ -8,12 +8,12 @@ LINUX ?=
|
||||||
LIBOS ?=
|
LIBOS ?=
|
||||||
TEST ?=
|
TEST ?=
|
||||||
GRAPHIC ?=
|
GRAPHIC ?=
|
||||||
|
DISK ?=
|
||||||
HYPERVISOR ?=
|
HYPERVISOR ?=
|
||||||
V ?=
|
V ?=
|
||||||
|
|
||||||
USER ?=
|
USER ?=
|
||||||
ZBI ?= bringup
|
ZBI ?= bringup
|
||||||
CMDLINE ?= LOG=$(LOG)
|
|
||||||
|
|
||||||
SMP ?= 1
|
SMP ?= 1
|
||||||
ACCEL ?=
|
ACCEL ?=
|
||||||
|
@ -21,6 +21,12 @@ ACCEL ?=
|
||||||
OBJDUMP ?= rust-objdump --print-imm-hex --x86-asm-syntax=intel
|
OBJDUMP ?= rust-objdump --print-imm-hex --x86-asm-syntax=intel
|
||||||
OBJCOPY ?= rust-objcopy --binary-architecture=$(ARCH)
|
OBJCOPY ?= rust-objcopy --binary-architecture=$(ARCH)
|
||||||
|
|
||||||
|
ifeq ($(LINUX), 1)
|
||||||
|
CMDLINE ?= LOG=$(LOG)
|
||||||
|
else
|
||||||
|
CMDLINE ?= LOG=$(LOG):TERM=xterm-256color:console.shell=true:virtcon.disable=true
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(LINUX), 1)
|
ifeq ($(LINUX), 1)
|
||||||
user_img := $(ARCH).img
|
user_img := $(ARCH).img
|
||||||
else ifeq ($(USER), 1)
|
else ifeq ($(USER), 1)
|
||||||
|
@ -126,32 +132,33 @@ endif
|
||||||
qemu_opts := -smp $(SMP)
|
qemu_opts := -smp $(SMP)
|
||||||
|
|
||||||
ifeq ($(ARCH), x86_64)
|
ifeq ($(ARCH), x86_64)
|
||||||
baremetal-test-qemu_opts := \
|
qemu_opts += \
|
||||||
-machine q35 \
|
-machine q35 \
|
||||||
-cpu Haswell,+smap,-check,-fsgsbase \
|
-cpu Haswell,+smap,-check,-fsgsbase \
|
||||||
-m 4G \
|
-m 1G \
|
||||||
-serial mon:stdio \
|
-serial mon:stdio \
|
||||||
-drive format=raw,if=pflash,readonly=on,file=$(ovmf) \
|
-drive format=raw,if=pflash,readonly=on,file=$(ovmf) \
|
||||||
-drive format=raw,file=fat:rw:$(esp) \
|
-drive format=raw,file=fat:rw:$(esp) \
|
||||||
-device ich9-ahci,id=ahci \
|
|
||||||
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
|
|
||||||
-nic none
|
-nic none
|
||||||
qemu_opts += $(baremetal-test-qemu_opts) \
|
|
||||||
-drive format=qcow2,id=userdisk,if=none,file=$(qemu_disk) \
|
|
||||||
-device ide-hd,bus=ahci.0,drive=userdisk
|
|
||||||
else ifeq ($(ARCH), riscv64)
|
else ifeq ($(ARCH), riscv64)
|
||||||
qemu_opts += \
|
qemu_opts += \
|
||||||
-machine virt \
|
-machine virt \
|
||||||
-bios default \
|
-bios default \
|
||||||
-m 512M \
|
-m 512M \
|
||||||
-no-reboot \
|
-no-reboot \
|
||||||
-no-shutdown \
|
|
||||||
-serial mon:stdio \
|
-serial mon:stdio \
|
||||||
-drive format=qcow2,id=userdisk,file=$(qemu_disk) \
|
|
||||||
-device virtio-blk-device,drive=userdisk \
|
|
||||||
-kernel $(kernel_img) \
|
-kernel $(kernel_img) \
|
||||||
-initrd $(USER_IMG) \
|
-initrd $(USER_IMG) \
|
||||||
-append "LOG=$(LOG)"
|
-append "$(CMDLINE)"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DISK), on)
|
||||||
|
ifeq ($(ARCH), x86_64)
|
||||||
|
qemu_opts += -device ide-hd,bus=ahci.0,drive=userdisk
|
||||||
|
else ifeq ($(ARCH), riscv64)
|
||||||
|
qemu_opts += -device virtio-blk-device,drive=userdisk
|
||||||
|
endif
|
||||||
|
qemu_opts += -drive format=qcow2,id=userdisk,if=none,file=$(qemu_disk)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(GRAPHIC), on)
|
ifeq ($(GRAPHIC), on)
|
||||||
|
@ -165,7 +172,6 @@ ifeq ($(GRAPHIC), on)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
qemu_opts += -display none -nographic
|
qemu_opts += -display none -nographic
|
||||||
baremetal-test-qemu_opts += -display none -nographic
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ACCEL), 1)
|
ifeq ($(ACCEL), 1)
|
||||||
|
@ -198,6 +204,10 @@ endif
|
||||||
|
|
||||||
.PHONY: justrun
|
.PHONY: justrun
|
||||||
justrun: $(qemu_disk)
|
justrun: $(qemu_disk)
|
||||||
|
ifeq ($(ARCH), x86_64)
|
||||||
|
$(sed) 's#initramfs=.*#initramfs=\\EFI\\zCore\\$(notdir $(user_img))#' $(esp)/EFI/Boot/rboot.conf
|
||||||
|
$(sed) 's#cmdline=.*#cmdline=$(CMDLINE)#' $(esp)/EFI/Boot/rboot.conf
|
||||||
|
endif
|
||||||
$(qemu) $(qemu_opts)
|
$(qemu) $(qemu_opts)
|
||||||
|
|
||||||
.PHONY: debugrun
|
.PHONY: debugrun
|
||||||
|
@ -243,12 +253,6 @@ ifeq ($(ARCH), x86_64)
|
||||||
cp rboot.conf $(esp)/EFI/Boot/rboot.conf
|
cp rboot.conf $(esp)/EFI/Boot/rboot.conf
|
||||||
cp $(kernel_elf) $(esp)/EFI/zCore/zcore.elf
|
cp $(kernel_elf) $(esp)/EFI/zCore/zcore.elf
|
||||||
cp $(user_img) $(esp)/EFI/zCore/
|
cp $(user_img) $(esp)/EFI/zCore/
|
||||||
$(sed) "s/fuchsia.zbi/$(notdir $(user_img))/" $(esp)/EFI/Boot/rboot.conf
|
|
||||||
ifneq ($(CMDLINE),)
|
|
||||||
$(sed) "s#cmdline=.*#cmdline=$(CMDLINE)#" $(esp)/EFI/Boot/rboot.conf
|
|
||||||
else
|
|
||||||
$(sed) "s/LOG=warn/LOG=$(LOG)/" $(esp)/EFI/Boot/rboot.conf
|
|
||||||
endif
|
|
||||||
else ifeq ($(ARCH), riscv64)
|
else ifeq ($(ARCH), riscv64)
|
||||||
$(OBJCOPY) $(kernel_elf) --strip-all -O binary $@
|
$(OBJCOPY) $(kernel_elf) --strip-all -O binary $@
|
||||||
endif
|
endif
|
||||||
|
@ -271,21 +275,6 @@ image:
|
||||||
hdiutil create -fs fat32 -ov -volname EFI -format UDTO -srcfolder $(esp) $(build_path)/zcore.cdr
|
hdiutil create -fs fat32 -ov -volname EFI -format UDTO -srcfolder $(esp) $(build_path)/zcore.cdr
|
||||||
qemu-img convert -f raw $(build_path)/zcore.cdr -O qcow2 $(build_path)/zcore.qcow2
|
qemu-img convert -f raw $(build_path)/zcore.cdr -O qcow2 $(build_path)/zcore.qcow2
|
||||||
|
|
||||||
################ Tests ################
|
|
||||||
|
|
||||||
.PHONY: baremetal-qemu-disk
|
|
||||||
baremetal-qemu-disk:
|
|
||||||
@qemu-img create -f qcow2 $(build_path)/disk.qcow2 100M
|
|
||||||
|
|
||||||
.PHONY: baremetal-test
|
|
||||||
baremetal-test:
|
|
||||||
cp rboot.conf $(esp)/EFI/Boot/rboot.conf
|
|
||||||
timeout --foreground 8s $(qemu) $(baremetal-test-qemu_opts)
|
|
||||||
|
|
||||||
.PHONY: baremetal-test-rv64
|
|
||||||
baremetal-test-rv64: build $(qemu_disk)
|
|
||||||
timeout --foreground 8s $(qemu) $(qemu_opts) -append ROOTPROC=$(ROOTPROC)
|
|
||||||
|
|
||||||
################ Deprecated ################
|
################ Deprecated ################
|
||||||
|
|
||||||
VMDISK := $(build_path)/boot.vdi
|
VMDISK := $(build_path)/boot.vdi
|
||||||
|
|
|
@ -39,11 +39,13 @@ pub fn boot_options() -> BootOptions {
|
||||||
std::process::exit(-1);
|
std::process::exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let log_level = std::env::var("LOG").unwrap_or_default();
|
let (cmdline, log_level) = if cfg!(feature = "zircon") {
|
||||||
let cmdline = if cfg!(feature = "zircon") {
|
let cmdline = args.get(2).cloned().unwrap_or_default();
|
||||||
args.get(2).cloned().unwrap_or_default()
|
let options = parse_cmdline(&cmdline);
|
||||||
|
let log_level = String::from(*options.get("LOG").unwrap_or(&""));
|
||||||
|
(cmdline, log_level)
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
(String::new(), std::env::var("LOG").unwrap_or_default())
|
||||||
};
|
};
|
||||||
BootOptions {
|
BootOptions {
|
||||||
cmdline,
|
cmdline,
|
||||||
|
@ -89,10 +91,10 @@ pub fn wait_for_exit(proc: Option<Arc<Process>>) -> ! {
|
||||||
let future = async move {
|
let future = async move {
|
||||||
use zircon_object::object::Signal;
|
use zircon_object::object::Signal;
|
||||||
let object: Arc<dyn KernelObject> = proc.clone();
|
let object: Arc<dyn KernelObject> = proc.clone();
|
||||||
let signal = if cfg!(feature = "zircon") {
|
let signal = if cfg!(any(feature = "linux", feature = "baremetal-test")) {
|
||||||
Signal::USER_SIGNAL_0
|
|
||||||
} else {
|
|
||||||
Signal::PROCESS_TERMINATED
|
Signal::PROCESS_TERMINATED
|
||||||
|
} else {
|
||||||
|
Signal::USER_SIGNAL_0
|
||||||
};
|
};
|
||||||
object.wait_signal(signal).await;
|
object.wait_signal(signal).await;
|
||||||
check_exit_code(proc)
|
check_exit_code(proc)
|
||||||
|
@ -120,9 +122,6 @@ pub fn wait_for_exit(proc: Option<Arc<Process>>) -> ! {
|
||||||
let has_task = executor::run_until_idle();
|
let has_task = executor::run_until_idle();
|
||||||
if cfg!(feature = "baremetal-test") && !has_task {
|
if cfg!(feature = "baremetal-test") && !has_task {
|
||||||
proc.map(check_exit_code);
|
proc.map(check_exit_code);
|
||||||
// if let Some(p) = proc {
|
|
||||||
// check_exit_code(p);
|
|
||||||
// }
|
|
||||||
kernel_hal::cpu::reset();
|
kernel_hal::cpu::reset();
|
||||||
}
|
}
|
||||||
kernel_hal::interrupt::wait_for_interrupt();
|
kernel_hal::interrupt::wait_for_interrupt();
|
||||||
|
|
|
@ -291,7 +291,7 @@ impl Syscall<'_> {
|
||||||
info_ptr.write(job.get_info())?;
|
info_ptr.write(job.get_info())?;
|
||||||
}
|
}
|
||||||
Topic::ProcessVmos => {
|
Topic::ProcessVmos => {
|
||||||
error!("A dummy implementation for utest Bti.NoDelayedUnpin, it does not check the reture value");
|
warn!("A dummy implementation for utest Bti.NoDelayedUnpin, it does not check the reture value");
|
||||||
actual.write(0)?;
|
actual.write(0)?;
|
||||||
avail.write(0)?;
|
avail.write(0)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue