From 169e1ee88d329f5106ece29871f20f9781463795 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Filho Date: Tue, 23 Sep 2025 15:26:40 +0200 Subject: [PATCH] fix: Adjust all examples and test to use local component - Makes the name of component mqtt - Updates README - Adjust CI to build for supported idf versions - Removes qemu job --- .build-test-rules.yml | 106 ++++++++++++++++++ .gitlab-ci.yml | 103 +---------------- .gitlab/ci/build.yml | 27 +++++ .gitlab/ci/deploy.yml | 29 +++++ .gitlab/ci/docs.yml | 105 +++++++++-------- .gitlab/ci/ignore_build_warnings.txt | 5 + .gitlab/ci/test.yml | 50 +++++++++ .idf_build_apps.toml | 18 +++ .idf_ci.toml | 21 ++++ README.md | 29 +++-- docs/sphinx-known-warnings.txt | 44 ++++---- examples/custom_outbox/main/idf_component.yml | 3 + examples/mqtt5/main/idf_component.yml | 3 + examples/ssl/main/idf_component.yml | 3 + examples/ssl_ds/main/idf_component.yml | 3 + examples/ssl_ds/partitions.csv | 2 +- .../ssl_mutual_auth/main/idf_component.yml | 3 + examples/ssl_mutual_auth/sdkconfig.defaults | 1 + .../sdkconfig.defaults.esp32c5 | 1 + .../sdkconfig.defaults.esp32c6 | 1 + .../sdkconfig.defaults.esp32c61 | 1 + examples/ssl_psk/main/idf_component.yml | 3 + examples/ssl_psk/sdkconfig.defaults.esp32c5 | 1 + examples/ssl_psk/sdkconfig.defaults.esp32c6 | 1 + examples/ssl_psk/sdkconfig.defaults.esp32c61 | 1 + examples/tcp/main/idf_component.yml | 19 +++- examples/ws/main/idf_component.yml | 3 + examples/wss/main/idf_component.yml | 3 + idf_component.yml | 24 +++- pytest.ini | 28 +++++ test/.build-test-rules.yml | 19 ---- test/apps/build_test/CMakeLists.txt | 1 + test/apps/build_test/main/CMakeLists.txt | 3 +- test/apps/build_test/main/idf_component.yml | 4 + test/apps/mqtt/CMakeLists.txt | 15 ++- test/apps/mqtt/main/idf_component.yml | 5 + test/apps/mqtt5/CMakeLists.txt | 15 ++- test/apps/mqtt5/main/idf_component.yml | 4 + .../main/idf_component.yml | 3 + test/apps/publish_connect_test/sdkconfig.qemu | 23 ---- test/host/CMakeLists.txt | 20 ++-- test/host/main/CMakeLists.txt | 4 +- test/host/main/idf_component.yml | 3 + test/host/main/test_mqtt_client.cpp | 5 +- test/host/sdkconfig.defaults | 2 +- 45 files changed, 508 insertions(+), 259 deletions(-) create mode 100644 .build-test-rules.yml create mode 100644 .gitlab/ci/build.yml create mode 100644 .gitlab/ci/deploy.yml create mode 100644 .gitlab/ci/ignore_build_warnings.txt create mode 100644 .gitlab/ci/test.yml create mode 100644 .idf_build_apps.toml create mode 100644 .idf_ci.toml create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 create mode 100644 examples/ssl_psk/sdkconfig.defaults.esp32c5 create mode 100644 examples/ssl_psk/sdkconfig.defaults.esp32c6 create mode 100644 examples/ssl_psk/sdkconfig.defaults.esp32c61 create mode 100644 pytest.ini delete mode 100644 test/.build-test-rules.yml create mode 100644 test/apps/build_test/main/idf_component.yml create mode 100644 test/apps/mqtt/main/idf_component.yml create mode 100644 test/apps/mqtt5/main/idf_component.yml delete mode 100644 test/apps/publish_connect_test/sdkconfig.qemu diff --git a/.build-test-rules.yml b/.build-test-rules.yml new file mode 100644 index 0000000..a1929ad --- /dev/null +++ b/.build-test-rules.yml @@ -0,0 +1,106 @@ +# ESP-MQTT Build Test Rules +# Consolidated manifest covering all examples and test apps + +.default_rules: &default_rules + disable: + - if: IDF_TARGET in ["esp32h21", "esp32h4"] + temporary: true + reason: not supported yet + - if: IDF_TARGET in ["esp32p4", "esp32h2"] and IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 3 + temporary: true + reason: esp32p4/esp32h2 example dependencies require IDF versions other than 5.3 + disable_test: + - if: IDF_TARGET not in ["esp32"] + reason: Tests run only on ESP32 with ethernet runners + +# Basic TCP MQTT example +examples/tcp: + <<: *default_rules + +# SSL/TLS MQTT example +examples/ssl: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: CN verification enabled, tests disabled during server migration + +# WebSocket MQTT example +examples/ws: + <<: *default_rules + +# WebSocket Secure MQTT example +examples/wss: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: CN verification enabled, tests disabled during server migration + +# MQTT 5.0 protocol example +examples/mqtt5: + <<: *default_rules + +# SSL with mutual authentication +examples/ssl_mutual_auth: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +# SSL with pre-shared keys +examples/ssl_psk: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +# SSL with Digital Signature peripheral +examples/ssl_ds: + <<: *default_rules + disable: + - if: SOC_DIG_SIGN_SUPPORTED != 1 + reason: DS not present + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +# Custom outbox implementation example +examples/custom_outbox: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +test/apps: + disable: + - if: IDF_TARGET not in ["esp32"] + reason: Test apps build only for esp32 + disable_test: + - if: IDF_TARGET != "esp32" + temporary: false + reason: Only esp32 target has ethernet runners for integration tests + +# C++ compatibility build test +test/apps/build_test: + enable: + - if: IDF_TARGET in ["esp32", "esp32c3"] + reason: C++ compatibility build test + disable_test: + - if: IDF_TARGET != IDF_TARGET + temporary: false + reason: Build only test + +# Publish/Connect integration test +test/apps/publish_connect_test: + enable: + - if: IDF_TARGET in ["esp32"] + reason: Integration test for publish/connect functionality + disable_test: + - if: IDF_TARGET != "esp32" + temporary: false + reason: Only esp32 target has ethernet runners for integration tests + +# Host tests (unit tests with mocks) +test/host: + enable: + - if: IDF_TARGET in ["linux"] + reason: Host-based unit tests with mocked ESP-IDF components diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae6eabf..6ccfe31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,105 +4,8 @@ stages: - test_deploy - deploy -variables: - IDF_REPO: ${GITLAB_SSH_SERVER}/idf/esp-idf.git - -.add_gh_key_remote: &add_gh_key_remote | - cit_add_ssh_key "${GH_PUSH_KEY}" - git remote remove github || true - git remote add github ${GH_PUSH_REPO} - -before_script: - # Use CI Tools - - curl -sSL ${CIT_LOADER_URL} | sh - - source citools/import_functions - # Add gitlab ssh key - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64 - - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa - - chmod 600 ~/.ssh/id_rsa - - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - - PATH=$CI_PROJECT_DIR/esp-idf/tools:$PATH - - export MQTT_PATH=$CI_PROJECT_DIR - -.build_template: - stage: build - tags: - - build - - internet - script: - # Replace the IDF's default esp-mqtt with this version - - rm -rf $IDF_PATH/components/mqtt/esp-mqtt && cp -r $MQTT_PATH $IDF_PATH/components/mqtt/ - # Build the examples - - $MQTT_PATH/ci/build_examples.sh - -build_idf_v5.0: - extends: .build_template - image: espressif/idf:release-v5.0 - -build_idf_v5.1: - extends: .build_template - image: espressif/idf:release-v5.1 - -build_idf_v5.2: - extends: .build_template - image: espressif/idf:release-v5.2 - -build_idf_v5.3: - extends: .build_template - image: espressif/idf:release-v5.3 - -build_idf_v5.4: - extends: .build_template - image: espressif/idf:release-v5.4 - -build_idf_latest: - extends: .build_template - image: espressif/idf:latest - -build_and_host_test: - stage: build - image: espressif/idf:latest - tags: - - build - - internet - script: - # Replace the IDF's default esp-mqtt with this version - - rm -rf $IDF_PATH/components/mqtt/esp-mqtt && cp -r $MQTT_PATH $IDF_PATH/components/mqtt/ - - cd $IDF_PATH/components/mqtt/esp-mqtt/test/host - - idf.py build - - build/host_mqtt_client_test.elf - -check_remotes_sync: - stage: test_deploy - image: espressif/idf:latest - tags: - - build - - internet - except: - - master - - idf - script: - - *add_gh_key_remote - - git fetch --depth=1 origin master - - git fetch --depth=1 github master - - test "$(git rev-parse origin/master)" == "$(git rev-parse github/master)" - -push_master_to_github: - stage: deploy - image: ${CI_DOCKER_REGISTRY}/esp32-ci-env - tags: - - build - only: - - master - - idf - when: on_success - variables: - GIT_STRATEGY: clone - script: - - *add_gh_key_remote - - git push github HEAD:${CI_COMMIT_REF_NAME} - include: + - local: ".gitlab/ci/build.yml" + - local: ".gitlab/ci/test.yml" - local: ".gitlab/ci/docs.yml" + - local: ".gitlab/ci/deploy.yml" diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml new file mode 100644 index 0000000..84e536a --- /dev/null +++ b/.gitlab/ci/build.yml @@ -0,0 +1,27 @@ +# Note: No need to run build and test on master branch since we use FastForward merge strategy and so each merge request +# is tested and then merged onto top of master branch. + +.build_template: + stage: build + tags: + - build + - internet + script: + - pip install -U 'idf-ci<1' + - idf-ci build run + +build_idf_v5.3: + extends: .build_template + image: espressif/idf:release-v5.3 + +build_idf_v5.4: + extends: .build_template + image: espressif/idf:release-v5.4 + +build_idf_v5.5: + extends: .build_template + image: espressif/idf:release-v5.5 + +build_idf_latest: + extends: .build_template + image: espressif/idf:latest diff --git a/.gitlab/ci/deploy.yml b/.gitlab/ci/deploy.yml new file mode 100644 index 0000000..38920d1 --- /dev/null +++ b/.gitlab/ci/deploy.yml @@ -0,0 +1,29 @@ +push_master_to_github: + stage: deploy + image: ${CI_DOCKER_REGISTRY}/esp32-ci-env + tags: + - build + only: + refs: + - master + - idf + when: on_success + variables: + GIT_STRATEGY: clone + script: + - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh + - add_github_remote "$GH_PUSH_KEY" "$GH_PUSH_REPO" + - git push github HEAD:${CI_COMMIT_REF_NAME} + +upload_to_component_manager: + stage: deploy + image: python:3.10-alpine + tags: + - deploy + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + script: + - pip install idf-component-manager + - export IDF_COMPONENT_API_TOKEN=${MQTT_COMPONENT_API_KEY} + - export COMP_VERSION=$(grep 'version:' idf_component.yml | head -n 1 | awk '{print $2}' | tr -d '"') + - compote component upload --namespace=espressif --name=mqtt --allow-existing --version=${COMP_VERSION} diff --git a/.gitlab/ci/docs.yml b/.gitlab/ci/docs.yml index d7b24dc..5402d09 100644 --- a/.gitlab/ci/docs.yml +++ b/.gitlab/ci/docs.yml @@ -1,7 +1,7 @@ variables: - # System environment - ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.4:1-1" - ESP_DOCS_PATH: "$CI_PROJECT_DIR" + # System environment + ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.4:1-1" + ESP_DOCS_PATH: "$CI_PROJECT_DIR" docs_build: stage: build @@ -26,60 +26,57 @@ docs_build: script: - cd docs - build-docs -t esp32 -l en - rules: - - if: $CI_COMMIT_REF_NAME == "master" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" .deploy_docs_template: - image: $ESP_DOCS_ENV_IMAGE - variables: - DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" - PYTHONUNBUFFERED: 1 - # ensure all tags are fetched, need to know the latest/stable tag for the docs - GIT_STRATEGY: clone - GIT_DEPTH: 0 - stage: test_deploy - tags: - - brew - - amd64 - script: - - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh - # ensure all tags are fetched, need to know the latest/stable tag for the docs - - add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER - - export GIT_VER=$(git describe --always ${PIPELINE_COMMIT_SHA} --) - - pip install esp-docs - - deploy-docs + image: $ESP_DOCS_ENV_IMAGE + variables: + DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" + PYTHONUNBUFFERED: 1 + # ensure all tags are fetched, need to know the latest/stable tag for the docs + GIT_STRATEGY: clone + GIT_DEPTH: 0 + stage: test_deploy + tags: + - brew + - amd64 + script: + - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh + # ensure all tags are fetched, need to know the latest/stable tag for the docs + - add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER + - export GIT_VER=$(git describe --always ${PIPELINE_COMMIT_SHA} --) + - pip install esp-docs + - deploy-docs deploy_docs_preview: - extends: - - .deploy_docs_template - except: - refs: - - master - needs: - - docs_build - variables: - TYPE: "preview" - DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" - DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY" - DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER" - DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER" - DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH" - DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE" + extends: + - .deploy_docs_template + except: + refs: + - master + needs: + - docs_build + variables: + TYPE: "preview" + DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" + DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY" + DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER" + DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER" + DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH" + DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE" deploy_docs_prod: - extends: - - .deploy_docs_template - stage: deploy - only: - refs: - - master - needs: - - docs_build - variables: - TYPE: "production" - DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY" - DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER" - DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER" - DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH" - DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE" + extends: + - .deploy_docs_template + stage: deploy + only: + refs: + - master + needs: + - docs_build + variables: + TYPE: "production" + DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY" + DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER" + DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER" + DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH" + DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE" diff --git a/.gitlab/ci/ignore_build_warnings.txt b/.gitlab/ci/ignore_build_warnings.txt new file mode 100644 index 0000000..302920d --- /dev/null +++ b/.gitlab/ci/ignore_build_warnings.txt @@ -0,0 +1,5 @@ +Warning: Deprecated: Option '--flash_size' is deprecated. Use '--flash-size' instead. +Warning: Deprecated: Option '--flash_mode' is deprecated. Use '--flash-mode' instead. +Warning: Deprecated: Option '--flash_freq' is deprecated. Use '--flash-freq' instead. +Warning: Deprecated: Command 'sign_data' is deprecated. Use 'sign-data' instead. +Warning: Deprecated: Command 'extract_public_key' is deprecated. Use 'extract-public-key' instead. diff --git a/.gitlab/ci/test.yml b/.gitlab/ci/test.yml new file mode 100644 index 0000000..86725ab --- /dev/null +++ b/.gitlab/ci/test.yml @@ -0,0 +1,50 @@ +.add_gh_key_remote: &add_gh_key_remote | + curl -sSL ${CIT_LOADER_URL} | sh + source citools/import_functions + cit_add_ssh_key "${GH_PUSH_KEY}" + git remote remove github || true + git remote add github ${GH_PUSH_REPO} + +host_tests: + image: espressif/idf:latest + stage: test + tags: [build] + timeout: 1h + variables: + GIT_DEPTH: 1 + needs: [] + artifacts: + paths: + - "**/coverage.xml" + - "**/coverage.html" + expire_in: 1 week + when: always + reports: + junit: "**/junit.xml" + coverage_report: + coverage_format: cobertura + path: "**/coverage.xml" + before_script: + - pip install -U gcovr 'idf-ci<1' + script: + - idf-ci build run -t linux -p test/host + - cd test/host + - ./build_linux_coverage/host_mqtt_client_test.elf -r junit -o junit.xml + - cd ../.. + - gcovr --gcov-ignore-parse-errors -g -k -r . --html coverage.html -x coverage.xml + +check_remotes_sync: + stage: test_deploy + image: espressif/idf:latest + tags: + - build + - internet + needs: [] + except: + - master + - idf + script: + - *add_gh_key_remote + - git fetch --depth=1 origin master + - git fetch --depth=1 github master + - test "$(git rev-parse origin/master)" == "$(git rev-parse github/master)" diff --git a/.idf_build_apps.toml b/.idf_build_apps.toml new file mode 100644 index 0000000..3117396 --- /dev/null +++ b/.idf_build_apps.toml @@ -0,0 +1,18 @@ +# check the latest documentation at +# https://docs.espressif.com/projects/idf-build-apps/en/latest/references/config_file.html + +config_rules = ['sdkconfig.ci=default', 'sdkconfig.ci.*=', '=default'] + +recursive = true +check_warnings = true +keep_going = true + +build_dir = "build_@t_@w" +build_log_filename = "build.log" +size_json_filename = "size.json" + +collect_app_info_filename = "app_info_@p.txt" + +check_manifest_rules = true +manifest_filepatterns = ['**/.build-test-rules.yml'] +ignore_warning_files = ['.gitlab/ci/ignore_build_warnings.txt'] diff --git a/.idf_ci.toml b/.idf_ci.toml new file mode 100644 index 0000000..993c081 --- /dev/null +++ b/.idf_ci.toml @@ -0,0 +1,21 @@ +# ESP-MQTT idf-ci Configuration +[gitlab.artifacts] +build_job_filepatterns = [ + "**/build*/partition_table/*.bin", + "**/build*/bootloader/*.bin", + "**/build*/bootloader/*.map", + "**/build*/bootloader/*.elf", + "**/build*/config/sdkconfig.json", + "**/build*/*.map", + "**/build*/*.bin", + "**/build*/*.elf", + "**/build*/flasher_args.json", +] + +test_job_filepatterns = [ + "**/test_logs", + "**/XUNIT_RESULT_*.xml", +] + +[gitlab.build_pipeline] +runs_per_job = 15 diff --git a/README.md b/README.md index 1be44b6..f46f80b 100644 --- a/README.md +++ b/README.md @@ -15,22 +15,33 @@ ## How to use -[ESP-MQTT](https://github.com/espressif/esp-mqtt) is a standard [ESP-IDF](https://github.com/espressif/esp-idf) component. -Please refer to instructions in [ESP-IDF](https://github.com/espressif/esp-idf) +ESP-MQTT is available through the [ESP-IDF Component Manager](https://components.espressif.com/) and ships as a standard [ESP-IDF](https://github.com/espressif/esp-idf) component. + +- To add it via the Component Manager (recommended), declare the dependency in your project's `idf_component.yml`, for example: + + ```yaml + dependencies: + espressif/mqtt: "*" + ``` + + Replace `*` with the version constraint you want to track, or run `idf.py add-dependency espressif/mqtt`. +- For local development, clone this repository as `mqtt` so the component name matches: + + ```bash + git clone https://github.com/espressif/esp-mqtt.git mqtt + ``` ## Documentation -- Please refer to the standard [ESP-IDF](https://github.com/espressif/esp-idf), documentation for the latest version: - -- Documentation of ESP-MQTT API: +- Documentation of ESP-MQTT API: ## License -- MQTT Package - [Stephen Robinson - contiki-mqtt](https://github.com/esar/contiki-mqtt) -- Others [@tuanpmt](https://twitter.com/tuanpmt) -Apache License +- Apache License 2.0 +- MQTT package origin: [Stephen Robinson - contiki-mqtt](https://github.com/esar/contiki-mqtt) +- Additional contributions by [@tuanpmt](https://twitter.com/tuanpmt) -## Older IDF verisons +## Older IDF versions For [ESP-IDF](https://github.com/espressif/esp-idf) versions prior to IDFv3.2, please clone as a component of [ESP-IDF](https://github.com/espressif/esp-idf): diff --git a/docs/sphinx-known-warnings.txt b/docs/sphinx-known-warnings.txt index 1746fa1..cff318d 100644 --- a/docs/sphinx-known-warnings.txt +++ b/docs/sphinx-known-warnings.txt @@ -1,37 +1,37 @@ mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:type:: struct esp_mqtt_event_t esp_mqtt_event_t'. +Declaration is '.. cpp:type:: struct esp_mqtt_event_t esp_mqtt_event_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:type:: struct esp_mqtt_client_config_t esp_mqtt_client_config_t'. +Declaration is '.. cpp:type:: struct esp_mqtt_client_config_t esp_mqtt_client_config_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_event_id_t'. +Declaration is '.. cpp:enum:: esp_mqtt_event_id_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_connect_return_code_t'. +Declaration is '.. cpp:enum:: esp_mqtt_connect_return_code_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_error_type_t'. +Declaration is '.. cpp:enum:: esp_mqtt_error_type_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_transport_t'. +Declaration is '.. cpp:enum:: esp_mqtt_transport_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_protocol_ver_t'. +Declaration is '.. cpp:enum:: esp_mqtt_protocol_ver_t'. mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: undefined label: 'config_mqtt_outbox_expired_timeout_ms' -index.rst:line: WARNING: undefined label: 'config_mqtt_report_deleted_messages' -index.rst:line: WARNING: undefined label: 'esp_tls_server_verification' -index.rst:line: WARNING: undefined label: 'config_mqtt_protocol_311' -index.rst:line: WARNING: undefined label: 'config_mqtt_transport_ssl' -index.rst:line: WARNING: undefined label: 'config_mqtt_transport_websocket' -index.rst:line: WARNING: undefined label: 'config_mqtt_custom_outbox' +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: undefined label: 'config_mqtt_outbox_expired_timeout_ms' +index.rst:line: WARNING: undefined label: 'config_mqtt_report_deleted_messages' +index.rst:line: WARNING: undefined label: 'esp_tls_server_verification' +index.rst:line: WARNING: undefined label: 'config_mqtt_protocol_311' +index.rst:line: WARNING: undefined label: 'config_mqtt_transport_ssl' +index.rst:line: WARNING: undefined label: 'config_mqtt_transport_websocket' +index.rst:line: WARNING: undefined label: 'config_mqtt_custom_outbox' diff --git a/examples/custom_outbox/main/idf_component.yml b/examples/custom_outbox/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/custom_outbox/main/idf_component.yml +++ b/examples/custom_outbox/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/mqtt5/main/idf_component.yml b/examples/mqtt5/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/mqtt5/main/idf_component.yml +++ b/examples/mqtt5/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl/main/idf_component.yml b/examples/ssl/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ssl/main/idf_component.yml +++ b/examples/ssl/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_ds/main/idf_component.yml b/examples/ssl_ds/main/idf_component.yml index 947ec18..d6ee923 100644 --- a/examples/ssl_ds/main/idf_component.yml +++ b/examples/ssl_ds/main/idf_component.yml @@ -3,3 +3,6 @@ dependencies: espressif/esp_secure_cert_mgr: "^2.0.2" protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_ds/partitions.csv b/examples/ssl_ds/partitions.csv index 0c4ad77..1423949 100644 --- a/examples/ssl_ds/partitions.csv +++ b/examples/ssl_ds/partitions.csv @@ -3,4 +3,4 @@ esp_secure_cert,0x3F,,,0x2000, nvs,data,nvs,,24K, phy_init,data,phy,,4K, -factory,app,factory,0x20000,1M, +factory,app,factory,0x20000,1500K, diff --git a/examples/ssl_mutual_auth/main/idf_component.yml b/examples/ssl_mutual_auth/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ssl_mutual_auth/main/idf_component.yml +++ b/examples/ssl_mutual_auth/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults b/examples/ssl_mutual_auth/sdkconfig.defaults new file mode 100644 index 0000000..99d3178 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults @@ -0,0 +1 @@ +# Empty file to trigger idf-ci to use esp32c6 specific file. diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_psk/main/idf_component.yml b/examples/ssl_psk/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ssl_psk/main/idf_component.yml +++ b/examples/ssl_psk/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_psk/sdkconfig.defaults.esp32c5 b/examples/ssl_psk/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_psk/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_psk/sdkconfig.defaults.esp32c6 b/examples/ssl_psk/sdkconfig.defaults.esp32c6 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_psk/sdkconfig.defaults.esp32c6 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_psk/sdkconfig.defaults.esp32c61 b/examples/ssl_psk/sdkconfig.defaults.esp32c61 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_psk/sdkconfig.defaults.esp32c61 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/tcp/main/idf_component.yml b/examples/tcp/main/idf_component.yml index 59805d8..c47068c 100644 --- a/examples/tcp/main/idf_component.yml +++ b/examples/tcp/main/idf_component.yml @@ -1,7 +1,14 @@ dependencies: - protocol_examples_common: - path: ${IDF_PATH}/examples/common_components/protocol_examples_common - espressif/esp_wifi_remote: - version: ">=0.10,<2.0" - rules: - - if: "target in [esp32p4, esp32h2]" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: ../../.. + espressif/esp_wifi_remote: + version: ">=0.10,<2.0" + rules: + - if: target in [esp32p4, esp32h2] + espressif/esp_hosted: + version: "2.5.1" + rules: + - if: target in [esp32p4, esp32h2] diff --git a/examples/ws/main/idf_component.yml b/examples/ws/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ws/main/idf_component.yml +++ b/examples/ws/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/wss/main/idf_component.yml b/examples/wss/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/wss/main/idf_component.yml +++ b/examples/wss/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/idf_component.yml b/idf_component.yml index 23cec31..adf10f4 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,5 +1,23 @@ +name: mqtt version: "1.0.0" -description: esp-mqtt +description: "ESP-MQTT - A robust MQTT client library for ESP32 microcontrollers supporting MQTT 3.1.1 and 5.0 protocols with multiple transport layers" +url: "https://github.com/espressif/esp-mqtt" +documentation: "https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/mqtt.html" +repository: "https://github.com/espressif/esp-mqtt" +issues: "https://github.com/espressif/esp-mqtt/issues" +license: "Apache-2.0" + +maintainers: + - "Espressif Systems " + +tags: + - mqtt + - mqtt5 + - protocol + - networking + dependencies: - idf: - version: ">=5.0" + idf: + version: ">=5.3" + + diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..3bbea53 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,28 @@ +[pytest] +python_files = pytest_*.py +addopts = + --embedded-services esp,idf + --ignore-no-tests-collected-error + --ignore-glob */managed_components/* + --ignore=examples/ssl + --ignore=examples/wss + --junitxml=junit.xml + --ignore-result-files .gitlab/ignored_cases.txt + --root-logdir=test_logs + +filterwarnings = + ignore::FutureWarning + +junit_family = xunit1 + +env_markers = + eth_ip101: Ethernet IP101 PHY required for test + eth_ip101_stress: Ethernet IP101 PHY required for stress test + generic: applicable to generic ESP devices + +# log related +log_cli = True +log_cli_level = INFO +log_cli_format = %(asctime)s %(levelname)s %(message)s +log_cli_date_format = %Y-%m-%d %H:%M:%S + diff --git a/test/.build-test-rules.yml b/test/.build-test-rules.yml deleted file mode 100644 index 2e58826..0000000 --- a/test/.build-test-rules.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps - -components/mqtt/test_apps: - disable: - - if: IDF_TARGET not in ["esp32", "esp32c3"] - reason: component test apps, needn't build all targets (chosen two, one for each architecture) - disable_test: - - if: IDF_TARGET != "esp32" - temporary: false - reason: Only esp32 target has ethernet runners - depends_components: - - mqtt - - tcp_transport - - app_update - - esp_eth - - esp_netif - - esp_event - depends_filepatterns: - - components/mqtt/test_apps/common/**/* diff --git a/test/apps/build_test/CMakeLists.txt b/test/apps/build_test/CMakeLists.txt index 7dd960d..8cf5bd5 100644 --- a/test/apps/build_test/CMakeLists.txt +++ b/test/apps/build_test/CMakeLists.txt @@ -7,4 +7,5 @@ cmake_minimum_required(VERSION 3.16) set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +idf_build_set_property(MINIMAL_BUILD ON) project(mqtt_tcp) diff --git a/test/apps/build_test/main/CMakeLists.txt b/test/apps/build_test/main/CMakeLists.txt index 2e8369c..b66769f 100644 --- a/test/apps/build_test/main/CMakeLists.txt +++ b/test/apps/build_test/main/CMakeLists.txt @@ -1,3 +1,4 @@ idf_component_register(SRCS "mqtt_app.cpp" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + PRIV_REQUIRES nvs_flash esp_netif) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/test/apps/build_test/main/idf_component.yml b/test/apps/build_test/main/idf_component.yml new file mode 100644 index 0000000..1b39baa --- /dev/null +++ b/test/apps/build_test/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/mqtt: + version: "*" + override_path: "../../../.." \ No newline at end of file diff --git a/test/apps/mqtt/CMakeLists.txt b/test/apps/mqtt/CMakeLists.txt index bc86bdb..8a68117 100644 --- a/test/apps/mqtt/CMakeLists.txt +++ b/test/apps/mqtt/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" - "../common") - -set(COMPONENTS main) include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +set(EXTRA_COMPONENT_DIRS "../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() + + +idf_build_set_property(MINIMAL_BUILD ON) project(esp_mqtt_client_test) diff --git a/test/apps/mqtt/main/idf_component.yml b/test/apps/mqtt/main/idf_component.yml new file mode 100644 index 0000000..30ca4ee --- /dev/null +++ b/test/apps/mqtt/main/idf_component.yml @@ -0,0 +1,5 @@ +dependencies: + espressif/mqtt: + version: "*" + override_path: "../../../.." + diff --git a/test/apps/mqtt5/CMakeLists.txt b/test/apps/mqtt5/CMakeLists.txt index 1c7881c..6b8e1e8 100644 --- a/test/apps/mqtt5/CMakeLists.txt +++ b/test/apps/mqtt5/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" - "../common") - -set(COMPONENTS main) include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +set(EXTRA_COMPONENT_DIRS "../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() + + +idf_build_set_property(MINIMAL_BUILD ON) project(esp_mqtt5_client_test) diff --git a/test/apps/mqtt5/main/idf_component.yml b/test/apps/mqtt5/main/idf_component.yml new file mode 100644 index 0000000..1b39baa --- /dev/null +++ b/test/apps/mqtt5/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/mqtt: + version: "*" + override_path: "../../../.." \ No newline at end of file diff --git a/test/apps/publish_connect_test/main/idf_component.yml b/test/apps/publish_connect_test/main/idf_component.yml index 5d8a7d6..bbc39b0 100644 --- a/test/apps/publish_connect_test/main/idf_component.yml +++ b/test/apps/publish_connect_test/main/idf_component.yml @@ -4,5 +4,8 @@ dependencies: version: ">=2.0.20" protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../../.." idf: version: ">=4.1.0" diff --git a/test/apps/publish_connect_test/sdkconfig.qemu b/test/apps/publish_connect_test/sdkconfig.qemu deleted file mode 100644 index 62d7f5b..0000000 --- a/test/apps/publish_connect_test/sdkconfig.qemu +++ /dev/null @@ -1,23 +0,0 @@ -CONFIG_IDF_TARGET_ESP32=y -CONFIG_EXAMPLE_USE_OPENETH=y -CONFIG_ETH_USE_OPENETH=y -CONFIG_ETH_OPENETH_DMA_RX_BUFFER_NUM=4 -CONFIG_ETH_OPENETH_DMA_TX_BUFFER_NUM=1 -CONFIG_EXAMPLE_CONNECT_ETHERNET=y -CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y -CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y -CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=16384 -CONFIG_EXAMPLE_BROKER_SSL_URI="mqtts://${EXAMPLE_MQTT_BROKER_SSL}" -CONFIG_EXAMPLE_BROKER_TCP_URI="mqtt://${EXAMPLE_MQTT_BROKER_TCP}" -CONFIG_EXAMPLE_BROKER_WS_URI="ws://${EXAMPLE_MQTT_BROKER_WS}/ws" -CONFIG_EXAMPLE_BROKER_WSS_URI="wss://${EXAMPLE_MQTT_BROKER_WSS}/ws" -CONFIG_EXAMPLE_BROKER_CERTIFICATE_OVERRIDE="${EXAMPLE_MQTT_BROKER_CERTIFICATE}" -CONFIG_MBEDTLS_HARDWARE_AES=n -CONFIG_MBEDTLS_HARDWARE_MPI=n -CONFIG_MBEDTLS_HARDWARE_SHA=n -CONFIG_ETH_USE_SPI_ETHERNET=n -CONFIG_EXAMPLE_CONNECT_WIFI=n -CONFIG_ESP_TLS_INSECURE=y -CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y diff --git a/test/host/CMakeLists.txt b/test/host/CMakeLists.txt index b2b4aba..4b4b5d4 100644 --- a/test/host/CMakeLists.txt +++ b/test/host/CMakeLists.txt @@ -1,15 +1,17 @@ +# The following four 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) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(COMPONENTS mqtt main) +idf_build_set_property(MINIMAL_BUILD ON) list(APPEND EXTRA_COMPONENT_DIRS - "$ENV{IDF_PATH}/tools/mocks/esp_hw_support/" - "$ENV{IDF_PATH}/tools/mocks/freertos/" - "$ENV{IDF_PATH}/tools/mocks/esp_timer/" - "$ENV{IDF_PATH}/tools/mocks/esp_event/" - "$ENV{IDF_PATH}/tools/mocks/lwip/" - "$ENV{IDF_PATH}/tools/mocks/esp-tls/" - "$ENV{IDF_PATH}/tools/mocks/http_parser/" - "$ENV{IDF_PATH}/tools/mocks/tcp_transport/") + "$ENV{IDF_PATH}/tools/mocks/esp_hw_support/" + "$ENV{IDF_PATH}/tools/mocks/freertos/" + "$ENV{IDF_PATH}/tools/mocks/esp_timer/" + "$ENV{IDF_PATH}/tools/mocks/esp_event/" + "$ENV{IDF_PATH}/tools/mocks/lwip/" + "$ENV{IDF_PATH}/tools/mocks/esp-tls/" + "$ENV{IDF_PATH}/tools/mocks/http_parser/" + "$ENV{IDF_PATH}/tools/mocks/tcp_transport/") project(host_mqtt_client_test) diff --git a/test/host/main/CMakeLists.txt b/test/host/main/CMakeLists.txt index 9e5347b..e258192 100644 --- a/test/host/main/CMakeLists.txt +++ b/test/host/main/CMakeLists.txt @@ -2,13 +2,13 @@ idf_component_register(SRCS "test_mqtt_client.cpp" REQUIRES cmock mqtt esp_timer esp_hw_support http_parser log WHOLE_ARCHIVE) -target_compile_options(${COMPONENT_LIB} PUBLIC -fsanitize=address -fconcepts) +target_compile_options(${COMPONENT_LIB} PUBLIC -fsanitize=address -Wno-missing-field-initializers) target_link_options(${COMPONENT_LIB} PUBLIC -fsanitize=address) target_link_libraries(${COMPONENT_LIB} PUBLIC Catch2::Catch2WithMain) idf_component_get_property(mqtt mqtt COMPONENT_LIB) target_compile_definitions(${mqtt} PRIVATE SOC_WIFI_SUPPORTED=1) -target_compile_options(${mqtt} PUBLIC -fsanitize=address -fconcepts) +target_compile_options(${mqtt} PUBLIC -fsanitize=address) target_link_options(${mqtt} PUBLIC -fsanitize=address) if(CONFIG_GCOV_ENABLED) diff --git a/test/host/main/idf_component.yml b/test/host/main/idf_component.yml index 6efd693..77d7483 100644 --- a/test/host/main/idf_component.yml +++ b/test/host/main/idf_component.yml @@ -1,6 +1,9 @@ ## IDF Component Manager Manifest File dependencies: espressif/catch2: "^3.5.2" + espressif/mqtt: + version: "*" + override_path: "../../.." ## Required IDF version idf: version: ">=5.0.0" diff --git a/test/host/main/test_mqtt_client.cpp b/test/host/main/test_mqtt_client.cpp index 8963df0..a5dc05c 100644 --- a/test/host/main/test_mqtt_client.cpp +++ b/test/host/main/test_mqtt_client.cpp @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include #include @@ -120,7 +121,9 @@ SCENARIO("MQTT Client Operation") SECTION("User set interface to use"){ http_parser_parse_url_ExpectAnyArgsAndReturn(0); http_parser_parse_url_ReturnThruPtr_u(&ret_uri); - struct ifreq if_name = {.ifr_ifrn = {"custom"}}; + struct ifreq if_name = {}; + strncpy(if_name.ifr_name, "custom", IFNAMSIZ - 1); + if_name.ifr_name[IFNAMSIZ - 1] = '\0';; config.network.if_name = &if_name; SECTION("Client is not started"){ REQUIRE(esp_mqtt_set_config(client.get(), &config)== ESP_OK); diff --git a/test/host/sdkconfig.defaults b/test/host/sdkconfig.defaults index c126429..d86d082 100644 --- a/test/host/sdkconfig.defaults +++ b/test/host/sdkconfig.defaults @@ -2,5 +2,5 @@ CONFIG_IDF_TARGET="linux" CONFIG_COMPILER_CXX_EXCEPTIONS=y CONFIG_COMPILER_CXX_RTTI=y CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 -CONFIG_COMPILER_STACK_CHECK_NONE=y +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n