Skip to content

Commit 400b96d

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 400b96d

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed
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)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_PRINTK=y
2+
CONFIG_LOG=n
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
uint32_t dummy_1 = 1;
16+
uint32_t dummy_2 = 2;
17+
uint32_t dummy_3 = 3;
18+
uint32_t dummy_4 = 4;
19+
uint32_t dummy_5 = 5;
20+
uint32_t dummy_6 = 6;
21+
uint32_t dummy_7 = 7;
22+
23+
LOG_DBG("Debug log %u", dummy_1);
24+
LOG_INF("Info log %u", dummy_2);
25+
LOG_WRN("Warning log %u", dummy_3);
26+
LOG_ERR("Error log %u", dummy_4);
27+
28+
for (int i = 0; i < 10; i++) {
29+
LOG_WRN_ONCE("Warning on the first execution only %u", dummy_5);
30+
}
31+
32+
LOG_PRINTK("Printk log %u\n", dummy_6);
33+
34+
LOG_RAW("Raw log %u\n", dummy_7);
35+
36+
LOG_HEXDUMP_DBG(data, sizeof(data), "Debug data");
37+
LOG_HEXDUMP_INF(data, sizeof(data), "Info data");
38+
LOG_HEXDUMP_WRN(data, sizeof(data), "Warning data");
39+
LOG_HEXDUMP_ERR(data, sizeof(data), "Error data");
40+
41+
printk("All done.\n");
42+
return 0;
43+
}
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)