Skip to content

Commit 8ce78e3

Browse files
committed
Consolidate test suite with QEMU automation
This introduces a machine-parseable test framework for automated CI/CD testing under QEMU emulation. It validates core functionality including thread management, IPC, timers, and KIP access. Test categories: - Thread tests: identity, global ID, pager verification - Timer tests: period creation, sleep functionality - KIP tests: access validation, processor info - IPC tests: basic send/receive, timeout handling - Safety tests: timer edge cases, thread priority/yield Fault tests (separate invocation): - MPU fault: write to code memory (expected fail on QEMU) - Stack canary: overflow detection validation Usage: make run-tests # Run 14-test suite make run-tests FAULT=mpu # MPU protection test make run-tests FAULT=canary # Stack canary test
1 parent f96c391 commit 8ce78e3

20 files changed

Lines changed: 1998 additions & 214 deletions

.github/workflows/build.yml

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -41,59 +41,41 @@ jobs:
4141
build/${{ matrix.board }}/f9.elf
4242
build/${{ matrix.board }}/f9.bin
4343
44+
test:
45+
runs-on: ubuntu-24.04
46+
needs: build
47+
48+
steps:
49+
- uses: actions/checkout@v6
50+
51+
- name: Install ARM toolchain
52+
uses: carlosperate/arm-none-eabi-gcc-action@v1
53+
with:
54+
release: '15.2.Rel1'
55+
4456
- name: Install QEMU
45-
if: matrix.board == 'netduinoplus2'
4657
run: sudo apt-get update && sudo apt-get install -y qemu-system-arm
4758

48-
- name: QEMU boot test
49-
if: matrix.board == 'netduinoplus2'
59+
- name: Configure for netduinoplus2
60+
run: make netduinoplus2_defconfig
61+
62+
- name: Enable test suite
5063
run: |
51-
timeout 15s qemu-system-arm \
52-
-M netduinoplus2 \
53-
-nographic \
54-
-serial mon:stdio \
55-
-kernel build/netduinoplus2/f9.elf 2>&1 | tee qemu.log || true
56-
57-
echo "=== QEMU Output ==="
58-
cat qemu.log
59-
echo "==================="
60-
61-
# Check for crashes first (highest priority failure)
62-
if grep -qE "MEMFAULT|HardFault|panic|PANIC" qemu.log; then
63-
echo "✗ Kernel crash detected"
64-
exit 1
65-
fi
66-
67-
# Check for test failures
68-
if grep -q "FAILED" qemu.log; then
69-
echo "✗ Test failure detected:"
70-
grep -B1 "FAILED" qemu.log
71-
exit 1
72-
fi
73-
74-
# Check for successful boot
75-
if grep -q "Press '?' to print KDB menu" qemu.log; then
76-
echo "✓ KDB shell ready"
77-
elif grep -q "KDB" qemu.log; then
78-
echo "✓ KDB initialized"
79-
elif grep -q "f9\|F9" qemu.log; then
80-
echo "✓ Kernel boot detected"
81-
else
82-
echo "✗ No boot message detected (timeout or minimal output)"
83-
exit 1
84-
fi
85-
86-
# Check for test results if tests ran
87-
if grep -q "test suite complete" qemu.log; then
88-
ok_count=$(grep -c "OK" qemu.log || echo 0)
89-
echo "✓ Test suite complete: $ok_count tests passed"
90-
exit 0
91-
fi
92-
93-
# Fallback: tests started but didn't complete
94-
if grep -q "test suite starts" qemu.log; then
95-
echo "✗ Test suite started but did not complete (timeout)"
96-
exit 1
97-
fi
98-
99-
exit 0
64+
# Enable test suite, disable conflicting apps
65+
echo "CONFIG_TESTS=y" >> .config
66+
echo "# CONFIG_PINGPONG is not set" >> .config
67+
echo "# CONFIG_L4_TEST is not set" >> .config
68+
make oldconfig
69+
70+
- name: Build kernel with tests
71+
run: make
72+
73+
- name: Run test suite
74+
run: make run-tests
75+
76+
- name: Run MPU fault test (expected to fail on QEMU)
77+
run: make run-tests FAULT=mpu
78+
continue-on-error: true
79+
80+
- name: Run stack canary fault test
81+
run: make run-tests FAULT=canary

mk/generic.mk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ qemu: $(out)/$(PROJECT).bin
105105
-killall -q qemu-system-arm
106106
$(QEMU) -M netduinoplus2 -nographic -kernel $(out)/$(PROJECT).elf -serial mon:stdio
107107

108+
# QEMU automated testing
109+
# Usage: make run-tests (test suite)
110+
# make run-tests FAULT=mpu (MPU fault test)
111+
# make run-tests FAULT=canary (stack canary test)
112+
.PHONY: run-tests
113+
run-tests:
114+
ifeq ($(FAULT),mpu)
115+
@echo "Building with FAULT_TYPE=1 (MPU)..."
116+
@$(MAKE) clean $(silent)
117+
@$(MAKE) FAULT_TYPE=1 $(out)/$(PROJECT).elf $(silent)
118+
@echo "Running MPU fault test under QEMU..."
119+
@python3 scripts/qemu-test.py $(out)/$(PROJECT).elf --fault -t 30
120+
else ifeq ($(FAULT),canary)
121+
@echo "Building with FAULT_TYPE=2 (canary)..."
122+
@$(MAKE) clean $(silent)
123+
@$(MAKE) FAULT_TYPE=2 $(out)/$(PROJECT).elf $(silent)
124+
@echo "Running stack canary fault test under QEMU..."
125+
@python3 scripts/qemu-test.py $(out)/$(PROJECT).elf --fault -t 30
126+
else
127+
@echo "Running test suite under QEMU..."
128+
@$(MAKE) $(out)/$(PROJECT).elf $(silent)
129+
@python3 scripts/qemu-test.py $(out)/$(PROJECT).elf -t 45
130+
endif
131+
108132
# Kconfiglib download target
109133
$(KCONFIG_DIR)/kconfiglib.py:
110134
@echo " CLONE Kconfiglib"

0 commit comments

Comments
 (0)