mqtt: Fix and add mqtt host test to CI

This commit is contained in:
David Cermak
2022-05-13 16:55:22 +02:00
parent e2bc3f865e
commit 1ad3e2db17
6 changed files with 27 additions and 26 deletions

View File

@@ -2,5 +2,7 @@ cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
option(TEST_BUILD "" ON)
project(host_mqtt_client_test)

View File

@@ -1,11 +1,9 @@
#define CATCH_CONFIG_MAIN // This tells the catch header to generate a main
#include "catch.hpp"
#include "mqtt_client.h"
extern "C" {
#include "Mockesp_event.h"
#include "Mockesp_log.h"
#include "Mockesp_system.h"
#include "Mockesp_mac.h"
#include "Mockesp_transport.h"
#include "Mockesp_transport_ssl.h"
@@ -20,17 +18,14 @@ extern "C" {
* The following functions are not directly called but the generation of them
* from cmock is broken, so we need to define them here.
*/
BaseType_t xQueueTakeMutexRecursive(QueueHandle_t xMutex,
TickType_t xTicksToWait)
esp_err_t esp_tls_get_and_clear_last_error(esp_tls_error_handle_t h, int *esp_tls_code, int *esp_tls_flags)
{
return 0;
}
BaseType_t xQueueGiveMutexRecursive(QueueHandle_t xMutex)
{
return 0;
return ESP_OK;
}
}
#include "mqtt_client.h"
struct ClientInitializedFixture {
esp_mqtt_client_handle_t client;
ClientInitializedFixture()
@@ -42,6 +37,8 @@ struct ClientInitializedFixture {
int event_group;
uint8_t mac[] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55};
esp_log_write_Ignore();
xQueueTakeMutexRecursive_CMockIgnoreAndReturn(0, true);
xQueueGiveMutexRecursive_CMockIgnoreAndReturn(0, true);
xQueueCreateMutex_ExpectAnyArgsAndReturn(
reinterpret_cast<QueueHandle_t>(&mtx));
xEventGroupCreate_IgnoreAndReturn(reinterpret_cast<EventGroupHandle_t>(&event_group));

View File

@@ -7,6 +7,8 @@
- array
- callback
:includes_h_pre_orig_header:
- local_FreeRTOS_config.h
- esp_attr.h
- FreeRTOS.h
- net/if.h
:strippables:

View File

@@ -0,0 +1,6 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#define configUSE_TRACE_FACILITY 1