Skip to content

Commit 129f464

Browse files
committed
test(ci:qemu): added integration test via GitHub Action
1 parent 6edce1e commit 129f464

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: TFLMWrapper ESP32 Integration Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Cache pip packages
17+
uses: actions/cache@v3
18+
with:
19+
path: ~/.cache/pip
20+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
21+
restore-keys: |
22+
${{ runner.os }}-pip-
23+
24+
- name: Cache PlatformIO packages
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.platformio
28+
key: ${{ runner.os }}-platformio-${{ hashFiles('**/platformio.ini') }}
29+
restore-keys: |
30+
${{ runner.os }}-platformio-
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: '3.x'
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install platformio
41+
sudo apt-get update
42+
sudo apt-get install -y wget xz-utils
43+
44+
- name: Install ESP32 toolchain
45+
run: |
46+
platformio platform install espressif32
47+
platformio platform install native
48+
49+
- name: Set up QEMU for ESP32-S3
50+
run: |
51+
wget https://github.com/espressif/qemu/releases/download/esp-develop-9.0.0-20240606/qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz
52+
tar xf qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz
53+
sudo mv qemu-xtensa-softmmu/bin/qemu-system-xtensa /usr/local/bin/
54+
sudo chmod +x /usr/local/bin/qemu-system-xtensa
55+
56+
- name: Run tests with QEMU
57+
run: |
58+
# Create a script to run tests with QEMU
59+
echo '#!/bin/bash
60+
qemu-system-xtensa \
61+
-machine esp32s3 \
62+
-nographic \
63+
-drive file=flash.bin,if=mtd,format=raw \
64+
-global driver=timer.esp32.timg,property=wdt_disable,value=true \
65+
-kernel .pio/build/esp32-s3-devkitc-1/firmware.elf \
66+
-serial stdio' > run_tests.sh
67+
chmod +x run_tests.sh
68+
69+
# Create an empty flash file
70+
dd if=/dev/zero of=flash.bin bs=1M count=4
71+
72+
# Build and run tests
73+
platformio test -e esp32-s3-devkitc-1 2>&1 | tee test_output.log
74+
75+
# Check test results
76+
if grep -q "PASSED" test_output.log; then
77+
echo "Tests passed successfully!"
78+
exit 0
79+
else
80+
echo "Tests failed!"
81+
exit 1
82+
fi
83+
84+
- name: Upload test results
85+
if: always()
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: test-results
89+
path: |
90+
test_output.log
91+
.pio/build/esp32-s3-devkitc-1/test_output.txt

0 commit comments

Comments
 (0)