Improve HIL tests (#773)

* tests: Add log-format test

* ci: Add list-ports test

* feat: Read a larger flash section

* feat: Update how we check the erase-region command

* fix: Elf paths

* fix: Typo

* feat: Add defmt_log level

* feat: Update defmt elf

* docs: Add instructions to build defmt elf

* feat: Change test order to keep a non-defmt elf flashed on c6
This commit is contained in:
Sergio Gasquez Arcos
2025-02-17 11:45:00 +01:00
committed by GitHub
parent 403b93d2e2
commit 7495637db0
8 changed files with 47 additions and 22 deletions

View File

@@ -71,7 +71,6 @@ jobs:
fail-fast: false
env:
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }}
ESPFLASH_APP: espflash/tests/data/${{ matrix.board.mcu }}
steps:
- uses: actions/checkout@v4
@@ -89,7 +88,7 @@ jobs:
run: bash espflash/tests/scripts/board-info.sh
- name: flash test
run: bash espflash/tests/scripts/flash.sh ${{ env.ESPFLASH_APP }}
run: bash espflash/tests/scripts/flash.sh ${{ matrix.board.mcu }}
- name: monitor test
run: bash espflash/tests/scripts/monitor.sh
@@ -99,7 +98,7 @@ jobs:
- name: save-image/write-bin test
run: |
bash espflash/tests/scripts/save-image_write-bin.sh ${{ matrix.board.mcu }} ${{ env.ESPFLASH_APP }}
bash espflash/tests/scripts/save-image_write-bin.sh ${{ matrix.board.mcu }}
bash espflash/tests/scripts/monitor.sh
- name: erase-region test
@@ -113,3 +112,6 @@ jobs:
- name: checksum-md5 test
run: bash espflash/tests/scripts/checksum-md5.sh
- name: list-ports test
run: bash espflash/tests/scripts/list-ports.sh

View File

@@ -1,7 +1,15 @@
The elf files under this folder have been generated using `esp-generate@0.2.2`:
The `$CHIP` elf files under this folder have been generated using `esp-generate@0.2.2`:
```
esp-generate --chip=$CHIP --headless $CHIP
cd $CHIP
cargo build --release
```
The `esp32c6_defmt` elf file under this folder has been generated using `esp-generate@04d69c9`:
```
esp-generate --chip=esp32c6 -o defmt --headless esp32c6_defmt
cd esp32c6_defmt
DEFMT_LOG=info cargo build --release
```

BIN
espflash/tests/data/esp32c6_defmt Executable file

Binary file not shown.

View File

@@ -5,8 +5,7 @@ echo "$result"
if [[ ! $result =~ "Flash has been erased!" ]]; then
exit 1
fi
# TODO: Once https://github.com/esp-rs/espflash/issues/697 is resolved this should read a larger portion of flash
result=$(espflash read-flash 0 0x200 flash_content.bin 2>&1)
result=$(espflash read-flash 0 0x4000 flash_content.bin 2>&1)
echo "$result"
if [[ ! $result =~ "Flash content successfully read and written to" ]]; then
exit 1

View File

@@ -30,27 +30,20 @@ echo "$result"
if [[ ! $result =~ "Erasing region at" ]]; then
exit 1
fi
# TODO: Once https://github.com/esp-rs/espflash/issues/697 is resolved we should look like:
# https://github.com/esp-rs/espflash/pull/754/commits/288eced61e7b21deface52a67e2f023b388ce6ed#diff-083bacee91d55c6adddc9dcd306da31db24e33591d5453e819999552995b85b7R8-R23
# Check first 0x1000 bytes are FF
result=$(espflash read-flash 0x1000 0x200 flash_content.bin 2>&1)
result=$(espflash read-flash 0x1000 0x2000 flash_content.bin 2>&1)
echo "$result"
if [[ ! $result =~ "Flash content successfully read and written to" ]]; then
echo "Failed to read flash contents"
exit 1
fi
if hexdump -v -e '/1 "%02x"' "flash_content.bin" | grep -qv '^ff*$'; then
# Check first 0x1000 bytes are FF
if head -c 4096 flash_content.bin | hexdump -v -e '/1 "%02x"' | grep -qv '^ff*$'; then
echo "First 0x1000 bytes should be empty (FF)"
exit 1
fi
# Check next 0x1000 bytes contain some non-FF bytes
result=$(espflash read-flash 0x2000 0x200 flash_content.bin 2>&1)
echo "$result"
if [[ ! $result =~ "Flash content successfully read and written to" ]]; then
echo "This region should be empty (FF)"
exit 1
fi
if ! hexdump -v -e '/1 "%02x"' "flash_content.bin" | grep -q '[0-e]'; then
echo "This region should contain some non-FF bytes"
if ! tail -c 4096 flash_content.bin | hexdump -v -e '/1 "%02x"' | grep -q '[0-e]'; then
echo "Next 0x1000 bytes should contain some non-FF bytes"
exit 1
fi
echo "Flash contents verified!"

View File

@@ -1,6 +1,21 @@
#!/usr/bin/env bash
app="espflash/tests/data/$1"
result=$(timeout 8s espflash flash --no-skip --monitor --non-interactive $1 2>&1)
if [[ "$1" == "esp32c6" ]]; then
app_defmt="${app}_defmt"
result=$(timeout 8s espflash flash --no-skip --monitor --non-interactive $app_defmt --log-format defmt 2>&1)
echo "$result"
if [[ ! $result =~ "Flashing has completed!" ]]; then
echo "Flashing failed!"
exit 1
fi
if ! echo "$result" | grep -q "Hello world!"; then
echo "Monitoring failed!"
exit 1
fi
fi
result=$(timeout 8s espflash flash --no-skip --monitor --non-interactive $app 2>&1)
echo "$result"
if [[ ! $result =~ "Flashing has completed!" ]]; then
echo "Flashing failed!"

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
result=$(espflash list-ports 2>&1)
echo "$result"
if [[ ! $result =~ "Silicon Labs" ]]; then
exit 1
fi

View File

@@ -1,11 +1,12 @@
#!/usr/bin/env bash
app="espflash/tests/data/$1"
# if $1 is esp32c2, create an variable that contains `-x 26mhz`
if [[ $1 == "esp32c2" ]]; then
freq="-x 26mhz"
fi
result=$(espflash save-image --merge --chip $1 $freq $2 app.bin 2>&1)
result=$(espflash save-image --merge --chip $1 $freq $app app.bin 2>&1)
echo "$result"
if [[ ! $result =~ "Image successfully saved!" ]]; then
exit 1