mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-29 10:17:30 +02:00
CI: fixing the files to be complient with pre-commit hooks
This commit is contained in:
2
components/esp_websocket_client/.gitignore
vendored
2
components/esp_websocket_client/.gitignore
vendored
@ -90,4 +90,4 @@ build
|
||||
dependencies.lock
|
||||
|
||||
# ignore generated docs
|
||||
docs/html
|
||||
docs/html
|
||||
|
@ -1,10 +1,12 @@
|
||||
from esp_docs.conf_docs import * # noqa: F403,F401
|
||||
# flake8: noqa
|
||||
from esp_docs.conf_docs import *
|
||||
|
||||
extensions += ['sphinx_copybutton',
|
||||
# Needed as a trigger for running doxygen
|
||||
'esp_docs.esp_extensions.dummy_build_system',
|
||||
'esp_docs.esp_extensions.run_doxygen',
|
||||
]
|
||||
extensions += [
|
||||
'sphinx_copybutton',
|
||||
# Needed as a trigger for running doxygen
|
||||
'esp_docs.esp_extensions.dummy_build_system',
|
||||
'esp_docs.esp_extensions.run_doxygen',
|
||||
]
|
||||
|
||||
# link roles config
|
||||
github_repo = 'espressif/esp-protocols'
|
||||
@ -14,7 +16,7 @@ html_context['github_user'] = 'espressif'
|
||||
html_context['github_repo'] = 'esp-docs'
|
||||
|
||||
# Extra options required by sphinx_idf_theme
|
||||
project_slug = 'esp-idf' # >=5.0
|
||||
project_slug = 'esp-idf' # >=5.0
|
||||
versions_url = 'https://github.com/espressif/esp-protocols/docs/docs_versions.js'
|
||||
|
||||
idf_targets = ['esp32']
|
||||
|
@ -124,4 +124,3 @@ API Reference
|
||||
-------------
|
||||
|
||||
.. include-build-file:: inc/esp_websocket_client.inc
|
||||
|
||||
|
@ -13,7 +13,7 @@ window.onload =(function() {
|
||||
mySpan.value = 'latest';
|
||||
mySpan.setAttribute('disabled', true);
|
||||
myAnchor.parentNode.replaceChild(mySpan, myAnchor);
|
||||
|
||||
|
||||
var myAnchor = document.getElementById('target-select');
|
||||
var mySpan = document.createElement('input');
|
||||
mySpan.setAttribute('type', 'text');
|
||||
@ -24,4 +24,3 @@ window.onload =(function() {
|
||||
|
||||
})();
|
||||
</script>" >> html/index.html
|
||||
|
||||
|
@ -59,7 +59,7 @@ static const char *TAG = "WEBSOCKET_CLIENT";
|
||||
|
||||
const static int STOPPED_BIT = BIT0;
|
||||
const static int CLOSE_FRAME_SENT_BIT = BIT1; // Indicates that a close frame was sent by the client
|
||||
// and we are waiting for the server to continue with clean close
|
||||
// and we are waiting for the server to continue with clean close
|
||||
|
||||
ESP_EVENT_DEFINE_BASE(WEBSOCKET_EVENTS);
|
||||
|
||||
@ -82,7 +82,7 @@ typedef struct {
|
||||
int pingpong_timeout_sec;
|
||||
size_t ping_interval_sec;
|
||||
const char *cert;
|
||||
size_t cert_len;
|
||||
size_t cert_len;
|
||||
const char *client_cert;
|
||||
size_t client_cert_len;
|
||||
const char *client_key;
|
||||
@ -131,7 +131,7 @@ struct esp_websocket_client {
|
||||
|
||||
static uint64_t _tick_get_ms(void)
|
||||
{
|
||||
return esp_timer_get_time()/1000;
|
||||
return esp_timer_get_time() / 1000;
|
||||
}
|
||||
|
||||
static esp_err_t esp_websocket_new_buf(esp_websocket_client_handle_t client, bool is_tx)
|
||||
@ -295,7 +295,7 @@ static esp_err_t esp_websocket_client_set_config(esp_websocket_client_handle_t c
|
||||
cfg->auto_reconnect = false;
|
||||
}
|
||||
|
||||
if (config->disable_pingpong_discon){
|
||||
if (config->disable_pingpong_discon) {
|
||||
cfg->pingpong_timeout_sec = 0;
|
||||
} else if (config->pingpong_timeout_sec) {
|
||||
cfg->pingpong_timeout_sec = config->pingpong_timeout_sec;
|
||||
@ -348,11 +348,11 @@ static esp_err_t set_websocket_transport_optional_settings(esp_websocket_client_
|
||||
esp_transport_handle_t trans = esp_transport_list_get_transport(client->transport_list, scheme);
|
||||
if (trans) {
|
||||
const esp_transport_ws_config_t config = {
|
||||
.ws_path = client->config->path,
|
||||
.sub_protocol = client->config->subprotocol,
|
||||
.user_agent = client->config->user_agent,
|
||||
.headers = client->config->headers,
|
||||
.propagate_control_frames = true
|
||||
.ws_path = client->config->path,
|
||||
.sub_protocol = client->config->subprotocol,
|
||||
.user_agent = client->config->user_agent,
|
||||
.headers = client->config->headers,
|
||||
.propagate_control_frames = true
|
||||
};
|
||||
return esp_transport_ws_set_config(trans, &config);
|
||||
}
|
||||
@ -616,12 +616,12 @@ esp_err_t esp_websocket_client_set_uri(esp_websocket_client_handle_t client, con
|
||||
asprintf(&client->config->path, "/?%.*s", puri.field_data[UF_QUERY].len, uri + puri.field_data[UF_QUERY].off);
|
||||
} else {
|
||||
asprintf(&client->config->path, "%.*s?%.*s", puri.field_data[UF_PATH].len, uri + puri.field_data[UF_PATH].off,
|
||||
puri.field_data[UF_QUERY].len, uri + puri.field_data[UF_QUERY].off);
|
||||
puri.field_data[UF_QUERY].len, uri + puri.field_data[UF_QUERY].off);
|
||||
}
|
||||
ESP_WS_CLIENT_MEM_CHECK(TAG, client->config->path, return ESP_ERR_NO_MEM);
|
||||
}
|
||||
if (puri.field_data[UF_PORT].off) {
|
||||
client->config->port = strtol((const char*)(uri + puri.field_data[UF_PORT].off), NULL, 10);
|
||||
client->config->port = strtol((const char *)(uri + puri.field_data[UF_PORT].off), NULL, 10);
|
||||
}
|
||||
|
||||
if (puri.field_data[UF_USERINFO].len) {
|
||||
@ -724,86 +724,86 @@ static void esp_websocket_client_task(void *pv)
|
||||
break;
|
||||
}
|
||||
switch ((int)client->state) {
|
||||
case WEBSOCKET_STATE_INIT:
|
||||
if (client->transport == NULL) {
|
||||
ESP_LOGE(TAG, "There are no transport");
|
||||
client->run = false;
|
||||
break;
|
||||
}
|
||||
int result = esp_transport_connect(client->transport,
|
||||
client->config->host,
|
||||
client->config->port,
|
||||
client->config->network_timeout_ms);
|
||||
if (result < 0) {
|
||||
ESP_LOGE(TAG, "Error transport connect %i", result);
|
||||
esp_websocket_client_error_connection(client);
|
||||
break;
|
||||
}
|
||||
ESP_LOGD(TAG, "Transport connected to %s://%s:%d", client->config->scheme, client->config->host, client->config->port);
|
||||
|
||||
client->state = WEBSOCKET_STATE_CONNECTED;
|
||||
client->wait_for_pong_resp = false;
|
||||
esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_CONNECTED, NULL, 0);
|
||||
|
||||
case WEBSOCKET_STATE_INIT:
|
||||
if (client->transport == NULL) {
|
||||
ESP_LOGE(TAG, "There are no transport");
|
||||
client->run = false;
|
||||
break;
|
||||
case WEBSOCKET_STATE_CONNECTED:
|
||||
if ((CLOSE_FRAME_SENT_BIT & xEventGroupGetBits(client->status_bits)) == 0) { // only send and check for PING
|
||||
// if closing hasn't been initiated
|
||||
if (_tick_get_ms() - client->ping_tick_ms > client->config->ping_interval_sec*1000) {
|
||||
client->ping_tick_ms = _tick_get_ms();
|
||||
ESP_LOGD(TAG, "Sending PING...");
|
||||
esp_transport_ws_send_raw(client->transport, WS_TRANSPORT_OPCODES_PING | WS_TRANSPORT_OPCODES_FIN, NULL, 0, client->config->network_timeout_ms);
|
||||
}
|
||||
int result = esp_transport_connect(client->transport,
|
||||
client->config->host,
|
||||
client->config->port,
|
||||
client->config->network_timeout_ms);
|
||||
if (result < 0) {
|
||||
ESP_LOGE(TAG, "Error transport connect %i", result);
|
||||
esp_websocket_client_error_connection(client);
|
||||
break;
|
||||
}
|
||||
ESP_LOGD(TAG, "Transport connected to %s://%s:%d", client->config->scheme, client->config->host, client->config->port);
|
||||
|
||||
if (!client->wait_for_pong_resp && client->config->pingpong_timeout_sec) {
|
||||
client->pingpong_tick_ms = _tick_get_ms();
|
||||
client->wait_for_pong_resp = true;
|
||||
}
|
||||
}
|
||||
client->state = WEBSOCKET_STATE_CONNECTED;
|
||||
client->wait_for_pong_resp = false;
|
||||
esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_CONNECTED, NULL, 0);
|
||||
|
||||
if ( _tick_get_ms() - client->pingpong_tick_ms > client->config->pingpong_timeout_sec*1000 ) {
|
||||
if (client->wait_for_pong_resp) {
|
||||
ESP_LOGE(TAG, "Error, no PONG received for more than %d seconds after PING", client->config->pingpong_timeout_sec);
|
||||
esp_websocket_client_abort_connection(client);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WEBSOCKET_STATE_CONNECTED:
|
||||
if ((CLOSE_FRAME_SENT_BIT & xEventGroupGetBits(client->status_bits)) == 0) { // only send and check for PING
|
||||
// if closing hasn't been initiated
|
||||
if (_tick_get_ms() - client->ping_tick_ms > client->config->ping_interval_sec * 1000) {
|
||||
client->ping_tick_ms = _tick_get_ms();
|
||||
ESP_LOGD(TAG, "Sending PING...");
|
||||
esp_transport_ws_send_raw(client->transport, WS_TRANSPORT_OPCODES_PING | WS_TRANSPORT_OPCODES_FIN, NULL, 0, client->config->network_timeout_ms);
|
||||
|
||||
if (!client->wait_for_pong_resp && client->config->pingpong_timeout_sec) {
|
||||
client->pingpong_tick_ms = _tick_get_ms();
|
||||
client->wait_for_pong_resp = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (read_select == 0) {
|
||||
ESP_LOGV(TAG, "Read poll timeout: skipping esp_transport_read()...");
|
||||
break;
|
||||
if ( _tick_get_ms() - client->pingpong_tick_ms > client->config->pingpong_timeout_sec * 1000 ) {
|
||||
if (client->wait_for_pong_resp) {
|
||||
ESP_LOGE(TAG, "Error, no PONG received for more than %d seconds after PING", client->config->pingpong_timeout_sec);
|
||||
esp_websocket_client_abort_connection(client);
|
||||
break;
|
||||
}
|
||||
}
|
||||
client->ping_tick_ms = _tick_get_ms();
|
||||
}
|
||||
|
||||
if (esp_websocket_client_recv(client) == ESP_FAIL) {
|
||||
ESP_LOGE(TAG, "Error receive data");
|
||||
esp_websocket_client_abort_connection(client);
|
||||
break;
|
||||
}
|
||||
if (read_select == 0) {
|
||||
ESP_LOGV(TAG, "Read poll timeout: skipping esp_transport_read()...");
|
||||
break;
|
||||
case WEBSOCKET_STATE_WAIT_TIMEOUT:
|
||||
}
|
||||
client->ping_tick_ms = _tick_get_ms();
|
||||
|
||||
if (!client->config->auto_reconnect) {
|
||||
client->run = false;
|
||||
break;
|
||||
}
|
||||
if (_tick_get_ms() - client->reconnect_tick_ms > client->wait_timeout_ms) {
|
||||
client->state = WEBSOCKET_STATE_INIT;
|
||||
client->reconnect_tick_ms = _tick_get_ms();
|
||||
ESP_LOGD(TAG, "Reconnecting...");
|
||||
}
|
||||
if (esp_websocket_client_recv(client) == ESP_FAIL) {
|
||||
ESP_LOGE(TAG, "Error receive data");
|
||||
esp_websocket_client_abort_connection(client);
|
||||
break;
|
||||
case WEBSOCKET_STATE_CLOSING:
|
||||
// if closing not initiated by the client echo the close message back
|
||||
if ((CLOSE_FRAME_SENT_BIT & xEventGroupGetBits(client->status_bits)) == 0) {
|
||||
ESP_LOGD(TAG, "Closing initiated by the server, sending close frame");
|
||||
esp_transport_ws_send_raw(client->transport, WS_TRANSPORT_OPCODES_CLOSE | WS_TRANSPORT_OPCODES_FIN, NULL, 0, client->config->network_timeout_ms);
|
||||
xEventGroupSetBits(client->status_bits, CLOSE_FRAME_SENT_BIT);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ESP_LOGD(TAG, "Client run iteration in a default state: %d", client->state);
|
||||
}
|
||||
break;
|
||||
case WEBSOCKET_STATE_WAIT_TIMEOUT:
|
||||
|
||||
if (!client->config->auto_reconnect) {
|
||||
client->run = false;
|
||||
break;
|
||||
}
|
||||
if (_tick_get_ms() - client->reconnect_tick_ms > client->wait_timeout_ms) {
|
||||
client->state = WEBSOCKET_STATE_INIT;
|
||||
client->reconnect_tick_ms = _tick_get_ms();
|
||||
ESP_LOGD(TAG, "Reconnecting...");
|
||||
}
|
||||
break;
|
||||
case WEBSOCKET_STATE_CLOSING:
|
||||
// if closing not initiated by the client echo the close message back
|
||||
if ((CLOSE_FRAME_SENT_BIT & xEventGroupGetBits(client->status_bits)) == 0) {
|
||||
ESP_LOGD(TAG, "Closing initiated by the server, sending close frame");
|
||||
esp_transport_ws_send_raw(client->transport, WS_TRANSPORT_OPCODES_CLOSE | WS_TRANSPORT_OPCODES_FIN, NULL, 0, client->config->network_timeout_ms);
|
||||
xEventGroupSetBits(client->status_bits, CLOSE_FRAME_SENT_BIT);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ESP_LOGD(TAG, "Client run iteration in a default state: %d", client->state);
|
||||
break;
|
||||
}
|
||||
xSemaphoreGiveRecursive(client->lock);
|
||||
if (WEBSOCKET_STATE_CONNECTED == client->state) {
|
||||
@ -816,7 +816,7 @@ static void esp_websocket_client_task(void *pv)
|
||||
// waiting for reconnecting...
|
||||
vTaskDelay(client->wait_timeout_ms / 2 / portTICK_PERIOD_MS);
|
||||
} else if (WEBSOCKET_STATE_CLOSING == client->state &&
|
||||
(CLOSE_FRAME_SENT_BIT & xEventGroupGetBits(client->status_bits))) {
|
||||
(CLOSE_FRAME_SENT_BIT & xEventGroupGetBits(client->status_bits))) {
|
||||
ESP_LOGD(TAG, " Waiting for TCP connection to be closed by the server");
|
||||
int ret = esp_transport_ws_poll_connection_closed(client->transport, 1000);
|
||||
if (ret == 0) {
|
||||
@ -967,7 +967,7 @@ static int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t c
|
||||
int ret = ESP_FAIL;
|
||||
|
||||
if (client == NULL || len < 0 ||
|
||||
(opcode != WS_TRANSPORT_OPCODES_CLOSE && (data == NULL || len <= 0))) {
|
||||
(opcode != WS_TRANSPORT_OPCODES_CLOSE && (data == NULL || len <= 0))) {
|
||||
ESP_LOGE(TAG, "Invalid arguments");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@ -1000,7 +1000,7 @@ static int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t c
|
||||
memcpy(client->tx_buffer, data + widx, need_write);
|
||||
// send with ws specific way and specific opcode
|
||||
wlen = esp_transport_ws_send_raw(client->transport, current_opcode, (char *)client->tx_buffer, need_write,
|
||||
(timeout==portMAX_DELAY)? -1 : timeout * portTICK_PERIOD_MS);
|
||||
(timeout == portMAX_DELAY) ? -1 : timeout * portTICK_PERIOD_MS);
|
||||
if (wlen < 0 || (wlen == 0 && need_write != 0)) {
|
||||
ret = wlen;
|
||||
ESP_LOGE(TAG, "Network error: esp_transport_write() returned %d, errno=%d", ret, errno);
|
||||
|
@ -86,4 +86,3 @@ if __name__ == '__main__':
|
||||
# gunicorn -b 0.0.0.0:5000 --workers 4 --threads 100 module:app
|
||||
app.run(host="0.0.0.0", debug=True)
|
||||
```
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
/* ESP HTTP Client Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
@ -71,11 +76,11 @@ static void websocket_event_handler(void *handler_args, esp_event_base_t base, i
|
||||
ESP_LOGI(TAG, "WEBSOCKET_EVENT_DATA");
|
||||
ESP_LOGI(TAG, "Received opcode=%d", data->op_code);
|
||||
if (data->op_code == 0x08 && data->data_len == 2) {
|
||||
ESP_LOGW(TAG, "Received closed message with code=%d", 256*data->data_ptr[0] + data->data_ptr[1]);
|
||||
ESP_LOGW(TAG, "Received closed message with code=%d", 256 * data->data_ptr[0] + data->data_ptr[1]);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Received=%.*s", data->data_len, (char *)data->data_ptr);
|
||||
}
|
||||
|
||||
|
||||
// If received data contains json structure it succeed to parse
|
||||
cJSON *root = cJSON_Parse(data->data_ptr);
|
||||
if (root) {
|
||||
|
@ -1,16 +1,13 @@
|
||||
import os
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import string
|
||||
from threading import Event, Thread
|
||||
import pytest
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
|
||||
from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket
|
||||
from pytest_embedded import Dut
|
||||
|
||||
|
||||
def get_my_ip():
|
||||
@ -64,7 +61,7 @@ class Websocket(object):
|
||||
self.exit_event.set()
|
||||
self.thread.join(10)
|
||||
if self.thread.is_alive():
|
||||
Utility.console_log('Thread cannot be joined', 'orange')
|
||||
print('Thread cannot be joined', 'orange')
|
||||
|
||||
|
||||
def test_examples_protocol_websocket(dut):
|
||||
@ -74,6 +71,7 @@ def test_examples_protocol_websocket(dut):
|
||||
2. connect to uri specified in the config
|
||||
3. send and receive data
|
||||
"""
|
||||
|
||||
def test_echo(dut):
|
||||
dut.expect('WEBSOCKET_EVENT_CONNECTED')
|
||||
for i in range(0, 5):
|
||||
@ -81,7 +79,9 @@ def test_examples_protocol_websocket(dut):
|
||||
print('All echos received')
|
||||
|
||||
def test_close(dut):
|
||||
code = dut.expect(re.compile(b'WEBSOCKET: Received closed message with code=(\\d*)'))[0]
|
||||
code = dut.expect(
|
||||
re.compile(
|
||||
b'WEBSOCKET: Received closed message with code=(\\d*)'))[0]
|
||||
print('Received close frame with code {}'.format(code))
|
||||
|
||||
def test_json(dut, websocket):
|
||||
@ -100,32 +100,39 @@ def test_examples_protocol_websocket(dut):
|
||||
websocket.send_data(json_string)
|
||||
data = json.loads(json_string)
|
||||
|
||||
match = dut.expect(re.compile(b'Json=([a-zA-Z0-9]*).*')).group(0).decode()[5:]
|
||||
match = dut.expect(
|
||||
re.compile(b'Json=([a-zA-Z0-9]*).*')).group(0).decode()[5:]
|
||||
if match == str(data[0]):
|
||||
print('Sent message and received message are equal')
|
||||
else:
|
||||
raise ValueError('DUT received string do not match sent string, \nexpected: {}\nwith length {}\
|
||||
\nreceived: {}\nwith length {}'.format(data[0], len(data[0]), match, len(match)))
|
||||
raise ValueError(
|
||||
'DUT received string do not match sent string, \nexpected: {}\nwith length {}\
|
||||
\nreceived: {}\nwith length {}'.format(
|
||||
data[0], len(data[0]), match, len(match)))
|
||||
|
||||
|
||||
def test_recv_long_msg(dut, websocket, msg_len, repeats):
|
||||
|
||||
send_msg = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(msg_len))
|
||||
send_msg = ''.join(
|
||||
random.choice(string.ascii_uppercase + string.ascii_lowercase +
|
||||
string.digits) for _ in range(msg_len))
|
||||
|
||||
for _ in range(repeats):
|
||||
websocket.send_data(send_msg)
|
||||
|
||||
|
||||
recv_msg = ''
|
||||
while len(recv_msg) < msg_len:
|
||||
match = dut.expect(re.compile(b'Received=([a-zA-Z0-9]*).*')).group(1).decode()
|
||||
match = dut.expect(re.compile(
|
||||
b'Received=([a-zA-Z0-9]*).*')).group(1).decode()
|
||||
recv_msg += match
|
||||
|
||||
|
||||
if recv_msg == send_msg:
|
||||
print('Sent message and received message are equal')
|
||||
else:
|
||||
raise ValueError('DUT received string do not match sent string, \nexpected: {}\nwith length {}\
|
||||
\nreceived: {}\nwith length {}'.format(send_msg, len(send_msg), recv_msg, len(recv_msg)))
|
||||
|
||||
raise ValueError(
|
||||
'DUT received string do not match sent string, \nexpected: {}\nwith length {}\
|
||||
\nreceived: {}\nwith length {}'.format(
|
||||
send_msg, len(send_msg), recv_msg, len(recv_msg)))
|
||||
|
||||
# Starting of the test
|
||||
try:
|
||||
if dut.app.sdkconfig.get('WEBSOCKET_URI_FROM_STDIN') is True:
|
||||
@ -153,4 +160,3 @@ def test_examples_protocol_websocket(dut):
|
||||
else:
|
||||
print('DUT connecting to {}'.format(uri))
|
||||
test_echo(dut)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
pytest-embedded-serial-esp
|
||||
pytest-embedded-idf
|
||||
junit_xml
|
||||
pytest-embedded-serial-esp
|
||||
pytest-embedded-idf
|
||||
junit_xml
|
||||
SimpleWebSocketServer
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*
|
||||
@ -17,7 +17,7 @@
|
||||
#include "unity.h"
|
||||
#include "memory_checks.h"
|
||||
|
||||
static void test_leak_setup(const char * file, long line)
|
||||
static void test_leak_setup(const char *file, long line)
|
||||
{
|
||||
printf("%s:%ld\n", file, line);
|
||||
test_utils_record_free_mem();
|
||||
@ -27,8 +27,8 @@ TEST_CASE("websocket init and deinit", "[websocket][leaks=0]")
|
||||
{
|
||||
test_leak_setup(__FILE__, __LINE__);
|
||||
const esp_websocket_client_config_t websocket_cfg = {
|
||||
// no connection takes place, but the uri has to be valid for init() to succeed
|
||||
.uri = "ws://echo.websocket.org",
|
||||
// no connection takes place, but the uri has to be valid for init() to succeed
|
||||
.uri = "ws://echo.websocket.org",
|
||||
};
|
||||
esp_websocket_client_handle_t client = esp_websocket_client_init(&websocket_cfg);
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, client);
|
||||
@ -39,7 +39,7 @@ TEST_CASE("websocket init with invalid url", "[websocket][leaks=0]")
|
||||
{
|
||||
test_leak_setup(__FILE__, __LINE__);
|
||||
const esp_websocket_client_config_t websocket_cfg = {
|
||||
.uri = "INVALID",
|
||||
.uri = "INVALID",
|
||||
};
|
||||
esp_websocket_client_handle_t client = esp_websocket_client_init(&websocket_cfg);
|
||||
TEST_ASSERT_NULL(client);
|
||||
|
Reference in New Issue
Block a user