Skip to content

Commit 24b1310

Browse files
committed
ci(lcd_qemu_rgb_panel): test example in CI
1 parent 4d380e0 commit 24b1310

File tree

10 files changed

+91
-16
lines changed

10 files changed

+91
-16
lines changed

Diff for: .github/test_requirements.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Generic requirements for all tests
2+
pytest-embedded==1.11.7
3+
pytest-embedded-serial-esp==1.11.7
4+
pytest-embedded-idf==1.11.7
5+
pytest-embedded-qemu==1.11.7
6+
pytest-custom_exit_code==0.3.0
7+
8+
# Test-specific requirements
9+
cryptography==43.0.3
10+
pillow==10.3.0

Diff for: .github/workflows/build_and_run_apps.yml

+27-14
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ jobs:
7272
fail-fast: false
7373
matrix:
7474
idf_ver:
75-
- "release-v5.0"
76-
- "release-v5.1"
77-
- "release-v5.2"
78-
- "release-v5.3"
75+
# - "release-v5.0"
76+
# - "release-v5.1"
77+
# - "release-v5.2"
78+
# - "release-v5.3"
7979
- "latest"
8080
parallel_index: [1,2,3,4,5] # Update --parallel-count below when changing this
8181
runs-on: ubuntu-22.04
@@ -122,27 +122,30 @@ jobs:
122122
fail-fast: false
123123
matrix:
124124
idf_ver:
125-
- "release-v5.0"
126-
- "release-v5.1"
127-
- "release-v5.2"
128-
- "release-v5.3"
125+
# - "release-v5.0"
126+
# - "release-v5.1"
127+
# - "release-v5.2"
128+
# - "release-v5.3"
129129
- "latest"
130130
runner:
131-
- runs-on: "esp32"
131+
- runs-on: '["self-hosted", "linux", "docker", "esp32"]'
132132
marker: "generic"
133133
target: "esp32"
134-
- runs-on: "ESP32-ETHERNET-KIT"
134+
- runs-on: '["self-hosted", "linux", "docker", "ESP32-ETHERNET-KIT"]'
135135
marker: "ethernet"
136136
target: "esp32"
137-
- runs-on: "spi_nand_flash"
137+
- runs-on: '["self-hosted", "linux", "docker", "spi_nand_flash"]'
138138
marker: "spi_nand_flash"
139139
target: "esp32"
140+
- runs-on: '["ubuntu-22.04"]'
141+
marker: "qemu"
142+
target: "esp32"
140143
env:
141144
TEST_RESULT_NAME: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }}
142145
TEST_RESULT_FILE: test_results_${{ matrix.runner.target }}_${{ matrix.runner.marker }}_${{ matrix.idf_ver }}.xml
143-
runs-on: [self-hosted, linux, docker, "${{ matrix.runner.runs-on }}"]
146+
runs-on: ${{ fromjson(matrix.runner.runs-on) }}
144147
container:
145-
image: python:3.11-bookworm
148+
image: 'python:3.11-bookworm'
146149
options: --privileged # Privileged mode has access to serial ports
147150
steps:
148151
- uses: actions/checkout@v4
@@ -153,7 +156,17 @@ jobs:
153156
- name: Install Python packages
154157
env:
155158
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi/"
156-
run: pip install --prefer-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pytest-custom_exit_code
159+
run: python3 -m pip install --prefer-binary -r .github/test_requirements.txt
160+
- name: Install QEMU
161+
if: matrix.runner.marker == 'qemu'
162+
env:
163+
QEMU_VERSION: "esp-develop-9.0.0-20240606"
164+
QEMU_ARCHIVE: "qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz"
165+
run: |
166+
curl -sSL -o ${QEMU_ARCHIVE} https://github.com/espressif/qemu/releases/download/${QEMU_VERSION}/${QEMU_ARCHIVE}
167+
tar -xf ${QEMU_ARCHIVE}
168+
rm ${QEMU_ARCHIVE}
169+
echo "PATH=$PWD/qemu/bin" >> $GITHUB_PATH
157170
- name: Run apps
158171
run: |
159172
python3 .github/get_pytest_args.py --target=${{ matrix.runner.target }} -v 'build_info*.json' pytest-args.txt

Diff for: esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ By default, the example will use the target internal RAM as the frame buffer. To
1616

1717
### Build and run
1818

19-
To build the example, run `idf.py build` command.
19+
To build and run the example, run:
20+
```shell
21+
idf.py qemu -g monitor
22+
```
2023

21-
Please refer to the [QEMU Guide](https://github.com/espressif/esp-toolchain-docs/blob/main/qemu/README.md) for the detailed steps to setup and run the image.
24+
Please refer to the [QEMU Guide](https://github.com/espressif/esp-toolchain-docs/blob/main/qemu/README.md) for more information on installing and running QEMU.
2225

2326
## Example Output
2427

@@ -34,3 +37,6 @@ I (55) example: Starting LVGL task
3437
I (65) example: Display LVGL Scatter Chart
3538
I (75) main_task: Returned from app_main()
3639
```
40+
41+
The following image should be displayed:
42+
![](doc/scatter_chart.png)
Loading

Diff for: esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/main/Kconfig.projbuild

+7
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ menu "Example Configuration"
66
help
77
Use QEMU RGB panel dedicated framebuffer as the framebuffer for LVGL.
88

9+
config EXAMPLE_QEMU_RGB_PANEL_STATIC
10+
bool "Static UI (for testing)"
11+
default "n"
12+
help
13+
If this option is enabled, example will not update the chart after
14+
it was drawn. This option is used in CI when testing the example.
15+
916
endmenu

Diff for: esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/main/lcd_qemu_rgb_panel_main.c

+2
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,6 @@ void app_main(void)
173173
// Release the mutex
174174
example_lvgl_unlock();
175175
}
176+
177+
ESP_LOGI(TAG, "LVGL Scatter Chart displayed");
176178
}

Diff for: esp_lcd_qemu_rgb/examples/lcd_qemu_rgb_panel/main/lvgl_demo_ui.c

+4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ static void draw_event_cb(lv_event_t *e)
3434
}
3535
}
3636

37+
#ifndef CONFIG_EXAMPLE_QEMU_RGB_PANEL_STATIC
3738
static void add_data(lv_timer_t *timer)
3839
{
3940
lv_obj_t *chart = timer->user_data;
4041
lv_chart_set_next_value2(chart, lv_chart_get_series_next(chart, NULL), lv_rand(0, 200), lv_rand(0, 1000));
4142
}
43+
#endif //CONFIG_EXAMPLE_QEMU_RGB_PANEL_STATIC
4244

4345
void example_lvgl_demo_ui(lv_disp_t *disp)
4446
{
@@ -64,5 +66,7 @@ void example_lvgl_demo_ui(lv_disp_t *disp)
6466
lv_chart_set_next_value2(chart, ser, lv_rand(0, 200), lv_rand(0, 1000));
6567
}
6668

69+
#ifndef CONFIG_EXAMPLE_QEMU_RGB_PANEL_STATIC
6770
lv_timer_create(add_data, 100, chart);
71+
#endif
6872
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-License-Identifier: Unlicense OR CC0-1.0
3+
4+
import pytest
5+
import os
6+
from pytest_embedded import Dut
7+
import time
8+
try:
9+
from PIL import Image
10+
from PIL import ImageChops
11+
except ImportError:
12+
Image = None
13+
14+
@pytest.mark.qemu
15+
@pytest.mark.parametrize('qemu_extra_args', ['-display sdl'])
16+
@pytest.mark.parametrize('embedded_services', ['idf,qemu'])
17+
def test_qemu_rgb_panel(dut: Dut) -> None:
18+
if not Image:
19+
pytest.fail('Pillow is not installed')
20+
21+
dut.expect_exact('Install RGB LCD panel driver')
22+
dut.expect_exact('LVGL Scatter Chart displayed')
23+
time.sleep(2)
24+
filename = 'scatter_chart.ppm'
25+
dut.qemu.take_screenshot(filename)
26+
27+
img = Image.open(filename)
28+
ref_img = Image.open(os.path.join(os.path.dirname(__file__), 'doc', 'scatter_chart.png'))
29+
30+
diff = ImageChops.difference(img, ref_img)
31+
assert not diff.getbbox(), 'Images are different'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_EXAMPLE_QEMU_RGB_PANEL_STATIC=y

Diff for: pytest.ini

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ markers =
1313
generic: generic runner
1414
ethernet: ethernet runners
1515
spi_nand_flash: runner with SPI NAND flash connected
16+
qemu: test runs in QEMU emulator
1617

1718
# log related
1819
log_cli = True

0 commit comments

Comments
 (0)