log: support ESP_LOG_BUFFER* functions for Linux target

pull/8812/head
Ivan Grokhotkov 2022-04-10 19:52:06 +02:00
rodzic 199d72c19c
commit 3602d332c4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 1E050E141B280628
3 zmienionych plików z 22 dodań i 5 usunięć

Wyświetl plik

@ -1,12 +1,9 @@
idf_build_get_property(target IDF_TARGET)
set(srcs "log.c")
set(srcs "log.c" "log_buffers.c")
set(priv_requires "")
if(${target} STREQUAL "linux")
# We leave log buffers out for now on Linux since it's rarely used. Explicitely add esp_rom to Linux target
# since we don't have the common components there yet.
list(APPEND srcs "log_linux.c")
else()
list(APPEND srcs "log_buffers.c")
list(APPEND priv_requires soc hal esp_hw_support)
endif()

Wyświetl plik

@ -193,6 +193,18 @@ TEST_CASE("changing log level")
CHECK(regex_search(fix.get_print_buffer_string(), test_print) == true);
}
TEST_CASE("log buffer")
{
PrintFixture fix(ESP_LOG_INFO);
const uint8_t buffer[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
};
ESP_LOG_BUFFER_HEX(TEST_TAG, buffer, sizeof(buffer));
const std::regex buffer_regex("I \\([0-9]*\\) test: 01 02 03 04 05 06 07 08 11 12 13 14 15 16 17 18", std::regex::ECMAScript);
CHECK(regex_search(fix.get_print_buffer_string(), buffer_regex));
}
TEST_CASE("rom printf")
{
PutcFixture fix;

Wyświetl plik

@ -7,9 +7,17 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include "esp_log.h"
#include "esp_memory_utils.h" // for esp_ptr_byte_accessible
#ifndef CONFIG_IDF_TARGET_LINUX
#include "esp_memory_utils.h" // for esp_ptr_byte_accessible
#else
static inline bool esp_ptr_byte_accessible(const void* ptr) {
(void) ptr;
return true;
}
#endif // CONFIG_IDF_TARGET_LINUX
//print number of bytes per line for esp_log_buffer_char and esp_log_buffer_hex
#define BYTES_PER_LINE 16