From 2baf1489873636f39307033e76e3cc60793e6873 Mon Sep 17 00:00:00 2001 From: mbalous <10358985+mbalous@users.noreply.github.com> Date: Thu, 3 Dec 2026 00:33:12 +0100 Subject: [PATCH 1/3] ci: add ARM compilation and parallel host tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 90 ++++++++++- .gitignore | 2 + CONTRIBUTING.md | 7 +- Makefile | 287 +--------------------------------- requirements-dev.txt | 3 +- requirements-style.txt | 2 + tests/host.mk | 210 +++++++++++++++++++++++++ tests/test_gps_wire_oracle.py | 2 +- tests/test_update_release.py | 4 +- 9 files changed, 314 insertions(+), 293 deletions(-) create mode 100644 requirements-style.txt create mode 100644 tests/host.mk diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f674959..4c7adcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,4 @@ -# Checks that need no copy of the car's system: style, repository content, PC tests. -# The ARM build links against the car's libraries (BMW files), so it runs on a developer's machine, not here. +# CI needs no copy of the car's system. The full ARM link and QEMU checks still run outside CI. name: CI on: @@ -20,37 +19,112 @@ jobs: runs-on: ubuntu-24.04 container: debian:12 timeout-minutes: 20 + env: + CCACHE_MAXSIZE: 150M + HOST_CACHE: ccache steps: - name: Install the tools run: | apt-get update - apt-get install -y --no-install-recommends ca-certificates dbus g++ gcc git libdbus-1-dev libssl-dev make \ + apt-get install -y --no-install-recommends ca-certificates ccache dbus g++ gcc git libdbus-1-dev libssl-dev make \ pkg-config protobuf-compiler python3 python3-protobuf python3-venv shellcheck - python3 -m venv /opt/style - /opt/style/bin/pip install --quiet clang-format==18.1.8 ruff==0.6.9 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 # verify_repo.py reads every commit + - name: Install style tools + run: | + python3 -m venv /opt/style + /opt/style/bin/pip install --quiet -r requirements-style.txt - name: Style run: make style STYLE_TOOLS=/opt/style/bin RUFF=/opt/style/bin/ruff - name: Content run: | git config --global --add safe.directory "$PWD" make verify_core verify_repo + - name: Restore host compiler cache + id: host-cache + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: .ccache + key: ccache-debian12-${{ runner.arch }}-normal-${{ hashFiles('Makefile', 'tests/host.mk') }}-${{ github.sha }} + restore-keys: ccache-debian12-${{ runner.arch }}-normal-${{ hashFiles('Makefile', 'tests/host.mk') }}- - name: PC tests - run: make test-host HOST_CXX=g++ + id: host-tests + run: | + export CCACHE_DIR="$PWD/.ccache" + ccache --zero-stats + make -j"$(nproc)" --output-sync=target test-host + - name: Host compiler cache statistics + if: always() && steps.host-tests.outcome != 'skipped' + run: CCACHE_DIR="$PWD/.ccache" ccache --show-stats + - name: Save host compiler cache + if: github.event_name == 'push' && steps.host-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: .ccache + key: ${{ steps.host-cache.outputs.cache-primary-key }} sanitizers: name: PC sanitizers (ASan, UBSan, leaks) runs-on: ubuntu-24.04 container: debian:12 timeout-minutes: 15 + env: + CCACHE_MAXSIZE: 150M + HOST_CACHE: ccache steps: - name: Install the tools run: | apt-get update - apt-get install -y --no-install-recommends ca-certificates g++ git libssl-dev make + apt-get install -y --no-install-recommends ca-certificates ccache g++ git libssl-dev make - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Restore sanitizer compiler cache + id: sanitizer-cache + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: .ccache + key: ccache-debian12-${{ runner.arch }}-sanitized-${{ hashFiles('Makefile', 'tests/host.mk') }}-${{ github.sha }} + restore-keys: ccache-debian12-${{ runner.arch }}-sanitized-${{ hashFiles('Makefile', 'tests/host.mk') }}- - name: PC tests with ASan, UBSan and LSan - run: make -j2 test-host-sanitizers + id: sanitizer-tests + run: | + export CCACHE_DIR="$PWD/.ccache" + ccache --zero-stats + make -j"$(nproc)" --output-sync=target test-host-sanitizers + - name: Sanitizer compiler cache statistics + if: always() && steps.sanitizer-tests.outcome != 'skipped' + run: CCACHE_DIR="$PWD/.ccache" ccache --show-stats + - name: Save sanitizer compiler cache + if: github.event_name == 'push' && steps.sanitizer-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: .ccache + key: ${{ steps.sanitizer-cache.outputs.cache-primary-key }} + + arm-compile: + name: ARM compile (GCC 4.7) + runs-on: ubuntu-24.04 + timeout-minutes: 15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Build the public ARM toolchain + run: | + # Quantal's official image is still schema v1, which current Docker cannot pull. + sudo apt-get update + sudo apt-get install -y --no-install-recommends skopeo + skopeo copy --format v2s2 \ + docker://docker.io/library/ubuntu@sha256:002fba3e3255af10be97ea26e476692a7ebed0bb074a9ab960b2e7a1526b15d7 \ + "docker-archive:$RUNNER_TEMP/ubuntu-quantal.tar:ubuntu:12.10" + docker load -i "$RUNNER_TEMP/ubuntu-quantal.tar" + DOCKER_BUILDKIT=0 docker build -t entrynav2-tc:4.7 toolchain + - name: Compile ARM objects without the car sysroot + run: | + docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" entrynav2-tc:4.7 sh -ec ' + test ! -e /sysroot + test "$(arm-linux-gnueabihf-g++ -dumpversion)" = 4.7.2 + make -j"$(getconf _NPROCESSORS_ONLN)" compile-arm + arm-linux-gnueabihf-objdump -f platform/main.o tools/aa_supervisor.o hmiapp/entry_aa_app.o + ' diff --git a/.gitignore b/.gitignore index 1ed33c1..3514549 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ !/platform/ !/pyproject.toml !/requirements-dev.txt +!/requirements-style.txt !/tests/ !/toolchain/ !/tools/ @@ -40,6 +41,7 @@ __pycache__/ !/tests/*.c !/tests/*.cpp !/tests/*.hpp +!/tests/host.mk !/tests/*.py !/tests/fixtures/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 013b1a8..f1a341a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,12 +60,17 @@ fermeture. | Niveau | Commande | Il faut | |---|---|---| | PC, comme la CI | `make check` | `g++`, `libssl-dev`, `libdbus-1-dev`, `protobuf-compiler`, `python3-protobuf`, clang-format 18.1.8 et ruff 0.6.9 (`pip install -r requirements-dev.txt`) | -| PC, mémoire et UB | `make test-host-sanitizers` | `g++` avec ASan/UBSan, `libssl-dev` ; tests des trames et de la session, détection des fuites active | +| PC, mémoire et UB | `make test-host-sanitizers` | `g++` avec ASan/UBSan, `libssl-dev` ; détection des fuites active | +| ARM, compilation seule (CI) | `make compile-arm` dans l'image `entrynav2-tc:4.7` | Docker et les en-têtes publics de l'image, sans copie du système de la voiture | | ARM | `bash toolchain/tc.sh make -j4 all hmiapp test-arm-all` | Docker, la copie du système de la voiture | | ARM sous QEMU | `python3 -I tests/run_qemu.py` | `qemu-user`, la copie du système | | Programmes validés | `make verify_binary verify_wireless` | idem | | Procédure d'installation | les commandes de [docs/INSTALLATION.md](docs/INSTALLATION.md), avec la BusyBox de la voiture sous QEMU | idem | +Les tests PC acceptent `make -jN`. Leurs binaires sont séparés dans `tests/build-host/normal/` et +`tests/build-host/sanitized/`. `HOST_CACHE=ccache` est facultatif en local. La vérification ARM de la CI compile +les objets avec GCC 4.7, mais ne remplace ni l'édition de liens avec les bibliothèques de la voiture ni QEMU. + ## Style | Langage | Règles | Outil | diff --git a/Makefile b/Makefile index a247503..55baf9d 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ # bash toolchain/tc.sh make # # all what the car runs: entry-aad, aa-supervisor and hmiapp/libEntryAad.so (ARM) +# compile-arm production and diagnostic objects, no linking or car sysroot (ARM) # dev-tools evo-check and evo-capture, read-only diagnostics run by hand on the car (ARM, not installed) # test-arm-all every ARM program tests/run_qemu.py runs (ARM) # test-host the tests that run on the PC itself (host compiler, libdbus-1-dev, dbus, protoc, python3-protobuf) @@ -62,13 +63,11 @@ LIFECYCLE_OBJ = $(PLATFORM_OBJ) platform/evo_touch.o platform/evo_knob.o platfor VIDEO_LIBS = -l:libxsvideo.so.4 -l:libdrm_omap.so.1 -l:libdrm.so.2 -lpthread -lrt -.PHONY: all daemon hmiapp dev-tools check style clean verify_core verify_binary verify_wireless verify_repo \ - test-host-sanitizers test-unit-sanitizers test-frame-host test-session-host test-kombi-core-host \ - test-host test-parsers test-spp-host test-kombi-host test-gps-host test-capture-host test-touch-live \ - tests/evo-check-host test-arm-all test-pb-arm-build test-sdr-arm-build test-kombi-arm-build \ +.PHONY: all compile-arm daemon hmiapp dev-tools check style clean verify_core verify_binary verify_wireless verify_repo \ + test-arm-all test-pb-arm-build test-sdr-arm-build test-kombi-arm-build \ test-session-silence-arm-build test-presentation-arm-build test-wireless-lifecycle-arm-build \ test-gps-arm-build test-supervisor-arm-build test-hmiapp-arm-build test-spawn-arm-build test-lm-cli-arm-build \ - test-phone-arm-build test-usb-host test-usb-arm-build test-wifi-arm-build test-update-arm-build + test-phone-arm-build test-usb-arm-build test-wifi-arm-build test-update-arm-build all: daemon aa-supervisor hmiapp %.o: %.cpp @@ -94,6 +93,8 @@ HMI_SRC = hmiapp/entry_aa_app.cpp hmiapp/bmw_framework.cpp hmiapp/app_log.cpp hm hmiapp/idrive_touch.cpp HMI_OBJ = $(HMI_SRC:.cpp=.o) HMI_LIBDIRS = -L$(SYSROOT)/opt/hmi/lib -Wl,-rpath-link,$(SYSROOT)/opt/hmi/lib +compile-arm: $(ARM_OBJ) $(HMI_OBJ) + hmiapp: hmiapp/libEntryAad.so $(HMI_OBJ): hmiapp/%.o: hmiapp/%.cpp $(CXX) $(CXXFLAGS) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MMD -MP -c $< -o $@ @@ -130,280 +131,7 @@ style: $(SHELLCHECK) -S style toolchain/tc.sh check: style verify_core verify_repo test-host -# ---- tests on the PC ------------------------------------------------------------------------------------------------ -HOST_CXX ?= g++ -HOST_FLAGS = -std=c++11 -O1 -g -Wall -Wextra -Werror -Iplatform -Icore -pthread -HOST_DBUS = $(shell pkg-config --cflags --libs dbus-1) -# The session as the fake-phone test links it; the car's TLS 1.2 client method is deprecated in the PC's OpenSSL 3. -SESSION_SRC = $(filter-out core/wireless_setup.cpp core/tcp_server.cpp,$(CORE_SRC)) -HOST_SSL_FLAGS = -Wno-deprecated-declarations -# The update from a USB stick without its car side (update_car.cpp): what its tests link around a fake car. -UPDATE_SRC = platform/update_install.cpp platform/update_package.cpp platform/log_copy.cpp -# A BMW library read by one test: only on a PC holding a copy of the car system, never in git. -SPP_FIXTURE_LIB = $(HOME)/entrynav2/rootfs/opt/app/usr/BTMedia/evolution/stack/lib/libevo_btappl.so - -# evo-check built for the PC: two tests drive it. Phony, so built once per make run, always from the current sources. -tests/evo-check-host: - $(HOST_CXX) $(HOST_FLAGS) tools/evo_check.cpp platform/alps_spp.cpp platform/alps_spp_codec.cpp \ - platform/evo_process.cpp $(HOST_DBUS) -o $@ - -test-host: test-parsers test-spp-host test-kombi-host test-gps-host test-capture-host test-usb-host \ - tests/evo-check-host test-media-host test-frame-host test-session-host - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_elf.cpp -o tests/test-evo-elf - if [ -f "$(SPP_FIXTURE_LIB)" ]; then ENTRY_AAD_FIXTURE_LIB="$(SPP_FIXTURE_LIB)" ./tests/test-evo-elf; else ./tests/test-evo-elf; fi - $(HOST_CXX) $(HOST_FLAGS) tests/test_spp_snapshot.cpp platform/evo_spp_snapshot.cpp -o tests/test-spp-snapshot - if [ -f "$(SPP_FIXTURE_LIB)" ]; then ENTRY_AAD_FIXTURE_LIB="$(SPP_FIXTURE_LIB)" ./tests/test-spp-snapshot; else echo "SKIP test-spp-snapshot: no copy of the car system"; fi - $(HOST_CXX) $(HOST_FLAGS) -DENTRY_AAD_VERSION='"test"' tests/test_supervisor.cpp platform/alps_spp_codec.cpp platform/usb_accessory.cpp \ - platform/log_copy.cpp -o tests/test-supervisor - ./tests/test-supervisor - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_ilm.cpp platform/evo_ilm.cpp platform/evo_process.cpp -o tests/test-evo-ilm - ENTRY_AAD_DIAGNOSTIC=./tests/evo-check-host ./tests/test-evo-ilm - $(HOST_CXX) $(HOST_FLAGS) tests/test_video_presentation.cpp platform/evo_video.cpp -o tests/test-video-presentation - ./tests/test-video-presentation - gcc -std=c99 -Wall -Wextra -Werror -shared -fPIC tests/fake_vmostclient.c -o tests/fake-vmostclient.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_input.cpp platform/evo_touch.cpp platform/evo_knob.cpp platform/vmost_client.cpp \ - -ldl -o tests/test-evo-input - ./tests/test-evo-input $(CURDIR)/tests/fake-vmostclient.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_control.cpp platform/evo_control.cpp -o tests/test-evo-control - ./tests/test-evo-control - $(HOST_CXX) $(HOST_FLAGS) tests/test_peek_timing.cpp platform/peek_timing.cpp -o tests/test-peek-timing - ./tests/test-peek-timing - $(HOST_CXX) $(HOST_FLAGS) tests/test_volume_state.cpp -o tests/test-volume-state - ./tests/test-volume-state - $(HOST_CXX) $(HOST_FLAGS) -Icore/include tests/test_sdr_g20.cpp core/sdr_builder.cpp platform/evo_sdr_sensors.cpp -o tests/test-sdr-g20 - ./tests/test-sdr-g20 - $(HOST_CXX) $(HOST_FLAGS) -Icore/include tests/test_evo_sdr.cpp core/sdr_builder.cpp platform/evo_sdr_sensors.cpp -o tests/test-evo-sdr - ./tests/test-evo-sdr - gcc -std=c99 -Wall -Wextra -Werror -shared -fPIC -DFAKE_VMOST_NO_CONNECTED tests/fake_vmostclient.c \ - -o tests/fake-vmostclient-nosym.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_wlan.cpp platform/evo_wlan.cpp platform/vmost_client.cpp -ldl -o tests/test-evo-wlan - ./tests/test-evo-wlan $(CURDIR)/tests/fake-vmostclient.so $(CURDIR)/tests/fake-vmostclient-nosym.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_reboot.cpp platform/evo_reboot.cpp platform/vmost_client.cpp -ldl \ - -o tests/test-evo-reboot - ./tests/test-evo-reboot $(CURDIR)/tests/fake-vmostclient.so - gcc -std=c99 -Wall -Wextra -Werror -shared -fPIC -Wl,-soname,libasound.so.2 tests/fake_libasound.c -pthread \ - -o tests/fake-libasound.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_mic.cpp platform/evo_mic.cpp -ldl -o tests/test-evo-mic - ./tests/test-evo-mic $(CURDIR)/tests/fake-libasound.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_spawn_attr.cpp -o tests/test-spawn-attr - ./tests/test-spawn-attr - $(HOST_CXX) $(HOST_FLAGS) tests/test_popup_peek.cpp -o tests/test-popup-peek - ./tests/test-popup-peek - $(HOST_CXX) $(HOST_FLAGS) tests/test_hold_machine.cpp hmiapp/hold_machine.cpp -o tests/test-hold-machine - ./tests/test-hold-machine - $(HOST_CXX) $(HOST_FLAGS) tests/test_child_reaper.cpp -o tests/test-child-reaper - ./tests/test-child-reaper - $(HOST_CXX) $(HOST_FLAGS) tests/test_idrive_touch.cpp hmiapp/idrive_touch.cpp -o tests/test-idrive-touch - ./tests/test-idrive-touch - $(HOST_CXX) $(HOST_FLAGS) tests/test_vtable_check.cpp -o tests/test-vtable-check - ./tests/test-vtable-check - $(HOST_CXX) $(HOST_FLAGS) tests/test_posted_task.cpp -o tests/test-posted-task - ./tests/test-posted-task - python3 tests/test_idrive_lookups.py - $(HOST_CXX) $(HOST_FLAGS) tests/test_pending_restart.cpp -o tests/test-pending-restart - ./tests/test-pending-restart - $(HOST_CXX) $(HOST_FLAGS) tests/test_guard_file.cpp -o tests/test-guard-file - ./tests/test-guard-file - $(HOST_CXX) $(HOST_FLAGS) tests/test_phone_audio_recall.cpp -o tests/test-phone-audio-recall - ./tests/test-phone-audio-recall - $(HOST_CXX) $(HOST_FLAGS) tests/test_log_profile.cpp -o tests/test-log-profile - ./tests/test-log-profile - $(HOST_CXX) $(HOST_FLAGS) tests/test_kept_log.cpp -o tests/test-kept-log - ./tests/test-kept-log - $(HOST_CXX) $(HOST_FLAGS) tests/test_log_copy.cpp platform/log_copy.cpp -o tests/test-log-copy - ./tests/test-log-copy - $(HOST_CXX) $(HOST_FLAGS) $(HOST_SSL_FLAGS) tests/test_update_package.cpp platform/update_package.cpp -lcrypto \ - -o tests/test-update-package - ./tests/test-update-package - python3 tests/test_update_release.py tests/test-update-package - python3 tests/test_docs.py - $(HOST_CXX) $(HOST_FLAGS) $(HOST_SSL_FLAGS) tests/test_update_install.cpp $(UPDATE_SRC) -lcrypto \ - -o tests/test-update-install - ./tests/test-update-install - $(HOST_CXX) $(HOST_FLAGS) tests/test_update_flow.cpp -o tests/test-update-flow - ./tests/test-update-flow - $(HOST_CXX) $(HOST_FLAGS) tests/test_pb.cpp -o tests/test-pb - ./tests/test-pb - $(HOST_CXX) $(HOST_FLAGS) tests/test_volume_pill.cpp -o tests/test-volume-pill - ./tests/test-volume-pill - $(HOST_CXX) $(HOST_FLAGS) tests/test_aa_messages.cpp core/aa_messages.cpp -o tests/test-aa-messages - ./tests/test-aa-messages - $(HOST_CXX) $(HOST_FLAGS) tests/test_tcp_server.cpp core/tcp_server.cpp -o tests/test-tcp-server - ./tests/test-tcp-server - $(HOST_CXX) $(HOST_FLAGS) tests/test_no_inherit.cpp core/tcp_server.cpp core/car_inbox.cpp $(KOMBI_SRC) \ - -o tests/test-no-inherit - ./tests/test-no-inherit - $(HOST_CXX) $(HOST_FLAGS) tests/test_wifi_link.cpp platform/wifi_link.cpp -o tests/test-wifi-link - ./tests/test-wifi-link - $(HOST_CXX) $(HOST_FLAGS) tests/test_wireless_phone.cpp core/wireless_setup.cpp -o tests/test-wireless-phone - ./tests/test-wireless-phone tests/fixtures/wireless_phone.golden - $(HOST_CXX) $(HOST_FLAGS) tests/test_wireless_listen.cpp core/wireless_setup.cpp -o tests/test-wireless-listen - ./tests/test-wireless-listen - $(HOST_CXX) $(HOST_FLAGS) tests/test_crash_handler.cpp core/crash_handler.cpp -o tests/test-crash-handler - ./tests/test-crash-handler - $(HOST_CXX) $(HOST_FLAGS) tests/test_fd_hygiene.cpp platform/evo_process.cpp -o tests/test-fd-hygiene - ./tests/test-fd-hygiene - $(HOST_CXX) $(HOST_FLAGS) tests/test_security_fs.cpp -o tests/test-security-fs - ./tests/test-security-fs - -# GCC's ASan can loop on DEADLYSIGNAL under a kernel that randomizes mmap over 32 bits (WSL): the sanitizer run -# goes without address randomization where the machine allows it (Docker's seccomp refuses it: nothing changes). -NORAND := $(shell setarch $$(uname -m) -R true 2>/dev/null && echo setarch $$(uname -m) -R) -test-host-sanitizers: - ASAN_OPTIONS=detect_leaks=1:allow_user_segv_handler=1 $(NORAND) $(MAKE) test-frame-host test-session-host test-parsers \ - test-usb-host test-capture-host test-media-host test-kombi-core-host test-unit-sanitizers \ - HOST_FLAGS="$(HOST_FLAGS) -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" - -test-unit-sanitizers: - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_elf.cpp -o tests/test-evo-elf - ./tests/test-evo-elf - gcc -std=c99 -Wall -Wextra -Werror -shared -fPIC tests/fake_vmostclient.c -o tests/fake-vmostclient.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_input.cpp platform/evo_touch.cpp platform/evo_knob.cpp \ - platform/vmost_client.cpp -ldl -o tests/test-evo-input - ./tests/test-evo-input $(CURDIR)/tests/fake-vmostclient.so - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_control.cpp platform/evo_control.cpp -o tests/test-evo-control - ./tests/test-evo-control - $(HOST_CXX) $(HOST_FLAGS) tests/test_peek_timing.cpp platform/peek_timing.cpp -o tests/test-peek-timing - ./tests/test-peek-timing - $(HOST_CXX) $(HOST_FLAGS) tests/test_volume_state.cpp -o tests/test-volume-state - ./tests/test-volume-state - $(HOST_CXX) $(HOST_FLAGS) tests/test_volume_pill.cpp -o tests/test-volume-pill - ./tests/test-volume-pill - $(HOST_CXX) $(HOST_FLAGS) -Icore/include tests/test_sdr_g20.cpp core/sdr_builder.cpp platform/evo_sdr_sensors.cpp \ - -o tests/test-sdr-g20 - ./tests/test-sdr-g20 - $(HOST_CXX) $(HOST_FLAGS) -Icore/include tests/test_evo_sdr.cpp core/sdr_builder.cpp platform/evo_sdr_sensors.cpp \ - -o tests/test-evo-sdr - ./tests/test-evo-sdr - $(HOST_CXX) $(HOST_FLAGS) tests/test_spawn_attr.cpp -o tests/test-spawn-attr - ./tests/test-spawn-attr - $(HOST_CXX) $(HOST_FLAGS) tests/test_popup_peek.cpp -o tests/test-popup-peek - ./tests/test-popup-peek - $(HOST_CXX) $(HOST_FLAGS) tests/test_hold_machine.cpp hmiapp/hold_machine.cpp -o tests/test-hold-machine - ./tests/test-hold-machine - $(HOST_CXX) $(HOST_FLAGS) tests/test_child_reaper.cpp -o tests/test-child-reaper - ./tests/test-child-reaper - $(HOST_CXX) $(HOST_FLAGS) tests/test_idrive_touch.cpp hmiapp/idrive_touch.cpp -o tests/test-idrive-touch - ./tests/test-idrive-touch - $(HOST_CXX) $(HOST_FLAGS) tests/test_vtable_check.cpp -o tests/test-vtable-check - ./tests/test-vtable-check - $(HOST_CXX) $(HOST_FLAGS) tests/test_pending_restart.cpp -o tests/test-pending-restart - ./tests/test-pending-restart - $(HOST_CXX) $(HOST_FLAGS) tests/test_guard_file.cpp -o tests/test-guard-file - ./tests/test-guard-file - $(HOST_CXX) $(HOST_FLAGS) tests/test_phone_audio_recall.cpp -o tests/test-phone-audio-recall - ./tests/test-phone-audio-recall - $(HOST_CXX) $(HOST_FLAGS) tests/test_log_profile.cpp -o tests/test-log-profile - ./tests/test-log-profile - $(HOST_CXX) $(HOST_FLAGS) tests/test_kept_log.cpp -o tests/test-kept-log - ./tests/test-kept-log - $(HOST_CXX) $(HOST_FLAGS) tests/test_log_copy.cpp platform/log_copy.cpp -o tests/test-log-copy - ./tests/test-log-copy - $(HOST_CXX) $(HOST_FLAGS) $(HOST_SSL_FLAGS) tests/test_update_package.cpp platform/update_package.cpp -lcrypto \ - -o tests/test-update-package - ./tests/test-update-package - $(HOST_CXX) $(HOST_FLAGS) $(HOST_SSL_FLAGS) tests/test_update_install.cpp $(UPDATE_SRC) -lcrypto \ - -o tests/test-update-install - ./tests/test-update-install - $(HOST_CXX) $(HOST_FLAGS) tests/test_update_flow.cpp -o tests/test-update-flow - ./tests/test-update-flow - $(HOST_CXX) $(HOST_FLAGS) tests/test_pb.cpp -o tests/test-pb - ./tests/test-pb - $(HOST_CXX) $(HOST_FLAGS) tests/test_aa_messages.cpp core/aa_messages.cpp -o tests/test-aa-messages - ./tests/test-aa-messages - $(HOST_CXX) $(HOST_FLAGS) tests/test_tcp_server.cpp core/tcp_server.cpp -o tests/test-tcp-server - ./tests/test-tcp-server - $(HOST_CXX) $(HOST_FLAGS) tests/test_wifi_link.cpp platform/wifi_link.cpp -o tests/test-wifi-link - ./tests/test-wifi-link - $(HOST_CXX) $(HOST_FLAGS) tests/test_wireless_phone.cpp core/wireless_setup.cpp -o tests/test-wireless-phone - ./tests/test-wireless-phone tests/fixtures/wireless_phone.golden - $(HOST_CXX) $(HOST_FLAGS) tests/test_wireless_listen.cpp core/wireless_setup.cpp -o tests/test-wireless-listen - ./tests/test-wireless-listen - $(HOST_CXX) $(HOST_FLAGS) tests/test_crash_handler.cpp core/crash_handler.cpp -o tests/test-crash-handler - ./tests/test-crash-handler - $(HOST_CXX) $(HOST_FLAGS) tests/test_fd_hygiene.cpp platform/evo_process.cpp -o tests/test-fd-hygiene - ./tests/test-fd-hygiene - $(HOST_CXX) $(HOST_FLAGS) tests/test_security_fs.cpp -o tests/test-security-fs - ./tests/test-security-fs - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_gps.cpp -o tests/test-evo-gps - ./tests/test-evo-gps - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_reboot.cpp platform/evo_reboot.cpp platform/vmost_client.cpp -ldl \ - -o tests/test-evo-reboot - ./tests/test-evo-reboot $(CURDIR)/tests/fake-vmostclient.so - -test-frame-host: - $(HOST_CXX) $(HOST_FLAGS) tests/test_aa_frame.cpp core/aa_frame.cpp -o tests/test-aa-frame - ./tests/test-aa-frame - -test-session-host: - $(HOST_CXX) $(HOST_FLAGS) $(HOST_SSL_FLAGS) -Icore/include tests/test_session_phone.cpp $(SESSION_SRC) -lssl -lcrypto \ - -o tests/test-session-phone - ./tests/test-session-phone tests/fixtures/session_phone.golden - -test-parsers: - $(HOST_CXX) $(HOST_FLAGS) tests/test_parsers.cpp platform/alps_spp_codec.cpp platform/evo_ap_config.cpp -o tests/test-parsers - ./tests/test-parsers - -test-spp-host: tests/evo-check-host - $(HOST_CXX) $(HOST_FLAGS) tests/test_alps_spp.cpp platform/alps_spp.cpp platform/alps_spp_codec.cpp platform/evo_process.cpp $(HOST_DBUS) -o tests/test-alps-spp - env -u XDG_RUNTIME_DIR dbus-run-session -- sh -c 'DBUS_SYSTEM_BUS_ADDRESS="$$DBUS_SESSION_BUS_ADDRESS" ENTRY_AAD_TEST_BUS=1 ENTRY_AAD_DIAGNOSTIC=./tests/evo-check-host ./tests/test-alps-spp' - -.PHONY: test-media-host test-media-arm-build -test-media-host: - $(HOST_CXX) $(HOST_FLAGS) tests/test_media_recall.cpp platform/evo_knob.cpp platform/vmost_client.cpp -ldl -o tests/test-media-recall - ./tests/test-media-recall - -test-media-arm-build: - $(CXX) $(CXXFLAGS) $(CPPFLAGS) tests/test_media_recall.cpp platform/evo_knob.cpp platform/vmost_client.cpp \ - -o tests/test-media-recall-arm $(LDSHLIB) -lpthread -ldl -lrt - -test-kombi-core-host: - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_phone.cpp platform/kombi_phone.cpp -o tests/test-kombi-phone - ./tests/test-kombi-phone - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_display.cpp platform/kombi_display.cpp platform/kombi_phone.cpp \ - -o tests/test-kombi-display - ./tests/test-kombi-display - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_graph.cpp platform/kombi_graph.cpp platform/kombi_someip.cpp \ - -o tests/test-kombi-graph - ./tests/test-kombi-graph - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_guide.cpp $(KOMBI_SRC) -o tests/test-kombi-guide - ./tests/test-kombi-guide - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_client.cpp $(KOMBI_SRC) -o tests/test-kombi-client - ./tests/test-kombi-client - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_nav.cpp $(KOMBI_SRC) -o tests/test-kombi-nav - ./tests/test-kombi-nav - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_golden.cpp $(KOMBI_SRC) -o tests/test-kombi-golden - ./tests/test-kombi-golden - $(HOST_CXX) $(HOST_FLAGS) tests/test_kombi_most.cpp $(KOMBI_SRC) -o tests/test-kombi-most - ./tests/test-kombi-most - -test-kombi-host: test-kombi-core-host - $(HOST_CXX) $(HOST_FLAGS) tests/test_bmw_guidance.cpp platform/evo_bmw_guidance.cpp $(HOST_DBUS) -o tests/test-bmw-guidance - env -u XDG_RUNTIME_DIR dbus-run-session -- ./tests/test-bmw-guidance - -# The USB cable: a fake bus (a folder like /sys/bus/usb/devices) and fake phones; no real device is opened. -test-usb-host: - $(HOST_CXX) $(HOST_FLAGS) tests/test_usb_accessory.cpp platform/usb_accessory.cpp -o tests/test-usb-accessory - ./tests/test-usb-accessory - $(HOST_CXX) $(HOST_FLAGS) tests/test_usb_bridge.cpp platform/usb_bridge.cpp core/aa_frame.cpp -o tests/test-usb-bridge - ./tests/test-usb-bridge - $(HOST_CXX) $(HOST_FLAGS) tests/test_usb_loop.cpp platform/usb_loop.cpp platform/usb_bridge.cpp \ - platform/usb_accessory.cpp platform/usb_devfs.cpp core/aa_frame.cpp -o tests/test-usb-loop - ./tests/test-usb-loop - -test-gps-host: - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_gps.cpp -o tests/test-evo-gps - ./tests/test-evo-gps - python3 tests/test_gps_wire_oracle.py - -test-capture-host: - $(HOST_CXX) $(HOST_FLAGS) tools/evo_capture.cpp -o tests/test-evo-capture - ./tests/test-evo-capture --selftest - -# Root only (AF_PACKET): sudo make test-touch-live. Loopback traffic, no other interface touched. -test-touch-live: - $(HOST_CXX) $(HOST_FLAGS) tests/test_evo_touch_live.cpp platform/evo_touch.cpp -o tests/test-evo-touch-live - ./tests/test-evo-touch-live +include tests/host.mk # ---- ARM tests, run on the PC under QEMU with the car's libraries (tests/run_qemu.py) -------------------------------- # test-spawn-attr-arm checks how the app starts the service from HmiMain3D with the HU's own glibc 2.15. @@ -505,5 +233,6 @@ clean: rm -f $(ARM_OBJ) $(ARM_OBJ:.o=.d) $(HMI_OBJ) $(HMI_OBJ:.o=.d) entry-aad aa-supervisor evo-check evo-capture \ hmiapp/libEntryAad.so hmiapp/EntryAad_ALL_Texts.zip hmiapp/EntryAad_ALL_Images.zip \ tests/test-* tests/evo-check-host tests/*.so + rm -rf tests/build-host -include $(ARM_OBJ:.o=.d) $(HMI_OBJ:.o=.d) diff --git a/requirements-dev.txt b/requirements-dev.txt index d76a360..764958e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,5 @@ # Python packages for the checks and the tests: python3 -m pip install -r requirements-dev.txt # Also needed, outside pip: protoc (tests/test_gps_wire_oracle.py), qemu-arm and a copy of the car's system (ARM tests). -clang-format==18.1.8 # tools/format_sources.py -ruff==0.6.9 # tools/format_sources.py, ruff check . +-r requirements-style.txt pyelftools>=0.29 # tools/verify_binary.py, tools/verify_wireless.py protobuf>=4.21 # tests/test_gps_wire_oracle.py diff --git a/requirements-style.txt b/requirements-style.txt new file mode 100644 index 0000000..e0b1b7c --- /dev/null +++ b/requirements-style.txt @@ -0,0 +1,2 @@ +clang-format==18.1.8 # tools/format_sources.py +ruff==0.6.9 # tools/format_sources.py, ruff check . diff --git a/tests/host.mk b/tests/host.mk new file mode 100644 index 0000000..6781ec4 --- /dev/null +++ b/tests/host.mk @@ -0,0 +1,210 @@ +# Copyright (c) 2026 Jiraiya43 +# SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 +# Host checks share objects only within the same mode and compiler flag set. + +HOST_CXX ?= g++ +HOST_CC ?= gcc +HOST_CACHE ?= +HOST_FLAGS = -std=c++11 -O1 -g -Wall -Wextra -Werror -Iplatform -Icore -pthread +HOST_MODE ?= normal +HOST_BUILD := tests/build-host/$(HOST_MODE) +HOST_DBUS_CFLAGS = $(shell pkg-config --cflags dbus-1) +HOST_DBUS_LIBS = $(shell pkg-config --libs dbus-1) + +HOST_CPPFLAGS_dbus = $(HOST_DBUS_CFLAGS) +HOST_CPPFLAGS_core = -Icore/include +# The head unit TLS 1.2 client method is deprecated in the host's OpenSSL 3. +HOST_CPPFLAGS_ssl = -Wno-deprecated-declarations +HOST_CPPFLAGS_session = $(HOST_CPPFLAGS_core) $(HOST_CPPFLAGS_ssl) +HOST_CPPFLAGS_version = -DENTRY_AAD_VERSION='"test"' + +SESSION_SRC = $(filter-out core/wireless_setup.cpp core/tcp_server.cpp,$(CORE_SRC)) +UPDATE_SRC = platform/update_install.cpp platform/update_package.cpp platform/log_copy.cpp +SPP_FIXTURE_LIB = $(HOME)/entrynav2/rootfs/opt/app/usr/BTMedia/evolution/stack/lib/libevo_btappl.so + +.PHONY: host-force test-host test-host-sanitizers test-unit-sanitizers test-frame-host test-session-host \ + test-parsers test-spp-host test-media-host test-kombi-core-host test-kombi-host test-usb-host \ + test-gps-host test-capture-host test-touch-live +host-force: + +host_quote = '$(subst ','"'"',$(1))' +$(HOST_BUILD)/config: host-force + @mkdir -p $(@D) + @printf '%s\n' $(call host_quote,$(HOST_CXX)) $(call host_quote,$(HOST_CC)) \ + $(call host_quote,$(HOST_FLAGS)) > $@.tmp + @cmp -s $@.tmp $@ || cp $@.tmp $@ + @rm -f $@.tmp + +define host-object-rule +$(HOST_BUILD)/obj/$(1)/%.o: %.cpp Makefile tests/host.mk $(HOST_BUILD)/config + @mkdir -p $$(@D) + $$(HOST_CACHE) $$(HOST_CXX) $$(HOST_FLAGS) $$(HOST_CPPFLAGS_$(1)) -MMD -MP -c $$< -o $$@ +endef +$(foreach variant,base dbus core ssl session version,$(eval $(call host-object-rule,$(variant)))) + +host-objects = $(addprefix $(HOST_BUILD)/obj/$(or $(2),base)/,$(1:.cpp=.o)) + +# Arguments: executable, sources, compile flag set, link libraries. +define host-program +HOST_OBJECTS += $(call host-objects,$(2),$(3)) +$(HOST_BUILD)/$(1): $(call host-objects,$(2),$(3)) Makefile tests/host.mk + $$(HOST_CXX) $$(HOST_FLAGS) $$(filter %.o,$$^) $(4) -o $$@ +endef + +# Test and tool source names normally match their executable, with underscores instead of hyphens. +host-test = $(call host-program,test-$(1),tests/test_$(subst -,_,$(1)).cpp $(2),$(3),$(4)) + +$(eval $(call host-program,evo-check-host,tools/evo_check.cpp platform/alps_spp.cpp platform/alps_spp_codec.cpp \ + platform/evo_process.cpp,dbus,$$(HOST_DBUS_LIBS))) +$(eval $(call host-program,test-evo-capture,tools/evo_capture.cpp)) +$(eval $(call host-test,aa-frame,core/aa_frame.cpp)) +$(eval $(call host-test,session-phone,$(SESSION_SRC),session,-lssl -lcrypto)) +$(eval $(call host-test,parsers,platform/alps_spp_codec.cpp platform/evo_ap_config.cpp)) +$(eval $(call host-test,alps-spp,platform/alps_spp.cpp platform/alps_spp_codec.cpp platform/evo_process.cpp,dbus,$$(HOST_DBUS_LIBS))) +$(eval $(call host-test,media-recall,platform/evo_knob.cpp platform/vmost_client.cpp,,-ldl)) +$(eval $(call host-test,kombi-phone,platform/kombi_phone.cpp)) +$(eval $(call host-test,kombi-display,platform/kombi_display.cpp platform/kombi_phone.cpp)) +$(eval $(call host-test,kombi-graph,platform/kombi_graph.cpp platform/kombi_someip.cpp)) +$(foreach test,guide client nav golden most,$(eval $(call host-test,kombi-$(test),$(KOMBI_SRC)))) +$(eval $(call host-test,bmw-guidance,platform/evo_bmw_guidance.cpp,dbus,$$(HOST_DBUS_LIBS))) +$(eval $(call host-test,usb-accessory,platform/usb_accessory.cpp)) +$(eval $(call host-test,usb-bridge,platform/usb_bridge.cpp core/aa_frame.cpp)) +$(eval $(call host-test,usb-loop,platform/usb_loop.cpp platform/usb_bridge.cpp platform/usb_accessory.cpp \ + platform/usb_devfs.cpp core/aa_frame.cpp)) +$(eval $(call host-test,evo-gps)) +$(eval $(call host-test,evo-touch-live,platform/evo_touch.cpp)) + +$(eval $(call host-test,evo-elf)) +$(eval $(call host-test,spp-snapshot,platform/evo_spp_snapshot.cpp)) +$(eval $(call host-test,supervisor,platform/alps_spp_codec.cpp platform/usb_accessory.cpp platform/log_copy.cpp,version)) +$(eval $(call host-test,evo-ilm,platform/evo_ilm.cpp platform/evo_process.cpp)) +$(eval $(call host-test,video-presentation,platform/evo_video.cpp)) +$(eval $(call host-test,evo-input,platform/evo_touch.cpp platform/evo_knob.cpp platform/vmost_client.cpp,,-ldl)) +$(eval $(call host-test,evo-control,platform/evo_control.cpp)) +$(eval $(call host-test,peek-timing,platform/peek_timing.cpp)) +$(eval $(call host-test,volume-state,platform/volume_state.cpp)) +$(eval $(call host-test,sdr-g20,core/sdr_builder.cpp platform/evo_sdr_sensors.cpp,core)) +$(eval $(call host-test,evo-sdr,core/sdr_builder.cpp platform/evo_sdr_sensors.cpp,core)) +$(eval $(call host-test,evo-wlan,platform/evo_wlan.cpp platform/vmost_client.cpp,,-ldl)) +$(eval $(call host-test,evo-reboot,platform/evo_reboot.cpp platform/vmost_client.cpp,,-ldl)) +$(eval $(call host-test,evo-mic,platform/evo_mic.cpp,,-ldl)) +$(eval $(call host-test,spawn-attr)) +$(eval $(call host-test,popup-peek)) +$(eval $(call host-test,hold-machine,hmiapp/hold_machine.cpp)) +$(eval $(call host-test,child-reaper)) +$(eval $(call host-test,idrive-touch,hmiapp/idrive_touch.cpp)) +$(eval $(call host-test,vtable-check)) +$(eval $(call host-test,posted-task)) +$(eval $(call host-test,pending-restart)) +$(eval $(call host-test,guard-file)) +$(eval $(call host-test,phone-audio-recall)) +$(eval $(call host-test,log-profile)) +$(eval $(call host-test,kept-log)) +$(eval $(call host-test,log-copy,platform/log_copy.cpp)) +$(eval $(call host-test,update-package,platform/update_package.cpp,ssl,-lcrypto)) +$(eval $(call host-test,update-install,$(UPDATE_SRC),ssl,-lcrypto)) +$(eval $(call host-test,update-flow)) +$(eval $(call host-test,pb)) +$(eval $(call host-test,volume-pill,platform/volume_pill.cpp)) +$(eval $(call host-test,aa-messages,core/aa_messages.cpp)) +$(eval $(call host-test,tcp-server,core/tcp_server.cpp)) +$(eval $(call host-test,no-inherit,core/tcp_server.cpp core/car_inbox.cpp $(KOMBI_SRC))) +$(eval $(call host-test,wifi-link,platform/wifi_link.cpp)) +$(eval $(call host-test,wireless-phone,core/wireless_setup.cpp)) +$(eval $(call host-test,wireless-listen,core/wireless_setup.cpp)) +$(eval $(call host-test,crash-handler,core/crash_handler.cpp)) +$(eval $(call host-test,fd-hygiene,platform/evo_process.cpp)) +$(eval $(call host-test,security-fs)) + +# The fake libraries remain uninstrumented, as in the original sanitizer suite. +define host-fixture +HOST_OBJECTS += $(HOST_BUILD)/obj/$(1).o +$(HOST_BUILD)/obj/$(1).o: $(2) Makefile tests/host.mk $(HOST_BUILD)/config + @mkdir -p $$(@D) + $$(HOST_CACHE) $$(HOST_CC) -std=c99 -Wall -Wextra -Werror -fPIC $(3) -MMD -MP -c $$< -o $$@ +$(HOST_BUILD)/$(1).so: $(HOST_BUILD)/obj/$(1).o + $$(HOST_CC) -shared $$< $(4) -o $$@ +endef +$(eval $(call host-fixture,fake-vmostclient,tests/fake_vmostclient.c)) +$(eval $(call host-fixture,fake-vmostclient-nosym,tests/fake_vmostclient.c,-DFAKE_VMOST_NO_CONNECTED)) +comma := , +$(eval $(call host-fixture,fake-libasound,tests/fake_libasound.c,-pthread,-Wl$(comma)-soname$(comma)libasound.so.2 -pthread)) + +-include $(sort $(HOST_OBJECTS:.o=.d)) + +host-bin = $(HOST_BUILD)/test-$(1) +host-fake = $(abspath $(HOST_BUILD)/$(1).so) +HOST_RUN_session-phone = $< tests/fixtures/session_phone.golden +HOST_RUN_evo-capture = $< --selftest +HOST_RUN_alps-spp = env -u XDG_RUNTIME_DIR dbus-run-session -- sh -c \ + 'DBUS_SYSTEM_BUS_ADDRESS="$$DBUS_SESSION_BUS_ADDRESS" ENTRY_AAD_TEST_BUS=1 ENTRY_AAD_DIAGNOSTIC=$(HOST_BUILD)/evo-check-host $<' +HOST_RUN_bmw-guidance = env -u XDG_RUNTIME_DIR dbus-run-session -- $< +HOST_RUN_evo-ilm = ENTRY_AAD_DIAGNOSTIC=$(HOST_BUILD)/evo-check-host $< +HOST_RUN_spp-snapshot = if [ -f "$(SPP_FIXTURE_LIB)" ]; then ENTRY_AAD_FIXTURE_LIB="$(SPP_FIXTURE_LIB)" $<; \ + else echo "SKIP test-spp-snapshot: no copy of the car system"; fi +HOST_RUN_evo-elf = $(if $(filter normal,$(HOST_MODE)),\ + if [ -f "$(SPP_FIXTURE_LIB)" ]; then ENTRY_AAD_FIXTURE_LIB="$(SPP_FIXTURE_LIB)" $<; else $<; fi,$<) +HOST_RUN_evo-input = $< $(call host-fake,fake-vmostclient) +HOST_RUN_evo-reboot = $< $(call host-fake,fake-vmostclient) +HOST_RUN_evo-wlan = $< $(call host-fake,fake-vmostclient) $(call host-fake,fake-vmostclient-nosym) +HOST_RUN_evo-mic = $< $(call host-fake,fake-libasound) +HOST_RUN_wireless-phone = $< tests/fixtures/wireless_phone.golden + +define host-run +.PHONY: run-host-$(1) +run-host-$(1): $(call host-bin,$(1)) $(2) + $$(if $$(HOST_RUN_$(1)),$$(HOST_RUN_$(1)),$$<) +endef + +HOST_UNITS = evo-elf evo-input evo-control peek-timing volume-state volume-pill sdr-g20 evo-sdr spawn-attr popup-peek \ + hold-machine child-reaper idrive-touch vtable-check posted-task pending-restart guard-file \ + phone-audio-recall log-profile kept-log log-copy update-package update-install update-flow pb aa-messages \ + tcp-server wifi-link wireless-phone wireless-listen crash-handler fd-hygiene security-fs evo-reboot +HOST_ONLY_UNITS = spp-snapshot supervisor evo-ilm video-presentation evo-wlan evo-mic no-inherit +HOST_KOMBI_UNITS = kombi-phone kombi-display kombi-graph kombi-guide kombi-client kombi-nav kombi-golden kombi-most +HOST_USB_UNITS = usb-accessory usb-bridge usb-loop +HOST_RUNS = $(HOST_UNITS) $(HOST_ONLY_UNITS) $(HOST_KOMBI_UNITS) $(HOST_USB_UNITS) \ + aa-frame session-phone parsers alps-spp bmw-guidance media-recall evo-gps evo-capture evo-touch-live + +HOST_PREREQS_alps-spp = $(HOST_BUILD)/evo-check-host +HOST_PREREQS_evo-ilm = $(HOST_BUILD)/evo-check-host +HOST_PREREQS_evo-input = $(HOST_BUILD)/fake-vmostclient.so +HOST_PREREQS_evo-reboot = $(HOST_BUILD)/fake-vmostclient.so +HOST_PREREQS_evo-wlan = $(HOST_BUILD)/fake-vmostclient.so $(HOST_BUILD)/fake-vmostclient-nosym.so +HOST_PREREQS_evo-mic = $(HOST_BUILD)/fake-libasound.so +$(foreach test,$(HOST_RUNS),$(eval $(call host-run,$(test),$(HOST_PREREQS_$(test))))) + +test-frame-host: run-host-aa-frame +test-session-host: run-host-session-phone +test-parsers: run-host-parsers +test-spp-host: run-host-alps-spp +test-media-host: run-host-media-recall +test-kombi-core-host: $(addprefix run-host-,$(HOST_KOMBI_UNITS)) +test-kombi-host: test-kombi-core-host run-host-bmw-guidance +test-usb-host: $(addprefix run-host-,$(HOST_USB_UNITS)) +test-gps-host: run-host-evo-gps + python3 tests/test_gps_wire_oracle.py +test-capture-host: run-host-evo-capture +test-touch-live: run-host-evo-touch-live + +.PHONY: run-host-idrive-lookups run-host-update-release run-host-docs +run-host-idrive-lookups: + python3 tests/test_idrive_lookups.py +run-host-update-release: $(call host-bin,update-package) + python3 tests/test_update_release.py $< +run-host-docs: + python3 tests/test_docs.py + +test-host: test-parsers test-spp-host test-kombi-host test-gps-host test-capture-host test-usb-host test-media-host \ + test-frame-host test-session-host $(addprefix run-host-,$(HOST_UNITS) $(HOST_ONLY_UNITS)) \ + run-host-idrive-lookups run-host-update-release run-host-docs + +# Disabling address randomization avoids GCC ASan startup failures on some kernels; Docker may refuse it. +NORAND = $(shell setarch $$(uname -m) -R true 2>/dev/null && echo setarch $$(uname -m) -R) +test-host-sanitizers: + +ASAN_OPTIONS=detect_leaks=1:allow_user_segv_handler=1 $(NORAND) $(MAKE) HOST_MODE=sanitized \ + test-frame-host test-session-host test-parsers test-usb-host test-capture-host test-media-host \ + test-kombi-core-host test-unit-sanitizers \ + HOST_FLAGS="$(HOST_FLAGS) -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" + +test-unit-sanitizers: $(addprefix run-host-,$(HOST_UNITS) evo-gps) diff --git a/tests/test_gps_wire_oracle.py b/tests/test_gps_wire_oracle.py index a1f28ba..68a763f 100644 --- a/tests/test_gps_wire_oracle.py +++ b/tests/test_gps_wire_oracle.py @@ -115,7 +115,7 @@ def main(): record = next(s for s in json.loads((SOURCES / "sources.json").read_text()) if s["file"] == "LocationData.proto") if sha256(SCHEMA.read_bytes()).hexdigest() != record["sha256"]: raise SystemExit("FAIL: oracle schema changed") - commands = {"host": [str(ROOT / "tests/test-evo-gps")]} + commands = {"host": [str(ROOT / "tests/build-host/normal/test-evo-gps")]} if "--arm" in sys.argv: commands["ARM_QEMU"] = [ "qemu-arm", diff --git a/tests/test_update_release.py b/tests/test_update_release.py index 6dc1ae7..b9d1b2f 100644 --- a/tests/test_update_release.py +++ b/tests/test_update_release.py @@ -3,11 +3,11 @@ """The release archive as tools/package_release.py writes it, read by the car's update code. A key made for the test signs an archive built by the packager's own functions; the C++ reader -(tests/test-update-package --verify) must take it. Also: the signature is the same every time (the archive stays +(test-update-package --verify) must take it. Also: the signature is the same every time (the archive stays reproducible), a key the programs do not trust is refused at packaging, and the project's key in platform/update_key.hpp reads as a DER key. -Usage: test_update_release.py +Usage: test_update_release.py """ import subprocess From e8a4dbd82488361cc5a57a6350e132e05d78f64d Mon Sep 17 00:00:00 2001 From: mbalous <10358985+mbalous@users.noreply.github.com> Date: Thu, 3 Dec 2026 00:35:12 +0100 Subject: [PATCH 2/3] ci: fix the first remote check failures Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 11 ++++++++--- tests/host.mk | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c7adcf..fd43957 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,9 +121,14 @@ jobs: DOCKER_BUILDKIT=0 docker build -t entrynav2-tc:4.7 toolchain - name: Compile ARM objects without the car sysroot run: | - docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" entrynav2-tc:4.7 sh -ec ' - test ! -e /sysroot - test "$(arm-linux-gnueabihf-g++ -dumpversion)" = 4.7.2 + docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" entrynav2-tc:4.7 sh -exc ' + arm-linux-gnueabihf-g++ --version + test "$(arm-linux-gnueabihf-g++ -dumpmachine)" = arm-linux-gnueabihf + version=$(dpkg-query -W -f="\${Version}" g++-4.7-arm-linux-gnueabihf) + case "$version" in + 4.7.2-*) ;; + *) echo "Unexpected ARM compiler package version: $version" >&2; exit 1 ;; + esac make -j"$(getconf _NPROCESSORS_ONLN)" compile-arm arm-linux-gnueabihf-objdump -f platform/main.o tools/aa_supervisor.o hmiapp/entry_aa_app.o ' diff --git a/tests/host.mk b/tests/host.mk index 6781ec4..b2a44b3 100644 --- a/tests/host.mk +++ b/tests/host.mk @@ -82,7 +82,7 @@ $(eval $(call host-test,video-presentation,platform/evo_video.cpp)) $(eval $(call host-test,evo-input,platform/evo_touch.cpp platform/evo_knob.cpp platform/vmost_client.cpp,,-ldl)) $(eval $(call host-test,evo-control,platform/evo_control.cpp)) $(eval $(call host-test,peek-timing,platform/peek_timing.cpp)) -$(eval $(call host-test,volume-state,platform/volume_state.cpp)) +$(eval $(call host-test,volume-state)) $(eval $(call host-test,sdr-g20,core/sdr_builder.cpp platform/evo_sdr_sensors.cpp,core)) $(eval $(call host-test,evo-sdr,core/sdr_builder.cpp platform/evo_sdr_sensors.cpp,core)) $(eval $(call host-test,evo-wlan,platform/evo_wlan.cpp platform/vmost_client.cpp,,-ldl)) @@ -105,7 +105,7 @@ $(eval $(call host-test,update-package,platform/update_package.cpp,ssl,-lcrypto) $(eval $(call host-test,update-install,$(UPDATE_SRC),ssl,-lcrypto)) $(eval $(call host-test,update-flow)) $(eval $(call host-test,pb)) -$(eval $(call host-test,volume-pill,platform/volume_pill.cpp)) +$(eval $(call host-test,volume-pill)) $(eval $(call host-test,aa-messages,core/aa_messages.cpp)) $(eval $(call host-test,tcp-server,core/tcp_server.cpp)) $(eval $(call host-test,no-inherit,core/tcp_server.cpp core/car_inbox.cpp $(KOMBI_SRC))) From 021af66fb5b9c1ab6b660bd479eb2bf59dee83e2 Mon Sep 17 00:00:00 2001 From: mbalous <10358985+mbalous@users.noreply.github.com> Date: Thu, 3 Dec 2026 00:37:52 +0100 Subject: [PATCH 3/3] docs: describe the new CI checks in English Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6277174..75b67cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,17 +60,17 @@ fermeture. | Niveau | Commande | Il faut | |---|---|---| | PC, comme la CI | `make check` | `g++`, `libssl-dev`, `libdbus-1-dev`, `protobuf-compiler`, `python3-protobuf`, clang-format 18.1.8 et ruff 0.6.9 (`pip install -r requirements-dev.txt`) | -| PC, mémoire et UB | `make test-host-sanitizers` | `g++` avec ASan/UBSan, `libssl-dev` ; détection des fuites active | -| ARM, compilation seule (CI) | `make compile-arm` dans l'image `entrynav2-tc:4.7` | Docker et les en-têtes publics de l'image, sans copie du système de la voiture | +| PC, mémoire et UB | `make test-host-sanitizers` | `g++` avec ASan/UBSan, `libssl-dev` ; tests des trames et de la session, détection des fuites active | +| ARM compile-only (CI) | `make compile-arm` inside `entrynav2-tc:4.7` | Docker and the image's public headers; no copy of the head unit system | | ARM | `bash toolchain/tc.sh make -j4 all hmiapp test-arm-all` | Docker, la copie du système de la voiture | | ARM SDK, hors publication | `bash toolchain/tc.sh --sdk make -j4 all` puis `python3 tools/verify_sdk.py` | Images Docker `entrynav2-tc:4.7` et `entrynav2-sdk:4.7` ([README](README.md#building-from-source)), `pyelftools`, `readelf` ; pas de copie du système | | ARM sous QEMU | `python3 -I tests/run_qemu.py` | `qemu-user`, la copie du système | | Programmes validés | `make verify_binary verify_wireless` | idem | | Procédure d'installation | les commandes de [docs/INSTALLATION.md](docs/INSTALLATION.md), avec la BusyBox de la voiture sous QEMU | idem | -Les tests PC acceptent `make -jN`. Leurs binaires sont séparés dans `tests/build-host/normal/` et -`tests/build-host/sanitized/`. `HOST_CACHE=ccache` est facultatif en local. La vérification ARM de la CI compile -les objets avec GCC 4.7, mais ne remplace ni l'édition de liens avec les bibliothèques de la voiture ni QEMU. +Host tests support `make -jN`. Normal and sanitized binaries are kept in `tests/build-host/normal/` and +`tests/build-host/sanitized/`, respectively. `HOST_CACHE=ccache` is optional for local builds. The ARM compile-only +check uses GCC 4.7 but does not replace linking against the head unit libraries or testing under QEMU. Les résultats SDK sont isolés dans `artifacts/sdk/` : ils ne passent pas par la publication. Le contrôle ELF ne remplace ni le chargement avec les bibliothèques de la voiture ni l'essai en voiture. Si la compilation de référence