Skip to content
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
86 changes: 34 additions & 52 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,59 +41,41 @@ jobs:
build/${{ matrix.board }}/f9.elf
build/${{ matrix.board }}/f9.bin

test:
runs-on: ubuntu-24.04
needs: build

steps:
- uses: actions/checkout@v6

- name: Install ARM toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '15.2.Rel1'

- name: Install QEMU
if: matrix.board == 'netduinoplus2'
run: sudo apt-get update && sudo apt-get install -y qemu-system-arm

- name: QEMU boot test
if: matrix.board == 'netduinoplus2'
- name: Configure for netduinoplus2
run: make netduinoplus2_defconfig

- name: Enable test suite
run: |
timeout 15s qemu-system-arm \
-M netduinoplus2 \
-nographic \
-serial mon:stdio \
-kernel build/netduinoplus2/f9.elf 2>&1 | tee qemu.log || true

echo "=== QEMU Output ==="
cat qemu.log
echo "==================="

# Check for crashes first (highest priority failure)
if grep -qE "MEMFAULT|HardFault|panic|PANIC" qemu.log; then
echo "✗ Kernel crash detected"
exit 1
fi

# Check for test failures
if grep -q "FAILED" qemu.log; then
echo "✗ Test failure detected:"
grep -B1 "FAILED" qemu.log
exit 1
fi

# Check for successful boot
if grep -q "Press '?' to print KDB menu" qemu.log; then
echo "✓ KDB shell ready"
elif grep -q "KDB" qemu.log; then
echo "✓ KDB initialized"
elif grep -q "f9\|F9" qemu.log; then
echo "✓ Kernel boot detected"
else
echo "✗ No boot message detected (timeout or minimal output)"
exit 1
fi

# Check for test results if tests ran
if grep -q "test suite complete" qemu.log; then
ok_count=$(grep -c "OK" qemu.log || echo 0)
echo "✓ Test suite complete: $ok_count tests passed"
exit 0
fi

# Fallback: tests started but didn't complete
if grep -q "test suite starts" qemu.log; then
echo "✗ Test suite started but did not complete (timeout)"
exit 1
fi

exit 0
# Enable test suite, disable conflicting apps
echo "CONFIG_TESTS=y" >> .config
echo "# CONFIG_PINGPONG is not set" >> .config
echo "# CONFIG_L4_TEST is not set" >> .config
make oldconfig

- name: Build kernel with tests
run: make

- name: Run test suite
run: make run-tests

- name: Run MPU fault test (expected to fail on QEMU)
run: make run-tests FAULT=mpu
continue-on-error: true

- name: Run stack canary fault test
run: make run-tests FAULT=canary
24 changes: 24 additions & 0 deletions mk/generic.mk
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ qemu: $(out)/$(PROJECT).bin
-killall -q qemu-system-arm
$(QEMU) -M netduinoplus2 -nographic -kernel $(out)/$(PROJECT).elf -serial mon:stdio

# QEMU automated testing
# Usage: make run-tests (test suite)
# make run-tests FAULT=mpu (MPU fault test)
# make run-tests FAULT=canary (stack canary test)
.PHONY: run-tests
run-tests:
ifeq ($(FAULT),mpu)
@echo "Building with FAULT_TYPE=1 (MPU)..."
@$(MAKE) clean $(silent)
@$(MAKE) FAULT_TYPE=1 $(out)/$(PROJECT).elf $(silent)
@echo "Running MPU fault test under QEMU..."
@python3 scripts/qemu-test.py $(out)/$(PROJECT).elf --fault -t 30
else ifeq ($(FAULT),canary)
@echo "Building with FAULT_TYPE=2 (canary)..."
@$(MAKE) clean $(silent)
@$(MAKE) FAULT_TYPE=2 $(out)/$(PROJECT).elf $(silent)
@echo "Running stack canary fault test under QEMU..."
@python3 scripts/qemu-test.py $(out)/$(PROJECT).elf --fault -t 30
else
@echo "Running test suite under QEMU..."
@$(MAKE) $(out)/$(PROJECT).elf $(silent)
@python3 scripts/qemu-test.py $(out)/$(PROJECT).elf -t 45
endif

# Kconfiglib download target
$(KCONFIG_DIR)/kconfiglib.py:
@echo " CLONE Kconfiglib"
Expand Down
Loading
Loading