mirror of
https://github.com/espressif/esp-modbus.git
synced 2025-09-25 22:20:54 +02:00
Merge branch 'bugfix/ci_fix_idf_v60_issues' into 'main'
fix idf compatibility issues under ci See merge request idf/esp-modbus!130
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
# Exclude old component feemodbus which exists in old versions
|
# Exclude old component feemodbus which exists in old versions
|
||||||
set(EXCLUDE_COMPONENTS freemodbus)
|
set(EXCLUDE_COMPONENTS freemodbus)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
# Exclude old component feemodbus which exists in old versions
|
# Exclude old component feemodbus which exists in old versions
|
||||||
set(EXCLUDE_COMPONENTS freemodbus)
|
set(EXCLUDE_COMPONENTS freemodbus)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
set(EXCLUDE_COMPONENTS freemodbus)
|
set(EXCLUDE_COMPONENTS freemodbus)
|
||||||
|
|
||||||
|
@@ -1,8 +1,14 @@
|
|||||||
# This is the project CMakeLists.txt file for the test subproject
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
|
||||||
list(APPEND EXTRA_COMPONENT_DIRS "../test_common")
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS "../test_common")
|
||||||
|
|
||||||
|
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5")
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components")
|
||||||
|
else()
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_comm_adapter)
|
project(test_comm_adapter)
|
||||||
|
@@ -8,7 +8,7 @@ set(srcs "test_app_main.c"
|
|||||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||||
idf_component_register(SRCS ${srcs}
|
idf_component_register(SRCS ${srcs}
|
||||||
PRIV_REQUIRES cmock test_common unity test_utils
|
PRIV_REQUIRES cmock test_common unity test_utils
|
||||||
) #
|
)
|
||||||
|
|
||||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u mb_test_include_adapter_impl_serial")
|
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u mb_test_include_adapter_impl_serial")
|
||||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u mb_test_include_adapter_impl_tcp")
|
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u mb_test_include_adapter_impl_tcp")
|
||||||
|
@@ -4,14 +4,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded import Dut
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('target', ['esp32'], indirect=True)
|
||||||
CONFIGS = [
|
@pytest.mark.parametrize('config', ['serial','tcp'], indirect=True)
|
||||||
pytest.param('serial', marks=[pytest.mark.esp32, pytest.mark.esp32p4]),
|
|
||||||
pytest.param('tcp', marks=[pytest.mark.esp32, pytest.mark.esp32p4]),
|
|
||||||
]
|
|
||||||
|
|
||||||
@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='no multi-dev runner')
|
|
||||||
@pytest.mark.multi_dut_modbus_generic
|
@pytest.mark.multi_dut_modbus_generic
|
||||||
@pytest.mark.parametrize('config', CONFIGS, indirect=True)
|
|
||||||
def test_modbus_comm_adapter(dut: Dut) -> None:
|
def test_modbus_comm_adapter(dut: Dut) -> None:
|
||||||
dut.expect_unity_test_output()
|
dut.expect_unity_test_output()
|
||||||
|
@@ -3,11 +3,12 @@
|
|||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "mbcontroller.h"
|
#include "mbcontroller.h"
|
||||||
|
|
||||||
#define TEST_PORT_NUM (uart_port_t)1
|
#define TEST_PORT_NUM (uart_port_t)1
|
||||||
#define TEST_SPEED 115200
|
#define TEST_SPEED 115200
|
||||||
|
|
||||||
#define TAG "CPP_TEST"
|
#define TAG "CPP_TEST"
|
||||||
#define MB_SLAVE_SHORT_ADDRESS 1
|
#define MB_SLAVE_SHORT_ADDRESS 1
|
||||||
|
#define MB_FUNC_CODE_MAX 42
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MB_DEVICE_ADDR1 = 1
|
MB_DEVICE_ADDR1 = 1
|
||||||
@@ -120,12 +121,18 @@ static int check_custom_handlers(void *inst)
|
|||||||
MB_RETURN_ON_FALSE((err == ESP_OK), 0, TAG,
|
MB_RETURN_ON_FALSE((err == ESP_OK), 0, TAG,
|
||||||
"mbc slave get handler count, returns(0x%x).", (int)err);
|
"mbc slave get handler count, returns(0x%x).", (int)err);
|
||||||
ESP_LOGI(TAG,"Object %p, custom handler test, (registered:max) handlers: %d:%d.", inst, count, CONFIG_FMB_FUNC_HANDLERS_MAX);
|
ESP_LOGI(TAG,"Object %p, custom handler test, (registered:max) handlers: %d:%d.", inst, count, CONFIG_FMB_FUNC_HANDLERS_MAX);
|
||||||
for (entry = 0x01; entry < CONFIG_FMB_FUNC_HANDLERS_MAX; entry++) {
|
for (entry = 0x01; entry < MB_FUNC_CODE_MAX; entry++) {
|
||||||
// Try to remove the handler
|
// Try to remove the handlers
|
||||||
err = mbc_delete_handler(inst, (uint8_t)entry);
|
err = mbc_delete_handler(inst, (uint8_t)entry);
|
||||||
if (err != ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Could not remove handler for command: (0x%x), returned (0x%x), already empty?", entry, (int)err);
|
ESP_LOGW(TAG, "Removed handler for command: (0x%x), returned (0x%x).", entry, (int)err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
err = mbc_get_handler_count(inst, &count);
|
||||||
|
MB_RETURN_ON_FALSE((err == ESP_OK && !count), 0, TAG,
|
||||||
|
"mbc slave get handler count, returns(0x%x), %u.", (int)err, count);
|
||||||
|
|
||||||
|
for (entry = 0x01; entry < CONFIG_FMB_FUNC_HANDLERS_MAX; entry++) {
|
||||||
err = mbc_set_handler(inst, (uint8_t)entry, test_handler);
|
err = mbc_set_handler(inst, (uint8_t)entry, test_handler);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG,"Could not set handler for command 0x%x, returned (0x%x).", entry, (int)err);
|
ESP_LOGE(TAG,"Could not set handler for command 0x%x, returned (0x%x).", entry, (int)err);
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded import Dut
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
MB_APP_WAIT_TOUT_SEC = 10
|
MB_APP_WAIT_TOUT_SEC = 30
|
||||||
|
|
||||||
@pytest.mark.esp32
|
@pytest.mark.parametrize('target', ['esp32'], indirect=True)
|
||||||
@pytest.mark.generic
|
@pytest.mark.multi_dut_modbus_generic
|
||||||
def test_cpp_mb_serial_master_slave(dut: Dut) -> None:
|
def test_cpp_mb_serial_master_slave(dut: Dut) -> None:
|
||||||
dut.expect('Setup master cpp....')
|
dut.expect('Setup master cpp....')
|
||||||
dut.expect('Modbus master stack initialized...', timeout=MB_APP_WAIT_TOUT_SEC)
|
dut.expect('Modbus master stack initialized...', timeout=MB_APP_WAIT_TOUT_SEC)
|
||||||
|
@@ -1,8 +1,15 @@
|
|||||||
# This is the project CMakeLists.txt file for the test subproject
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
|
||||||
list(APPEND EXTRA_COMPONENT_DIRS "../test_common")
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS "../test_common")
|
||||||
|
|
||||||
|
# The workaround for the test_utils under ESP-IDF v6.0
|
||||||
|
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5")
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components")
|
||||||
|
else()
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_modbus_comm_multi_dev)
|
project(test_modbus_comm_multi_dev)
|
||||||
|
@@ -4,18 +4,18 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded_idf import CaseTester
|
from pytest_embedded_idf import CaseTester
|
||||||
|
|
||||||
@pytest.mark.esp32
|
@pytest.mark.parametrize('target', ['esp32'], indirect=True)
|
||||||
@pytest.mark.multi_dut_modbus_serial
|
|
||||||
@pytest.mark.parametrize('count, config', [(2, 'serial')], indirect=True)
|
@pytest.mark.parametrize('count, config', [(2, 'serial')], indirect=True)
|
||||||
|
@pytest.mark.multi_dut_modbus_serial
|
||||||
def test_modbus_comm_multi_dev_serial(case_tester) -> None: # type: ignore
|
def test_modbus_comm_multi_dev_serial(case_tester) -> None: # type: ignore
|
||||||
for case in case_tester.test_menu:
|
for case in case_tester.test_menu:
|
||||||
if case.attributes.get('test_env', 'multi_dut_modbus_serial') == 'multi_dut_modbus_serial':
|
if case.attributes.get('test_env', 'multi_dut_modbus_serial') == 'multi_dut_modbus_serial':
|
||||||
print(f'Test case: {case.name}')
|
print(f'Test case: {case.name}')
|
||||||
case_tester.run_multi_dev_case(case=case, reset=True)
|
case_tester.run_multi_dev_case(case=case, reset=True)
|
||||||
|
|
||||||
@pytest.mark.esp32
|
|
||||||
@pytest.mark.multi_dut_modbus_tcp
|
|
||||||
@pytest.mark.parametrize('count, config', [(2, 'ethernet')], indirect=True)
|
@pytest.mark.parametrize('count, config', [(2, 'ethernet')], indirect=True)
|
||||||
|
@pytest.mark.parametrize('target', ['esp32'], indirect=True)
|
||||||
|
@pytest.mark.multi_dut_modbus_tcp
|
||||||
def test_modbus_comm_multi_dev_tcp(case_tester) -> None: # type: ignore
|
def test_modbus_comm_multi_dev_tcp(case_tester) -> None: # type: ignore
|
||||||
for case in case_tester.test_menu:
|
for case in case_tester.test_menu:
|
||||||
if case.attributes.get('test_env', 'multi_dut_modbus_tcp') == 'multi_dut_modbus_tcp':
|
if case.attributes.get('test_env', 'multi_dut_modbus_tcp') == 'multi_dut_modbus_tcp':
|
||||||
|
@@ -1,9 +1,15 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
idf_component_register(SRCS "test_common.c"
|
idf_component_register(SRCS "test_common.c"
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
REQUIRES unity)
|
REQUIRES unity)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
set(EXTRA_COMPONENT_DIRS)
|
||||||
|
|
||||||
|
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5")
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components")
|
||||||
|
else()
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(mb_utest_lib)
|
add_subdirectory(mb_utest_lib)
|
||||||
target_link_libraries(${COMPONENT_LIB} PUBLIC mb_ut_lib)
|
target_link_libraries(${COMPONENT_LIB} PUBLIC mb_ut_lib)
|
||||||
|
@@ -1,9 +1,16 @@
|
|||||||
# This is the project CMakeLists.txt file for the test subproject
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
|
||||||
list(APPEND EXTRA_COMPONENT_DIRS "../../test_common")
|
|
||||||
list(APPEND EXTRA_COMPONENT_DIRS "../test_stubs")
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS "../../test_common" "../test_stubs")
|
||||||
|
|
||||||
|
# The workaround for the test_utils under ESP-IDF v6.0
|
||||||
|
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5")
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components")
|
||||||
|
else()
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_mb_controller_common_unit)
|
project(test_mb_controller_common_unit)
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ set(srcs "test_app_main.c"
|
|||||||
|
|
||||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||||
idf_component_register(SRCS ${srcs}
|
idf_component_register(SRCS ${srcs}
|
||||||
PRIV_REQUIRES test_stubs mocked_esp_modbus test_common cmock test_utils unity)
|
REQUIRES test_stubs mocked_esp_modbus test_common cmock test_utils unity)
|
||||||
|
|
||||||
# The workaround for WHOLE_ARCHIVE is absent in v4.4
|
# The workaround for WHOLE_ARCHIVE is absent in v4.4
|
||||||
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u mb_test_include_impl")
|
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u mb_test_include_impl")
|
||||||
|
@@ -1,11 +1,18 @@
|
|||||||
# This is the project CMakeLists.txt file for the test subproject
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
list(APPEND EXTRA_COMPONENT_DIRS "../../test_common")
|
|
||||||
list(APPEND EXTRA_COMPONENT_DIRS "../test_stubs")
|
|
||||||
|
|
||||||
#set(COMPONENTS driver esp_timer esp_event esp_netif main)
|
set(EXTRA_COMPONENT_DIRS "../../test_common" "../test_stubs")
|
||||||
|
|
||||||
|
# The workaround for the test_utils under ESP-IDF v6.0
|
||||||
|
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5")
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components")
|
||||||
|
else()
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(COMPONENTS driver esp_timer esp_event esp_netif main)
|
||||||
|
|
||||||
# list(APPEND EXTRA_COMPONENT_DIRS
|
# list(APPEND EXTRA_COMPONENT_DIRS
|
||||||
# "$ENV{IDF_PATH}/tools/mocks/lwip/"
|
# "$ENV{IDF_PATH}/tools/mocks/lwip/"
|
||||||
@@ -13,5 +20,4 @@ list(APPEND EXTRA_COMPONENT_DIRS "../test_stubs")
|
|||||||
# "$ENV{IDF_PATH}/tools/mocks/esp_timer/"
|
# "$ENV{IDF_PATH}/tools/mocks/esp_timer/"
|
||||||
# )
|
# )
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
||||||
project(test_mb_controller_mapping_unit)
|
project(test_mb_controller_mapping_unit)
|
||||||
|
@@ -1,8 +1,17 @@
|
|||||||
#This is the project CMakeLists.txt file for the test subproject
|
#This is the project CMakeLists.txt file for the test subproject
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
|
||||||
set(COMPONENTS main)
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS)
|
||||||
|
|
||||||
|
# The workaround for the test_utils under ESP-IDF v6.0
|
||||||
|
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5")
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components")
|
||||||
|
else()
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(COMPONENTS main)
|
||||||
|
|
||||||
project(mb_endianness_utils)
|
project(mb_endianness_utils)
|
||||||
|
@@ -4,9 +4,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded import Dut
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('target', ['esp32'], indirect=True)
|
||||||
#@pytest.mark.supported_targets
|
|
||||||
@pytest.mark.esp32 # test on esp32 for now
|
|
||||||
@pytest.mark.multi_dut_modbus_generic
|
@pytest.mark.multi_dut_modbus_generic
|
||||||
def test_mb_endianness_utils(dut: Dut) -> None:
|
def test_mb_endianness_utils(dut: Dut) -> None:
|
||||||
dut.run_all_single_board_cases()
|
dut.run_all_single_board_cases()
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
set(srcs "src/mb_object_stub.c")
|
set(srcs "src/mb_object_stub.c")
|
||||||
|
|
||||||
idf_component_register( SRCS ${srcs}
|
idf_component_register( SRCS ${srcs}
|
||||||
|
Reference in New Issue
Block a user