diff --git a/examples/serial/mb_serial_master/CMakeLists.txt b/examples/serial/mb_serial_master/CMakeLists.txt index 6245125..ae277a9 100644 --- a/examples/serial/mb_serial_master/CMakeLists.txt +++ b/examples/serial/mb_serial_master/CMakeLists.txt @@ -1,6 +1,6 @@ # The following lines of boilerplate have to be in your project's CMakeLists # 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 set(EXCLUDE_COMPONENTS freemodbus) diff --git a/examples/serial/mb_serial_slave/CMakeLists.txt b/examples/serial/mb_serial_slave/CMakeLists.txt index 2b26eba..b7b33b9 100644 --- a/examples/serial/mb_serial_slave/CMakeLists.txt +++ b/examples/serial/mb_serial_slave/CMakeLists.txt @@ -1,6 +1,6 @@ # The following lines of boilerplate have to be in your project's CMakeLists # 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 set(EXCLUDE_COMPONENTS freemodbus) diff --git a/examples/tcp/mb_tcp_master/CMakeLists.txt b/examples/tcp/mb_tcp_master/CMakeLists.txt index 6c24ee8..8dd1e97 100644 --- a/examples/tcp/mb_tcp_master/CMakeLists.txt +++ b/examples/tcp/mb_tcp_master/CMakeLists.txt @@ -1,6 +1,6 @@ # The following lines of boilerplate have to be in your project's CMakeLists # 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) diff --git a/test_apps/adapter_tests/CMakeLists.txt b/test_apps/adapter_tests/CMakeLists.txt index 391abd1..b45ea58 100644 --- a/test_apps/adapter_tests/CMakeLists.txt +++ b/test_apps/adapter_tests/CMakeLists.txt @@ -1,8 +1,14 @@ # This is the project CMakeLists.txt file for the test subproject -cmake_minimum_required(VERSION 3.16) - -set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") -list(APPEND EXTRA_COMPONENT_DIRS "../test_common") +cmake_minimum_required(VERSION 3.22) 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) diff --git a/test_apps/adapter_tests/main/CMakeLists.txt b/test_apps/adapter_tests/main/CMakeLists.txt index d933967..c249a41 100644 --- a/test_apps/adapter_tests/main/CMakeLists.txt +++ b/test_apps/adapter_tests/main/CMakeLists.txt @@ -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, idf_component_register(SRCS ${srcs} 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_tcp") diff --git a/test_apps/adapter_tests/pytest_mb_comm_adapter.py b/test_apps/adapter_tests/pytest_mb_comm_adapter.py index 76c9ddc..876bdf1 100644 --- a/test_apps/adapter_tests/pytest_mb_comm_adapter.py +++ b/test_apps/adapter_tests/pytest_mb_comm_adapter.py @@ -4,14 +4,8 @@ import pytest from pytest_embedded import Dut - -CONFIGS = [ - 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.parametrize('target', ['esp32'], indirect=True) +@pytest.mark.parametrize('config', ['serial','tcp'], indirect=True) @pytest.mark.multi_dut_modbus_generic -@pytest.mark.parametrize('config', CONFIGS, indirect=True) def test_modbus_comm_adapter(dut: Dut) -> None: dut.expect_unity_test_output() diff --git a/test_apps/cpp/modbus_serial_cpp_test/main/serial_test.cpp b/test_apps/cpp/modbus_serial_cpp_test/main/serial_test.cpp index 7ec46dc..39f0a4f 100644 --- a/test_apps/cpp/modbus_serial_cpp_test/main/serial_test.cpp +++ b/test_apps/cpp/modbus_serial_cpp_test/main/serial_test.cpp @@ -3,11 +3,12 @@ #include "sdkconfig.h" #include "mbcontroller.h" -#define TEST_PORT_NUM (uart_port_t)1 -#define TEST_SPEED 115200 +#define TEST_PORT_NUM (uart_port_t)1 +#define TEST_SPEED 115200 #define TAG "CPP_TEST" -#define MB_SLAVE_SHORT_ADDRESS 1 +#define MB_SLAVE_SHORT_ADDRESS 1 +#define MB_FUNC_CODE_MAX 42 enum { MB_DEVICE_ADDR1 = 1 @@ -120,12 +121,18 @@ static int check_custom_handlers(void *inst) MB_RETURN_ON_FALSE((err == ESP_OK), 0, TAG, "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); - for (entry = 0x01; entry < CONFIG_FMB_FUNC_HANDLERS_MAX; entry++) { - // Try to remove the handler + for (entry = 0x01; entry < MB_FUNC_CODE_MAX; entry++) { + // Try to remove the handlers err = mbc_delete_handler(inst, (uint8_t)entry); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Could not remove handler for command: (0x%x), returned (0x%x), already empty?", entry, (int)err); + if (err == ESP_OK) { + 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); if (err != ESP_OK) { ESP_LOGE(TAG,"Could not set handler for command 0x%x, returned (0x%x).", entry, (int)err); diff --git a/test_apps/cpp/modbus_serial_cpp_test/pytest_cpp_mb_serial_master_slave.py b/test_apps/cpp/modbus_serial_cpp_test/pytest_cpp_mb_serial_master_slave.py index 38cdbaa..10d446c 100644 --- a/test_apps/cpp/modbus_serial_cpp_test/pytest_cpp_mb_serial_master_slave.py +++ b/test_apps/cpp/modbus_serial_cpp_test/pytest_cpp_mb_serial_master_slave.py @@ -3,10 +3,10 @@ import pytest from pytest_embedded import Dut -MB_APP_WAIT_TOUT_SEC = 10 +MB_APP_WAIT_TOUT_SEC = 30 -@pytest.mark.esp32 -@pytest.mark.generic +@pytest.mark.parametrize('target', ['esp32'], indirect=True) +@pytest.mark.multi_dut_modbus_generic def test_cpp_mb_serial_master_slave(dut: Dut) -> None: dut.expect('Setup master cpp....') dut.expect('Modbus master stack initialized...', timeout=MB_APP_WAIT_TOUT_SEC) diff --git a/test_apps/physical_tests/CMakeLists.txt b/test_apps/physical_tests/CMakeLists.txt index 5f208ff..8170ace 100644 --- a/test_apps/physical_tests/CMakeLists.txt +++ b/test_apps/physical_tests/CMakeLists.txt @@ -1,8 +1,15 @@ # This is the project CMakeLists.txt file for the test subproject -cmake_minimum_required(VERSION 3.16) - -set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") -list(APPEND EXTRA_COMPONENT_DIRS "../test_common") +cmake_minimum_required(VERSION 3.22) 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) diff --git a/test_apps/physical_tests/pytest_mb_comm_multi_dev.py b/test_apps/physical_tests/pytest_mb_comm_multi_dev.py index 832753a..e3d7cef 100644 --- a/test_apps/physical_tests/pytest_mb_comm_multi_dev.py +++ b/test_apps/physical_tests/pytest_mb_comm_multi_dev.py @@ -4,18 +4,18 @@ import pytest from pytest_embedded_idf import CaseTester -@pytest.mark.esp32 -@pytest.mark.multi_dut_modbus_serial +@pytest.mark.parametrize('target', ['esp32'], 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 for case in case_tester.test_menu: if case.attributes.get('test_env', 'multi_dut_modbus_serial') == 'multi_dut_modbus_serial': print(f'Test case: {case.name}') 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('target', ['esp32'], indirect=True) +@pytest.mark.multi_dut_modbus_tcp def test_modbus_comm_multi_dev_tcp(case_tester) -> None: # type: ignore for case in case_tester.test_menu: if case.attributes.get('test_env', 'multi_dut_modbus_tcp') == 'multi_dut_modbus_tcp': diff --git a/test_apps/test_common/CMakeLists.txt b/test_apps/test_common/CMakeLists.txt index bc347b1..7a6fd90 100644 --- a/test_apps/test_common/CMakeLists.txt +++ b/test_apps/test_common/CMakeLists.txt @@ -1,9 +1,15 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.22) idf_component_register(SRCS "test_common.c" INCLUDE_DIRS "include" 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) target_link_libraries(${COMPONENT_LIB} PUBLIC mb_ut_lib) diff --git a/test_apps/unit_tests/mb_controller_common/CMakeLists.txt b/test_apps/unit_tests/mb_controller_common/CMakeLists.txt index 79c2793..5cccb36 100644 --- a/test_apps/unit_tests/mb_controller_common/CMakeLists.txt +++ b/test_apps/unit_tests/mb_controller_common/CMakeLists.txt @@ -1,9 +1,16 @@ # This is the project CMakeLists.txt file for the test subproject -cmake_minimum_required(VERSION 3.16) - -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") +cmake_minimum_required(VERSION 3.22) 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) + diff --git a/test_apps/unit_tests/mb_controller_common/main/CMakeLists.txt b/test_apps/unit_tests/mb_controller_common/main/CMakeLists.txt index d1bb8b3..6edab80 100644 --- a/test_apps/unit_tests/mb_controller_common/main/CMakeLists.txt +++ b/test_apps/unit_tests/mb_controller_common/main/CMakeLists.txt @@ -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, 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 set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u mb_test_include_impl") diff --git a/test_apps/unit_tests/mb_controller_mapping/CMakeLists.txt b/test_apps/unit_tests/mb_controller_mapping/CMakeLists.txt index 1272dd2..a44ac15 100644 --- a/test_apps/unit_tests/mb_controller_mapping/CMakeLists.txt +++ b/test_apps/unit_tests/mb_controller_mapping/CMakeLists.txt @@ -1,11 +1,18 @@ # 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) -#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 # "$ENV{IDF_PATH}/tools/mocks/lwip/" @@ -13,5 +20,4 @@ list(APPEND EXTRA_COMPONENT_DIRS "../test_stubs") # "$ENV{IDF_PATH}/tools/mocks/esp_timer/" # ) -include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(test_mb_controller_mapping_unit) diff --git a/test_apps/unit_tests/mb_ext_types/CMakeLists.txt b/test_apps/unit_tests/mb_ext_types/CMakeLists.txt index e880dea..de1429f 100644 --- a/test_apps/unit_tests/mb_ext_types/CMakeLists.txt +++ b/test_apps/unit_tests/mb_ext_types/CMakeLists.txt @@ -1,8 +1,17 @@ #This is the project CMakeLists.txt file for the test subproject -cmake_minimum_required(VERSION 3.16) - -set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") -set(COMPONENTS main) +cmake_minimum_required(VERSION 3.22) 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) diff --git a/test_apps/unit_tests/mb_ext_types/pytest_mb_endianness_utils.py b/test_apps/unit_tests/mb_ext_types/pytest_mb_endianness_utils.py index 80f69b3..d29aa85 100644 --- a/test_apps/unit_tests/mb_ext_types/pytest_mb_endianness_utils.py +++ b/test_apps/unit_tests/mb_ext_types/pytest_mb_endianness_utils.py @@ -4,9 +4,7 @@ import pytest from pytest_embedded import Dut - -#@pytest.mark.supported_targets -@pytest.mark.esp32 # test on esp32 for now +@pytest.mark.parametrize('target', ['esp32'], indirect=True) @pytest.mark.multi_dut_modbus_generic def test_mb_endianness_utils(dut: Dut) -> None: dut.run_all_single_board_cases() diff --git a/test_apps/unit_tests/test_stubs/CMakeLists.txt b/test_apps/unit_tests/test_stubs/CMakeLists.txt index cf9fd3d..28f374c 100644 --- a/test_apps/unit_tests/test_stubs/CMakeLists.txt +++ b/test_apps/unit_tests/test_stubs/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.22) set(srcs "src/mb_object_stub.c") idf_component_register( SRCS ${srcs}