Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run in QEMU as a GitHub action #62

Merged
merged 13 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/build-i686.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ jobs:
steps:

- name: Install dependencies
run: sudo apt-get install -y gcc-multilib

- uses: ilammy/setup-nasm@v1
run: sudo apt-get install -y gcc-multilib grub-common nasm qemu-system-x86 xorriso

- uses: actions/checkout@v4
with:
Expand All @@ -30,3 +28,16 @@ jobs:

- name: make testapp
run: make testapp

- name: make qemu
run: make qemu

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: |
kernel/interface/i686/jinue
userspace/testapp/testapp

- name: make qemu-check
run: make qemu-check
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ qemu:
qemu-run:
make -C $(qemu) run

# build the ISO file for QEMU and run (without the debugger)
# build the ISO file for QEMU and run (without VGA display)
.PHONY: qemu-run-no-display
qemu-run-no-display:
make -C $(qemu) run-no-display

# build the ISO file for QEMU, run and check the output
.PHONY: qemu-check
qemu-check:
make -C $(qemu) check

# Run cppcheck on the kernel sources
# Note: there are known failures
.PHONY: cppcheck-kernel
Expand Down
12 changes: 10 additions & 2 deletions devel/qemu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ grub_image_rel = boot/grub/i386-pc/jinue.img
grub_image = $(temp_iso_fs)/$(grub_image_rel)
kernel_img_copy = $(temp_iso_fs)/boot/$(notdir $(kernel_img))
initrd_copy = $(temp_iso_fs)/boot/$(notdir $(testapp_initrd))
run_log = run-jinue.log
check_script = check-log.sh

target = $(jinue_iso)
unclean_recursive = $(temp_iso_fs)
Expand All @@ -61,7 +63,7 @@ run: $(jinue_iso)
-serial stdio \
-smp 1 \
-usb \
-vga std
-vga std | tee $(run_log)

.PHONY: run-no-display
run-no-display: $(jinue_iso)
Expand All @@ -74,7 +76,11 @@ run-no-display: $(jinue_iso)
-display none \
-smp 1 \
-usb \
-vga std
-vga std | tee $(run_log)

.PHONY: check
check: $(run_log)
./$(check_script) $<

.PHONY: kernel-image
kernel-image:
Expand Down Expand Up @@ -127,3 +133,5 @@ $(jinue_iso): $(grub_image)
/ \
--sort-weight 1 \
/boot

$(run_log): run-no-display
89 changes: 89 additions & 0 deletions devel/qemu/check-log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
# Copyright (C) 2024 Philippe Aubertin.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the author nor the names of other contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

fail () {
echo "*** [ FAIL ] ***" >&2
exit 1
}

usage () {
echo "USAGE: $(basename $0) log_file" >&2
exit 1
}

[[ $# -ne 1 ]] && usage

echo "* Check log file exists"
[[ -f $1 ]] || fail

echo "* Check kernel started"
grep -F "Jinue microkernel started." $1 || fail

echo "* Check kernel did not panic"
grep -F -A 20 "KERNEL PANIC" $1 && fail

echo "* Check user space loader started"
grep -F "Jinue user space loader (jinue-userspace-loader) started." $1 || fail

echo "* Check test application started"
grep -F "Jinue test app (/sbin/init) started." $1 || fail

echo "* Check threading and IPC test ran"
grep -F "Running threading and IPC test" $1 || fail

echo "* Check main thread received message from client thread"
grep -F "Main thread received message" $1 || fail

MESSAGE=`grep -F -A 5 "Main thread received message:" $1`

echo "* Checking message data"
echo "$MESSAGE" | grep -E 'data:[ ]+"Hello World!"' || fail

echo "* Checking message size"
echo "$MESSAGE" | grep -E 'size:[ ]+13$' || fail

echo "* Checking function number"
echo "$MESSAGE" | grep -E 'function:[ ]+4138\b' || fail

echo "* Checking cookie"
echo "$MESSAGE" | grep -E 'cookie:[ ]+0xca11ab1e$' || fail

echo "* Check client thread received reply from main thread"
grep -F "Client thread got reply from main thread" $1 || fail

REPLY=`grep -F -A 2 "Client thread got reply from main thread:" $1`

echo "* Checking reply data"
echo "$REPLY" | grep -E 'data:[ ]+"Hi, Main Thread!"' || fail

echo "* Checking message size"
echo "$REPLY" | grep -E 'size:[ ]+17$' || fail

echo "[ PASS ]"
1 change: 1 addition & 0 deletions devel/qemu/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
linux16 /boot/jinue \
on_panic=reboot \
serial_enable=yes \
serial_dev=/dev/ttyS0 \
DEBUG_DUMP_MEMORY_MAP=1 \
Expand Down
56 changes: 0 additions & 56 deletions doc/TODO.txt

This file was deleted.

17 changes: 17 additions & 0 deletions doc/cmdline.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ For user space environment variables, the behaviour is undefined.

| Name | Type | Description |
|------------------|---------|--------------------------------------------------------------|
| on_panic | string | Action to take after a kernel panic |
| pae | string | Controls whether Physical Address Extension (PAE) is enabled |
| serial_enable | boolean | Enable/disable logging on the serial port |
| serial_baud_rate | integer | Baud rate for serial port logging |
Expand All @@ -58,6 +59,22 @@ Integer option values can be specified as a decimal number without any leading
zero (e.g. `42` but not `042`) or as an hexadecimal number prepended with `0x`
(e.g. `0x3f8`).

### Kernel Panic Action - `on_panic`

Action to take after a kernel panic.

Type: string

The following values are recognized:

* `halt` (default) halt CPU.
* `reboot` reboot the system.

Rebooting after a kernel panic can be helpful when testing the kernel in a virtual
machine, as some virtual machine hosts can be set to exit when a reboot is triggered.
If the test hangs instead of exiting, it can cause issues, particularly in automated
testing environments.

### Physical Address Extension - `pae`

Controls whether Physical Address Extension (PAE) is enabled or not.
Expand Down
Loading