From 412dc9516874928bb18c29c85ef5e914bf653c18 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 11 Jun 2019 15:56:04 +0200 Subject: [PATCH] tcp_transport: added basic unit tests for init/destroy transports in lists or when used separately --- components/tcp_transport/test/CMakeLists.txt | 5 ++++ components/tcp_transport/test/component.mk | 5 ++++ .../tcp_transport/test/test_transport.c | 28 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 components/tcp_transport/test/CMakeLists.txt create mode 100644 components/tcp_transport/test/component.mk create mode 100644 components/tcp_transport/test/test_transport.c diff --git a/components/tcp_transport/test/CMakeLists.txt b/components/tcp_transport/test/CMakeLists.txt new file mode 100644 index 0000000000..88504a27f6 --- /dev/null +++ b/components/tcp_transport/test/CMakeLists.txt @@ -0,0 +1,5 @@ +set(COMPONENT_SRCDIRS ".") +set(COMPONENT_PRIV_INCLUDEDIRS "../private_include" ".") +set(COMPONENT_PRIV_REQUIRES unity test_utils tcp_transport) + +register_component() \ No newline at end of file diff --git a/components/tcp_transport/test/component.mk b/components/tcp_transport/test/component.mk new file mode 100644 index 0000000000..22e49eddde --- /dev/null +++ b/components/tcp_transport/test/component.mk @@ -0,0 +1,5 @@ +# +#Component Makefile +# +COMPONENT_PRIV_INCLUDEDIRS := ../private_include . +COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive \ No newline at end of file diff --git a/components/tcp_transport/test/test_transport.c b/components/tcp_transport/test/test_transport.c new file mode 100644 index 0000000000..28702fb08b --- /dev/null +++ b/components/tcp_transport/test/test_transport.c @@ -0,0 +1,28 @@ +#include "unity.h" + +#include "esp_transport.h" +#include "esp_transport_tcp.h" +#include "esp_transport_ssl.h" +#include "esp_transport_ws.h" + +TEST_CASE("tcp_transport: init and deinit transport list", "[tcp_transport][leaks=0]") +{ + esp_transport_list_handle_t transport_list = esp_transport_list_init(); + esp_transport_handle_t tcp = esp_transport_tcp_init(); + esp_transport_list_add(transport_list, tcp, "tcp"); + TEST_ASSERT_EQUAL(ESP_OK, esp_transport_list_destroy(transport_list)); +} + +TEST_CASE("tcp_transport: using ssl transport separately", "[tcp_transport][leaks=0]") +{ + esp_transport_handle_t h = esp_transport_ssl_init(); + TEST_ASSERT_EQUAL(ESP_OK, esp_transport_destroy(h)); +} + +TEST_CASE("tcp_transport: using ws transport separately", "[tcp_transport][leaks=0]") +{ + esp_transport_handle_t tcp = esp_transport_tcp_init(); + esp_transport_handle_t ws = esp_transport_ws_init(tcp); + TEST_ASSERT_EQUAL(ESP_OK, esp_transport_destroy(ws)); + TEST_ASSERT_EQUAL(ESP_OK, esp_transport_destroy(tcp)); +} -- 2.40.0