Skip to content

feat(modem): Add end2end host tests with host modem_sim#1041

Merged
david-cermak merged 4 commits intoespressif:masterfrom
david-cermak:feat/modem_host_tests
Apr 16, 2026
Merged

feat(modem): Add end2end host tests with host modem_sim#1041
david-cermak merged 4 commits intoespressif:masterfrom
david-cermak:feat/modem_host_tests

Conversation

@david-cermak
Copy link
Copy Markdown
Collaborator

@david-cermak david-cermak commented Apr 1, 2026

Add end-to-end host test with modem simulator

Adds a new host_test_app under components/esp_modem/test/ that exercises the esp_modem AT command path end-to-end on a Linux host, using two cooperating processes connected over a TCP socket.

The test consists of two parts:

modem_sim

A standalone C++ TCP server (no IDF dependency) that emulates a SIM7600-like modem. It listens on localhost, accepts connections, and responds to AT commands (AT+CSQ, AT+CGMM, AT+CGSN, AT+CIMI, AT+COPS?, AT+CPIN?, +++, etc.). Responses can be delivered in configurable batches (batch_size / batch_delay_ms) to simulate fragmented serial data arriving in chunks rather than complete lines.

test_app

An IDF Linux application (Catch2) that creates a VFS socket DTE via vfs_create_socket, instantiates a SIM7600 DCE through the standard esp_modem factory API, and runs AT command tests against the simulator. Seven test cases cover set_command_mode, get_signal_quality, get_module_name, get_operator_name, get_imsi, get_imei, and read_pin.

A run_test.sh harness script orchestrates both processes: builds the simulator if needed, starts it in the background, runs the test binary with a configurable timeout, and cleans up.

esp_netif_linux stub mode

To avoid requiring a lwIP download for AT-only testing, the esp_netif_linux component's CMakeLists.txt now checks whether LWIP_PATH is set. If not, it registers a minimal stub (esp_netif_stub.c) providing only the headers and no-op implementations of esp_netif_new/esp_netif_destroy/esp_netif_receive, then returns early. The full lwIP+TUN build path is unchanged when LWIP_PATH is defined. This makes the existing host_test and linux_modem example unaffected while enabling lightweight test builds.


Note

Medium Risk
Introduces new CI-executed host tests and a conditional esp_netif_linux stub path, which could affect Linux build/link behavior when lwIP isn’t configured. Runtime impact should be limited to the Linux port and test scaffolding.

Overview
Adds a new components/esp_modem/test/host_test_app end-to-end Linux host test that runs Catch2-based AT-command tests against a new standalone TCP modem_sim process, with a run_test.sh harness and CI configs for the Linux target.

Updates CI (modem__build-host-tests.yml) to build and execute this host test across multiple IDF versions and run it under different response chunking settings to simulate fragmented modem I/O.

Makes Linux builds less dependent on networking by adding an esp_netif_linux stub mode when LWIP_PATH isn’t present (registering esp_netif_stub.c), and introduces a small FreeRTOS portmacro.h shim for Linux critical-section/spinlock APIs.

Reviewed by Cursor Bugbot for commit 63ccd09. Bugbot is set up for automated code reviews on this repo. Configure here.

@david-cermak david-cermak self-assigned this Apr 1, 2026
Comment thread components/esp_modem/test/host_test_app/main/test_app.cpp Outdated
Comment thread components/esp_modem/test/host_test_app/main/test_app.cpp
Comment thread components/esp_modem/test/host_test_app/run_test.sh Outdated
Comment thread components/esp_modem/test/host_test_app/CMakeLists.txt Outdated
Comment thread components/esp_modem/test/host_test_app/main/CMakeLists.txt Outdated
Comment thread components/esp_modem/test/host_test_app/main/CMakeLists.txt Outdated
Comment thread components/esp_modem/test/host_test_app/main/test_app.cpp Outdated
@david-cermak david-cermak force-pushed the feat/modem_host_tests branch from c1997ae to ac832bb Compare April 14, 2026 14:50
@david-cermak david-cermak merged commit ec1d0e4 into espressif:master Apr 16, 2026
130 of 143 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants