mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-19 05:22:21 +02:00
feat(modem): host test support of the latest ESP-IDF release
This commit is contained in:
@ -22,8 +22,7 @@ using namespace esp_modem;
|
||||
|
||||
[[maybe_unused]] constexpr auto TAG = "linux_modem_main";
|
||||
|
||||
|
||||
int main()
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
// init the DTE
|
||||
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)
|
||||
|
||||
set(COMPONENTS main)
|
||||
set(COMPONENTS esp_modem main)
|
||||
project(host_modem_test)
|
||||
|
||||
idf_component_get_property(esp_modem esp_modem COMPONENT_LIB)
|
||||
|
@ -3,19 +3,14 @@
|
||||
idf_version=$1
|
||||
component=$2
|
||||
|
||||
if [[ "$idf_version" == "release-v4.3" ]] && [[ "$component" == "esp_modem" ]]; then
|
||||
lwip=lwip-2.1.2
|
||||
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
|
||||
lwip_contrib=contrib-2.1.0
|
||||
lwip=lwip-2.1.2
|
||||
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
|
||||
lwip_contrib=contrib-2.1.0
|
||||
|
||||
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
||||
unzip -oq ${lwip}.zip
|
||||
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
||||
unzip -oq ${lwip_contrib}.zip
|
||||
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
||||
unzip -oq ${lwip}.zip
|
||||
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
||||
unzip -oq ${lwip_contrib}.zip
|
||||
|
||||
apt-get update && apt-get install -y gcc-8 g++-8
|
||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
||||
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
|
||||
export LWIP_PATH=`pwd`/$lwip
|
||||
export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib
|
||||
|
@ -1,11 +1,12 @@
|
||||
idf_component_register(SRCS "test_modem.cpp" "LoopbackTerm.cpp"
|
||||
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
|
||||
REQUIRES esp_modem)
|
||||
REQUIRES esp_modem WHOLE_ARCHIVE)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE Threads::Threads)
|
||||
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain)
|
||||
|
||||
set_target_properties(${COMPONENT_LIB} PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
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
|
||||
*/
|
||||
#define CATCH_CONFIG_MAIN // This tells the catch header to generate a main
|
||||
#include <memory>
|
||||
#include <future>
|
||||
#include "catch.hpp"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/catch_session.hpp>
|
||||
#include "cxx_include/esp_modem_api.hpp"
|
||||
#include "LoopbackTerm.h"
|
||||
#include <iostream>
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
#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