CI: fixing the files to be complient with pre-commit hooks

This commit is contained in:
Suren Gabrielyan
2022-10-11 16:31:57 +02:00
parent 9d45d505d5
commit 945bd17701
205 changed files with 3130 additions and 3441 deletions

View File

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <memory>
#include <future>
#include <cstring>
@ -83,8 +88,9 @@ int LoopbackTerm::write(uint8_t *data, size_t len)
int LoopbackTerm::read(uint8_t *data, size_t len)
{
size_t read_len = std::min(data_len, len);
if (inject_by && read_len > inject_by)
if (inject_by && read_len > inject_by) {
read_len = inject_by;
}
if (read_len) {
if (loopback_data.capacity() < len) {
loopback_data.reserve(len);

View File

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#pragma once
#include "cxx_include/esp_modem_api.hpp"
@ -17,7 +22,7 @@ public:
* inject_by defines batch sizes: the read callback is called multiple times
* with partial data of `inject_by` size
*/
int inject(uint8_t *data, size_t len, size_t inject_by,size_t delay_before=0, size_t delay_after=1);
int inject(uint8_t *data, size_t len, size_t inject_by, size_t delay_before = 0, size_t delay_after = 1);
void start() override;
void stop() override;

View File

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#define CATCH_CONFIG_MAIN // This tells the catch header to generate a main
#include <memory>
#include <future>
@ -7,7 +12,8 @@
using namespace esp_modem;
TEST_CASE("DTE command races", "[esp_modem]") {
TEST_CASE("DTE command races", "[esp_modem]")
{
auto term = std::make_unique<LoopbackTerm>(true);
auto loopback = term.get();
auto dte = std::make_shared<DTE>(std::move(term));
@ -19,7 +25,7 @@ TEST_CASE("DTE command races", "[esp_modem]") {
uint8_t resp[] = {'O', 'K', '\n'};
// run many commands in succession with the timeout set exactly to the timespan of injected reply
// (checks for potential exception, data races, recycled local variables, etc.)
for (int i=0; i<1000; ++i) {
for (int i = 0; i < 1000; ++i) {
loopback->inject(&resp[0], sizeof(resp), sizeof(resp), /* 1ms before injecting reply */1, 0);
auto ret = dce->command("AT\n", [&](uint8_t *data, size_t len) {
return command_result::OK;
@ -229,13 +235,13 @@ TEST_CASE("Test CMUX protocol by injecting payloads", "[esp_modem]")
long_payload[450] = '\n';
long_payload[451] = 0x53; // footer
long_payload[452] = 0xf9;
for (int i=0; i<5; ++i) {
for (int i = 0; i < 5; ++i) {
// inject the whole payload (i=0) and then per 1,2,3,4 bytes (i)
loopback->inject(&long_payload[0], sizeof(long_payload), i==0?sizeof(long_payload):i);
loopback->inject(&long_payload[0], sizeof(long_payload), i == 0 ? sizeof(long_payload) : i);
auto ret = dce->command("ignore", [&](uint8_t *data, size_t len) {
CHECK(data[0] == 0x7e);
CHECK(data[len-2] == 0x7e);
CHECK(data[len-1] == '\n');
CHECK(data[len - 2] == 0x7e);
CHECK(data[len - 1] == '\n');
return command_result::OK;
}, 1000);
CHECK(ret == command_result::OK);