Skip to content

Commit 56d4fc3

Browse files
committed
[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]>
1 parent 693769a commit 56d4fc3

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
11+
project(log_disable)
12+
13+
target_sources(app PRIVATE src/main.c)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_PRINTK=y
2+
CONFIG_LOG=n
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/logging/log.h>
9+
10+
LOG_MODULE_REGISTER(app, LOG_LEVEL_DBG);
11+
12+
int main(void)
13+
{
14+
uint8_t data[] = {0, 1, 2, 3};
15+
16+
LOG_DBG("Debug log");
17+
LOG_INF("Info log");
18+
LOG_WRN("Warning log");
19+
LOG_ERR("Error log");
20+
21+
for (int i = 0; i < 10; i++) {
22+
LOG_WRN_ONCE("Warning on the first execution only");
23+
}
24+
25+
LOG_PRINTK("Printk log\n");
26+
27+
LOG_RAW("Raw log\n");
28+
29+
LOG_HEXDUMP_DBG(data, sizeof(data), "Debug data");
30+
LOG_HEXDUMP_INF(data, sizeof(data), "Info data");
31+
LOG_HEXDUMP_WRN(data, sizeof(data), "Warning data");
32+
LOG_HEXDUMP_ERR(data, sizeof(data), "Error data");
33+
34+
printk("All done.\n");
35+
return 0;
36+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
common:
2+
tags:
3+
- logging
4+
build_only: true
5+
harness: console
6+
harness_config:
7+
type: one_line
8+
regex:
9+
- "All done."
10+
11+
tests:
12+
logging.log_disable:
13+
platform_allow:
14+
- nrf5340dk/nrf5340/cpunet
15+
- nrf54l15dk/nrf54l15/cpuapp
16+
integration_platforms:
17+
- nrf5340dk/nrf5340/cpunet

0 commit comments

Comments
 (0)