diff --git a/scripts/install-prerequisites.sh b/scripts/install-prerequisites.sh index 8cadebb739..5392834355 100755 --- a/scripts/install-prerequisites.sh +++ b/scripts/install-prerequisites.sh @@ -5,15 +5,11 @@ # here, such as MicroPython and PC simulator packages. # # Note: This script is run by the CI workflows. +SCRIPT_PATH=$(readlink -f $0) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) + sudo dpkg --add-architecture i386 sudo apt update -sudo apt install gcc gcc-multilib g++-multilib ninja-build \ - libpng-dev libjpeg-turbo8-dev libfreetype6-dev \ - libglew-dev libglfw3-dev libsdl2-dev \ - libpng-dev:i386 libjpeg-dev:i386 libfreetype6-dev:i386 \ - ruby-full gcovr cmake python3 libinput-dev libxkbcommon-dev \ - libdrm-dev pkg-config wayland-protocols libwayland-dev libwayland-bin \ - libwayland-dev:i386 libxkbcommon-dev:i386 libudev-dev \ - libavformat-dev libavcodec-dev libswscale-dev libavutil-dev \ - libavformat-dev:i386 libavcodec-dev:i386 libswscale-dev:i386 libavutil-dev:i386 -pip3 install pypng lz4 kconfiglib + +cat $SCRIPT_DIR/prerequisites-apt.txt | xargs sudo apt install -y +pip3 install --user -r $SCRIPT_DIR/prerequisites-pip.txt diff --git a/scripts/prerequisites-apt.txt b/scripts/prerequisites-apt.txt new file mode 100644 index 0000000000..d1d6a1e553 --- /dev/null +++ b/scripts/prerequisites-apt.txt @@ -0,0 +1,37 @@ +git +gcc +gcc-multilib +g++-multilib +ninja-build +libpng-dev +libjpeg-turbo8-dev +libfreetype6-dev +libglew-dev +libglfw3-dev +libsdl2-dev +libpng-dev:i386 +libjpeg-dev:i386 +libfreetype6-dev:i386 +ruby-full +gcovr +cmake +python3 +python3-pip +libinput-dev +libxkbcommon-dev +libdrm-dev +pkg-config +wayland-protocols +libwayland-dev +libwayland-bin +libwayland-dev:i386 +libxkbcommon-dev:i386 +libudev-dev +libavformat-dev +libavcodec-dev +libswscale-dev +libavutil-dev +libavformat-dev:i386 +libavcodec-dev:i386 +libswscale-dev:i386 +libavutil-dev:i386 diff --git a/scripts/prerequisites-pip.txt b/scripts/prerequisites-pip.txt new file mode 100644 index 0000000000..86c683f0d8 --- /dev/null +++ b/scripts/prerequisites-pip.txt @@ -0,0 +1,3 @@ +pypng +lz4 +kconfiglib diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 0000000000..918127affa --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:24.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN dpkg --add-architecture i386 +RUN apt update + +COPY ./scripts/prerequisites-apt.txt . +COPY ./scripts/prerequisites-pip.txt . + +RUN cat prerequisites-apt.txt | xargs apt install -y + +RUN pip install --break-system-packages -r prerequisites-pip.txt + +RUN git clone https://github.com/kornelski/pngquant && \ + cd pngquant && \ + git checkout 2.17.0 && \ + ./configure && \ + make -j$(nproc) && \ + make install +RUN rm -rf pngquant + + +WORKDIR /work diff --git a/tests/README.md b/tests/README.md index b0d946b823..3a32faba4f 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,21 +4,20 @@ The tests in the folder can be run locally and automatically by GitHub CI. ## Running locally -### Requirements (Linux) +### Local -Install requirements by: +1. Install requirements by: ```sh scripts/install-prerequisites.sh ``` -### Run test -1. Run all executable tests with `./tests/main.py test`. -2. Build all build-only tests with `./tests/main.py build`. -3. Clean prior test build, build all build-only tests, +2. Run all executable tests with `./tests/main.py test`. +3. Build all build-only tests with `./tests/main.py build`. +4. Clean prior test build, build all build-only tests, run executable tests, and generate code coverage report `./tests/main.py --clean --report build test`. -4. You can re-generate the test images by adding option `--update-image`. +5. You can re-generate the test images by adding option `--update-image`. It relies on scripts/LVGLImage.py, which requires pngquant and pypng. You can run below command firstly and follow instructions in logs to install them. `./tests/main.py --update-image test` @@ -27,6 +26,24 @@ scripts/install-prerequisites.sh For full information on running tests run: `./tests/main.py --help`. +### Docker + +To run the tests in an environment matching the CI setup: + +1. Build it + +```bash +docker build . -f tests/Dockerfile -t lvgl_test_env +``` + +2. Run the tests + +```bash +docker run --rm -it -v $(pwd):/work lvgl_test_env "./tests/main.py" +``` + +This ensures you are testing in a consistent environment with the same dependencies as the CI pipeline. + ## Running automatically GitHub's CI automatically runs these tests on pushes and pull requests to `master` and `releasev8.*` branches.