-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/esp_log_master_option' into 'master'
log: Add master log option Closes IDFGH-9721 See merge request espressif/esp-idf!23538
- Loading branch information
Showing
12 changed files
with
194 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#This is the project CMakeLists.txt file for the test subproject | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
set(COMPONENTS main) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(esp_log) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
| Supported Targets | ESP32 | | ||
| ----------------- | ----- | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRC_DIRS "." | ||
PRIV_REQUIRES unity esp_timer | ||
WHOLE_ARCHIVE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
*/ | ||
#include "unity.h" | ||
|
||
void app_main(void) | ||
{ | ||
unity_run_menu(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <inttypes.h> | ||
#include "unity.h" | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "esp_log.h" | ||
#include "esp_timer.h" | ||
#include "sdkconfig.h" | ||
|
||
|
||
static const char * TAG = "log_test"; | ||
|
||
static int calc_time_of_logging(int iterations) | ||
{ | ||
int diff; | ||
int64_t start, end; | ||
int attempts = 2; | ||
while (attempts--) { | ||
start = esp_timer_get_time(); | ||
for (int i = 0; i < iterations; i++) { | ||
ESP_LOGI(TAG, "some test data, %d, %d, %d", i, iterations - i, 12); | ||
} | ||
end = esp_timer_get_time(); | ||
} | ||
diff = (int)(end - start); | ||
printf("%d iterations took %d usec (%.02f usec per invocation)\n", | ||
iterations, diff, (float)diff / iterations); | ||
return diff; | ||
} | ||
|
||
TEST_CASE("test master logging level performance", "[log]") | ||
{ | ||
const int ITERATIONS = 1000; | ||
ESP_LOGI(TAG, "Start"); | ||
|
||
#ifdef CONFIG_LOG_MASTER_LEVEL | ||
esp_log_set_level_master(ESP_LOG_NONE); | ||
TEST_ASSERT_INT_WITHIN(100, 150, calc_time_of_logging(ITERATIONS)); | ||
#else | ||
esp_log_level_set("*", ESP_LOG_NONE); | ||
TEST_ASSERT_INT_WITHIN(5, 11, calc_time_of_logging(ITERATIONS) / ITERATIONS); | ||
#endif | ||
|
||
esp_log_level_set("*", ESP_LOG_NONE); | ||
#ifdef CONFIG_LOG_MASTER_LEVEL | ||
esp_log_set_level_master(ESP_LOG_DEBUG); | ||
#endif | ||
TEST_ASSERT_INT_WITHIN(5, 11, calc_time_of_logging(ITERATIONS) / ITERATIONS); | ||
|
||
esp_log_level_set("*", ESP_LOG_INFO); | ||
ESP_LOGI(TAG, "End"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
|
||
import pytest | ||
from pytest_embedded import Dut | ||
|
||
|
||
@pytest.mark.esp32 | ||
@pytest.mark.generic | ||
def test_esp_log(dut: Dut) -> None: | ||
dut.run_all_single_board_cases() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# General options for additional checks | ||
CONFIG_ESP_TASK_WDT_INIT=n | ||
CONFIG_LOG_MASTER_LEVEL=y |