Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions .github/workflows/asio__build-target-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ jobs:
name: Build
strategy:
matrix:
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4"]
idf_ver: ["latest", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4", "release-v5.5", "release-v6.0"]
idf_target: ["esp32", "esp32s2"]
example: ["asio_chat", "async_request", "socks4", "ssl_client_server", "tcp_echo_server", "udp_echo_server"]
example: ["asio_chat", "async_request", "socks4", "ssl_client_server", "tcp_echo_server", "udp_echo_server", "unit"]
runs-on: ubuntu-22.04
container: espressif/idf:${{ matrix.idf_ver }}
env:
TEST_DIR: components/asio/examples
APP_DIR: ${{ matrix.example == 'unit' && 'components/asio/tests/unit' || format('components/asio/examples/{0}', matrix.example) }}
steps:
- name: Checkout esp-protocols
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build ${{ matrix.example }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
working-directory: ${{ env.TEST_DIR }}/${{ matrix.example }}
working-directory: ${{ env.APP_DIR }}
env:
IDF_TARGET: ${{ matrix.idf_target }}
shell: bash
Expand All @@ -35,25 +35,12 @@ jobs:
test -f sdkconfig.ci && cat sdkconfig.ci >> sdkconfig.defaults || echo "No sdkconfig.ci"
idf.py set-target ${{ matrix.idf_target }}
idf.py build
- name: Merge binaries with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }} for ${{ matrix.example }}
working-directory: ${{ env.TEST_DIR }}/${{ matrix.example }}/build
env:
IDF_TARGET: ${{ matrix.idf_target }}
shell: bash
run: |
. ${IDF_PATH}/export.sh
esptool.py --chip ${{ matrix.idf_target }} merge_bin --fill-flash-size 4MB -o flash_image.bin @flash_args
$GITHUB_WORKSPACE/ci/clean_build_artifacts.sh `pwd`/build
zip -qur artifacts.zip build
- uses: actions/upload-artifact@v4
with:
name: examples_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.example }}
path: |
${{ env.TEST_DIR }}/${{ matrix.example }}/build/bootloader/bootloader.bin
${{ env.TEST_DIR }}/${{ matrix.example }}/build//partition_table/partition-table.bin
${{ env.TEST_DIR }}/${{ matrix.example }}/build/*.bin
${{ env.TEST_DIR }}/${{ matrix.example }}/build/*.elf
${{ env.TEST_DIR }}/${{ matrix.example }}/build/flasher_args.json
${{ env.TEST_DIR }}/${{ matrix.example }}/build/config/sdkconfig.h
${{ env.TEST_DIR }}/${{ matrix.example }}/build/config/sdkconfig.json
path: ${{ env.APP_DIR }}/artifacts.zip
if-no-files-found: error

target_tests_asio:
Expand All @@ -64,25 +51,25 @@ jobs:
name: Target tests
strategy:
matrix:
idf_ver: ["latest", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4"]
idf_ver: ["latest", "release-v5.3", "release-v5.4", "release-v5.5", "release-v6.0"]
idf_target: ["esp32"]
example: ["asio_chat", "tcp_echo_server", "udp_echo_server", "ssl_client_server"]
example: ["asio_chat", "tcp_echo_server", "udp_echo_server", "ssl_client_server", "unit"]
needs: build_asio
runs-on:
- self-hosted
- ESP32-ETHERNET-KIT
env:
TEST_DIR: components/asio/examples
APP_DIR: ${{ matrix.example == 'unit' && 'components/asio/tests/unit' || format('components/asio/examples/{0}', matrix.example) }}
steps:
- name: Clear repository
run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: examples_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.example }}
path: ${{ env.TEST_DIR }}/${{ matrix.example }}/build
path: ${{ env.APP_DIR }}
- name: Run Example Test ${{ matrix.example }} on target
working-directory: ${{ env.TEST_DIR }}/${{ matrix.example }}
working-directory: ${{ env.APP_DIR }}
run: |
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
Expand All @@ -98,9 +85,10 @@ jobs:
fi
pyenv activate myenv
python --version
unzip artifacts.zip -d .
python -m pytest --log-cli-level DEBUG --junit-xml=./examples_results_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.config }}.xml --target=${{ matrix.idf_target }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: examples_results_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.example }}
path: ${{ env.TEST_DIR }}/${{ matrix.example }}/*.xml
path: ${{ env.APP_DIR }}/*.xml
2 changes: 1 addition & 1 deletion components/asio/.cz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ commitizen:
bump_message: 'bump(asio): $current_version -> $new_version'
pre_bump_hooks: python ../../ci/changelog.py asio
tag_format: asio-v$version
version: 1.32.0
version: 1.32.0~1
version_files:
- idf_component.yml
19 changes: 19 additions & 0 deletions components/asio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## [1.32.0~1](https://github.com/espressif/esp-protocols/commits/asio-v1.32.0_1)

### Features

- Add mbedtls specific APIs to use TLS stack specific features ([ad94cc95](https://github.com/espressif/esp-protocols/commit/ad94cc95))

### Bug Fixes

- Add a simple unit test to check the leaks ([c3b01688](https://github.com/espressif/esp-protocols/commit/c3b01688))
- Use mbedtls-v4 API (PSA-crypto support) ([a465ad41](https://github.com/espressif/esp-protocols/commit/a465ad41))
- memory leaks over ssl::stream lifetime ([d33cb616](https://github.com/espressif/esp-protocols/commit/d33cb616))
- Fix picolib missing pthread_sigmask() declaration ([25d54efd](https://github.com/espressif/esp-protocols/commit/25d54efd))
- Fixed TLS server-client example failure per cert expiry ([4885d282](https://github.com/espressif/esp-protocols/commit/4885d282))

### Updated

- change mbedtls_*_free destruction order ([9590aecc](https://github.com/espressif/esp-protocols/commit/9590aecc))
- chore(asio): Fixed formatting ([ff5d6021](https://github.com/espressif/esp-protocols/commit/ff5d6021))

## [1.32.0](https://github.com/espressif/esp-protocols/commits/asio-v1.32.0)

### Features
Expand Down
2 changes: 1 addition & 1 deletion components/asio/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.32.0"
version: "1.32.0~1"
description: Cross-platform C++ library for network and I/O programming
url: https://github.com/espressif/esp-protocols/tree/master/components/asio
issues: https://github.com/espressif/esp-protocols/issues
Expand Down
15 changes: 15 additions & 0 deletions components/asio/tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "6.0")
set(test_component_dir $ENV{IDF_PATH}/tools/test_apps/components)
else()
set(test_component_dir $ENV{IDF_PATH}/tools/unit-test-app/components)
endif()

set(EXTRA_COMPONENT_DIRS ../..
${test_component_dir})

project(asio_ssl_unit_test)
4 changes: 4 additions & 0 deletions components/asio/tests/unit/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
idf_component_register(SRCS "test_asio_ssl.cpp"
# REQUIRES test_utils
INCLUDE_DIRS ".")
# PRIV_REQUIRES unity asio)
5 changes: 5 additions & 0 deletions components/asio/tests/unit/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies:
idf: ">=5.1"
espressif/asio:
version: "^1.14.1"
override_path: "../../../"
65 changes: 65 additions & 0 deletions components/asio/tests/unit/main/test_asio_ssl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/

#include "unity.h"
extern "C" // workaround for unity headers (possibly) without C++ guards
{
#include "unity_fixture.h"
}
#include "test_utils.h"
#include "memory_checks.h"
#include "esp_netif.h"
#include "esp_event.h"

#include "asio.hpp"
#include "asio/ssl.hpp"

static void create_stream_and_attempt_handshake()
{
asio::io_context io;
asio::ssl::context ctx(asio::ssl::context::tlsv12_client);
asio::ssl::stream<asio::ip::tcp::socket> stream(io, ctx);
stream.set_verify_mode(asio::ssl::verify_none);

asio::error_code ec;
stream.handshake(asio::ssl::stream_base::client, ec);
}


TEST_GROUP(asio_ssl);

TEST_SETUP(asio_ssl)
{
// call once to allocate all one time inits
create_stream_and_attempt_handshake();
test_utils_record_free_mem();
}

TEST_TEAR_DOWN(asio_ssl)
{
// account for some timer-based lwip allocations
test_utils_finish_and_evaluate_leaks(128, 256);
}


TEST(asio_ssl, ssl_stream_lifecycle_no_leak)
{
test_case_uses_tcpip();
create_stream_and_attempt_handshake();
TEST_ASSERT_TRUE(true);
}

TEST_GROUP_RUNNER(asio_ssl)
{
RUN_TEST_CASE(asio_ssl, ssl_stream_lifecycle_no_leak)
}

extern "C" void app_main(void)
{
esp_netif_init();
esp_event_loop_create_default();
UNITY_MAIN(asio_ssl);
}
8 changes: 8 additions & 0 deletions components/asio/tests/unit/pytest_app_asio_ssl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0

from pytest_embedded import Dut


def test_asio_ssl_unit(dut: Dut) -> None:
dut.expect_unity_test_output()
4 changes: 4 additions & 0 deletions components/asio/tests/unit/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
CONFIG_UNITY_ENABLE_FIXTURE=y
CONFIG_ASIO_SSL_SUPPORT=y
Loading