mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-18 21:12:22 +02:00
feat(modem): host test support of the latest ESP-IDF release
This commit is contained in:
17
.github/workflows/modem__build-host-tests.yml
vendored
17
.github/workflows/modem__build-host-tests.yml
vendored
@ -76,10 +76,25 @@ jobs:
|
|||||||
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
|
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
|
||||||
uses: "./.github/workflows/run-host-tests.yml"
|
uses: "./.github/workflows/run-host-tests.yml"
|
||||||
with:
|
with:
|
||||||
idf_version: "release-v4.3"
|
idf_version: "latest"
|
||||||
app_name: "host_modem_test"
|
app_name: "host_modem_test"
|
||||||
app_path: "esp-protocols/components/esp_modem/test/host_test"
|
app_path: "esp-protocols/components/esp_modem/test/host_test"
|
||||||
component_path: "esp-protocols/components/esp_modem"
|
component_path: "esp-protocols/components/esp_modem"
|
||||||
upload_artifacts: true
|
upload_artifacts: true
|
||||||
|
run_executable: true
|
||||||
|
run_coverage: true
|
||||||
pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh"
|
pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh"
|
||||||
publish_unit_test_result: true
|
publish_unit_test_result: true
|
||||||
|
|
||||||
|
build_linux_example:
|
||||||
|
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
|
||||||
|
uses: "./.github/workflows/run-host-tests.yml"
|
||||||
|
with:
|
||||||
|
idf_version: "latest"
|
||||||
|
app_name: "linux_modem"
|
||||||
|
app_path: "esp-protocols/components/esp_modem/examples/linux_modem"
|
||||||
|
component_path: "esp-protocols/components/esp_modem"
|
||||||
|
upload_artifacts: true
|
||||||
|
run_executable: false
|
||||||
|
run_coverage: false
|
||||||
|
pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh"
|
||||||
|
23
.github/workflows/run-host-tests.yml
vendored
23
.github/workflows/run-host-tests.yml
vendored
@ -18,6 +18,12 @@ on:
|
|||||||
upload_artifacts:
|
upload_artifacts:
|
||||||
type: boolean
|
type: boolean
|
||||||
required: true
|
required: true
|
||||||
|
run_executable:
|
||||||
|
type: boolean
|
||||||
|
required: true
|
||||||
|
run_coverage:
|
||||||
|
type: boolean
|
||||||
|
required: true
|
||||||
pre_run_script:
|
pre_run_script:
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: false
|
||||||
@ -51,7 +57,16 @@ jobs:
|
|||||||
# The sdkconfig.ci.linux specifies Linux as the build target with apropriate settings.
|
# The sdkconfig.ci.linux specifies Linux as the build target with apropriate settings.
|
||||||
cp sdkconfig.ci.linux sdkconfig.defaults
|
cp sdkconfig.ci.linux sdkconfig.defaults
|
||||||
idf.py build
|
idf.py build
|
||||||
./build/${{inputs.app_name}}.elf -r junit -o junit.xml
|
if [ "${{ inputs.run_executable}}" == "false" ]; then
|
||||||
|
echo "Executeable wasn't run"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ inputs.publish_unit_test_result }}" == "true" ]; then
|
||||||
|
./build/${{inputs.app_name}}.elf --reporter JUnit::out=result-junit.xml --reporter console::out=-::colour-mode=ansi
|
||||||
|
else
|
||||||
|
./build/${{inputs.app_name}}.elf
|
||||||
|
fi
|
||||||
- name: Publish Unit Test Result
|
- name: Publish Unit Test Result
|
||||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
if: ${{ inputs.publish_unit_test_result }}
|
if: ${{ inputs.publish_unit_test_result }}
|
||||||
@ -59,6 +74,7 @@ jobs:
|
|||||||
files: ${{inputs.component_path}}/**/*junit.xml
|
files: ${{inputs.component_path}}/**/*junit.xml
|
||||||
- name: Build with Coverage Enabled
|
- name: Build with Coverage Enabled
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: ${{ inputs.run_coverage }}
|
||||||
run: |
|
run: |
|
||||||
component=$(basename ${{ inputs.component_path }})
|
component=$(basename ${{ inputs.component_path }})
|
||||||
if [ -f "${{ inputs.pre_run_script }}" ]; then
|
if [ -f "${{ inputs.pre_run_script }}" ]; then
|
||||||
@ -74,6 +90,7 @@ jobs:
|
|||||||
./build/${{inputs.app_name}}.elf
|
./build/${{inputs.app_name}}.elf
|
||||||
- name: Run Coverage
|
- name: Run Coverage
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: ${{ inputs.run_coverage }}
|
||||||
run: |
|
run: |
|
||||||
apt-get update && apt-get install -y python3-pip rsync
|
apt-get update && apt-get install -y python3-pip rsync
|
||||||
python -m pip install gcovr
|
python -m pip install gcovr
|
||||||
@ -86,6 +103,7 @@ jobs:
|
|||||||
cp index.html ${{inputs.app_name}}_coverage_report
|
cp index.html ${{inputs.app_name}}_coverage_report
|
||||||
cp -rf ${{inputs.app_name}}_coverage_report ${{inputs.app_name}}_coverage.xml $GITHUB_WORKSPACE
|
cp -rf ${{inputs.app_name}}_coverage_report ${{inputs.app_name}}_coverage.xml $GITHUB_WORKSPACE
|
||||||
- name: Code Coverage Summary Report
|
- name: Code Coverage Summary Report
|
||||||
|
if: ${{ inputs.run_coverage }}
|
||||||
uses: irongut/CodeCoverageSummary@v1.3.0
|
uses: irongut/CodeCoverageSummary@v1.3.0
|
||||||
with:
|
with:
|
||||||
filename: esp-protocols/**/${{inputs.app_name}}_coverage.xml
|
filename: esp-protocols/**/${{inputs.app_name}}_coverage.xml
|
||||||
@ -99,9 +117,10 @@ jobs:
|
|||||||
thresholds: '60 80'
|
thresholds: '60 80'
|
||||||
- name: Write to Job Summary
|
- name: Write to Job Summary
|
||||||
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
|
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
|
||||||
|
if: ${{ inputs.run_coverage }}
|
||||||
- name: Upload files to artifacts for run-target job
|
- name: Upload files to artifacts for run-target job
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
if: ${{inputs.upload_artifacts}}
|
if: ${{ inputs.run_coverage }}
|
||||||
with:
|
with:
|
||||||
name: ${{inputs.app_name}}_coverage_report
|
name: ${{inputs.app_name}}_coverage_report
|
||||||
path: |
|
path: |
|
||||||
|
@ -17,4 +17,6 @@ jobs:
|
|||||||
app_name: "websocket"
|
app_name: "websocket"
|
||||||
app_path: "esp-protocols/components/esp_websocket_client/examples/linux"
|
app_path: "esp-protocols/components/esp_websocket_client/examples/linux"
|
||||||
component_path: "esp-protocols/components/esp_websocket_client"
|
component_path: "esp-protocols/components/esp_websocket_client"
|
||||||
|
run_executable: true
|
||||||
upload_artifacts: true
|
upload_artifacts: true
|
||||||
|
run_coverage: true
|
||||||
|
@ -22,8 +22,7 @@ using namespace esp_modem;
|
|||||||
|
|
||||||
[[maybe_unused]] constexpr auto TAG = "linux_modem_main";
|
[[maybe_unused]] constexpr auto TAG = "linux_modem_main";
|
||||||
|
|
||||||
|
extern "C" void app_main(void)
|
||||||
int main()
|
|
||||||
{
|
{
|
||||||
// init the DTE
|
// init the DTE
|
||||||
esp_modem_dte_config_t dte_config = {
|
esp_modem_dte_config_t dte_config = {
|
||||||
|
@ -6,7 +6,7 @@ set(EXTRA_COMPONENT_DIRS # Add esp_modem component and linux port components
|
|||||||
../..
|
../..
|
||||||
../../port/linux)
|
../../port/linux)
|
||||||
|
|
||||||
set(COMPONENTS main)
|
set(COMPONENTS esp_modem main)
|
||||||
project(host_modem_test)
|
project(host_modem_test)
|
||||||
|
|
||||||
idf_component_get_property(esp_modem esp_modem COMPONENT_LIB)
|
idf_component_get_property(esp_modem esp_modem COMPONENT_LIB)
|
||||||
|
@ -3,19 +3,14 @@
|
|||||||
idf_version=$1
|
idf_version=$1
|
||||||
component=$2
|
component=$2
|
||||||
|
|
||||||
if [[ "$idf_version" == "release-v4.3" ]] && [[ "$component" == "esp_modem" ]]; then
|
lwip=lwip-2.1.2
|
||||||
lwip=lwip-2.1.2
|
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
|
||||||
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
|
lwip_contrib=contrib-2.1.0
|
||||||
lwip_contrib=contrib-2.1.0
|
|
||||||
|
|
||||||
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
||||||
unzip -oq ${lwip}.zip
|
unzip -oq ${lwip}.zip
|
||||||
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
||||||
unzip -oq ${lwip_contrib}.zip
|
unzip -oq ${lwip_contrib}.zip
|
||||||
|
|
||||||
apt-get update && apt-get install -y gcc-8 g++-8
|
export LWIP_PATH=`pwd`/$lwip
|
||||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib
|
||||||
rm /usr/bin/gcov && ln -s /usr/bin/gcov-8 /usr/bin/gcov
|
|
||||||
export LWIP_PATH=`pwd`/$lwip
|
|
||||||
export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib
|
|
||||||
fi
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
idf_component_register(SRCS "test_modem.cpp" "LoopbackTerm.cpp"
|
idf_component_register(SRCS "test_modem.cpp" "LoopbackTerm.cpp"
|
||||||
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
|
REQUIRES esp_modem WHOLE_ARCHIVE)
|
||||||
REQUIRES esp_modem)
|
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(${COMPONENT_LIB} PRIVATE Threads::Threads)
|
target_link_libraries(${COMPONENT_LIB} PRIVATE Threads::Threads)
|
||||||
|
|
||||||
|
target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain)
|
||||||
|
|
||||||
set_target_properties(${COMPONENT_LIB} PROPERTIES
|
set_target_properties(${COMPONENT_LIB} PROPERTIES
|
||||||
CXX_STANDARD 17
|
CXX_STANDARD 17
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
dependencies:
|
||||||
|
espressif/catch2:
|
||||||
|
version: '*'
|
||||||
|
idf:
|
||||||
|
version: ">=5.0"
|
@ -1,14 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
#define CATCH_CONFIG_MAIN // This tells the catch header to generate a main
|
#define CATCH_CONFIG_MAIN // This tells the catch header to generate a main
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <future>
|
#include <future>
|
||||||
#include "catch.hpp"
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <catch2/catch_session.hpp>
|
||||||
#include "cxx_include/esp_modem_api.hpp"
|
#include "cxx_include/esp_modem_api.hpp"
|
||||||
#include "LoopbackTerm.h"
|
#include "LoopbackTerm.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace esp_modem;
|
using namespace esp_modem;
|
||||||
|
|
||||||
@ -346,3 +348,25 @@ TEST_CASE("CMUX manual mode transitions", "[esp_modem][transitions]")
|
|||||||
CHECK(dce->set_mode(esp_modem::modem_mode::UNDEF) == true); // Succeeds from any state
|
CHECK(dce->set_mode(esp_modem::modem_mode::UNDEF) == true); // Succeeds from any state
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CATCH_CONFIG_RUNNER
|
||||||
|
extern "C" int app_main(void)
|
||||||
|
{
|
||||||
|
// Define the argument count and arguments for Catch2, including JUnit reporting
|
||||||
|
int argc = 5;
|
||||||
|
const char *argv[] = {"esp_modem", "-r", "junit", "-o", "junit.xml", nullptr};
|
||||||
|
|
||||||
|
// Run the Catch2 session and store the result
|
||||||
|
int result = Catch::Session().run(argc, argv);
|
||||||
|
|
||||||
|
// Use more descriptive error handling
|
||||||
|
if (result != 0) {
|
||||||
|
printf("Test failed with result %d. Refer to the Catch2 documentation for error details.\n", result);
|
||||||
|
} else {
|
||||||
|
printf("All tests passed successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for the junit.xml file in the current working directory
|
||||||
|
// Exit the application with the test result as the status code
|
||||||
|
std::exit(result);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user