-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nrf fromlist] tests: subsys: logging: Test with CONFIG_LOG disabled
Developer reports build error when he uses LOG_RAW in his code and disables logging in prj.conf using CONFIG_LOG=n. Add test case for above described scenario. Upstream PR #: 85383 Signed-off-by: Sebastian Głąb <[email protected]>
- Loading branch information
1 parent
693769a
commit 400b96d
Showing
4 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
|
||
project(log_disable) | ||
|
||
target_sources(app PRIVATE src/main.c) |
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,2 @@ | ||
CONFIG_PRINTK=y | ||
CONFIG_LOG=n |
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,43 @@ | ||
/* | ||
* Copyright (c) 2025 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
|
||
LOG_MODULE_REGISTER(app, LOG_LEVEL_DBG); | ||
|
||
int main(void) | ||
{ | ||
uint8_t data[] = {0, 1, 2, 3}; | ||
uint32_t dummy_1 = 1; | ||
uint32_t dummy_2 = 2; | ||
uint32_t dummy_3 = 3; | ||
uint32_t dummy_4 = 4; | ||
uint32_t dummy_5 = 5; | ||
uint32_t dummy_6 = 6; | ||
uint32_t dummy_7 = 7; | ||
|
||
LOG_DBG("Debug log %u", dummy_1); | ||
LOG_INF("Info log %u", dummy_2); | ||
LOG_WRN("Warning log %u", dummy_3); | ||
LOG_ERR("Error log %u", dummy_4); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
LOG_WRN_ONCE("Warning on the first execution only %u", dummy_5); | ||
} | ||
|
||
LOG_PRINTK("Printk log %u\n", dummy_6); | ||
|
||
LOG_RAW("Raw log %u\n", dummy_7); | ||
|
||
LOG_HEXDUMP_DBG(data, sizeof(data), "Debug data"); | ||
LOG_HEXDUMP_INF(data, sizeof(data), "Info data"); | ||
LOG_HEXDUMP_WRN(data, sizeof(data), "Warning data"); | ||
LOG_HEXDUMP_ERR(data, sizeof(data), "Error data"); | ||
|
||
printk("All done.\n"); | ||
return 0; | ||
} |
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,17 @@ | ||
common: | ||
tags: | ||
- logging | ||
build_only: true | ||
harness: console | ||
harness_config: | ||
type: one_line | ||
regex: | ||
- "All done." | ||
|
||
tests: | ||
logging.log_disable: | ||
platform_allow: | ||
- nrf5340dk/nrf5340/cpunet | ||
- nrf54l15dk/nrf54l15/cpuapp | ||
integration_platforms: | ||
- nrf5340dk/nrf5340/cpunet |