Skip to content

Commit fab5bb9

Browse files
yperessmbolivar-nordic
authored andcommitted
printk: Add tests for print format
Add tests to verify that the different print formats and constant macros match. Fixes #44199 Signed-off-by: Yuval Peress <[email protected]>
1 parent 44ddb30 commit fab5bb9

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2021 Google LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
project(print_format)
8+
9+
target_sources(app PRIVATE src/main.c)

tests/misc/print_format/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty

tests/misc/print_format/src/main.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2021 Google LLC
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr.h>
8+
9+
void main(void)
10+
{
11+
printk("d%" PRId8 "\n", INT8_C(8));
12+
printk("d%" PRId16 "\n", INT16_C(16));
13+
printk("d%" PRId32 "\n", INT32_C(32));
14+
printk("d%" PRId64 "\n", INT64_C(64));
15+
16+
printk("i%" PRIi8 "\n", INT8_C(8));
17+
printk("i%" PRIi16 "\n", INT16_C(16));
18+
printk("i%" PRIi32 "\n", INT32_C(32));
19+
printk("i%" PRIi64 "\n", INT64_C(64));
20+
21+
printk("o%" PRIo8 "\n", INT8_C(8));
22+
printk("o%" PRIo16 "\n", INT16_C(16));
23+
printk("o%" PRIo32 "\n", INT32_C(32));
24+
printk("o%" PRIo64 "\n", INT64_C(64));
25+
26+
printk("u%" PRIu8 "\n", UINT8_C(8));
27+
printk("u%" PRIu16 "\n", UINT16_C(16));
28+
printk("u%" PRIu32 "\n", UINT32_C(32));
29+
printk("u%" PRIu64 "\n", UINT64_C(64));
30+
31+
printk("x%" PRIx8 "\n", UINT8_C(8));
32+
printk("x%" PRIx16 "\n", UINT16_C(16));
33+
printk("x%" PRIx32 "\n", UINT32_C(32));
34+
printk("x%" PRIx64 "\n", UINT64_C(64));
35+
36+
printk("X%" PRIX8 "\n", UINT8_C(8));
37+
printk("X%" PRIX16 "\n", UINT16_C(16));
38+
printk("X%" PRIX32 "\n", UINT32_C(32));
39+
printk("X%" PRIX64 "\n", UINT64_C(64));
40+
}

tests/misc/print_format/testcase.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
common:
2+
harness: console
3+
harness_config:
4+
type: multi_line
5+
ordered: true
6+
regex:
7+
- "d8"
8+
- "d16"
9+
- "d32"
10+
- "d64"
11+
- "i8"
12+
- "i16"
13+
- "i32"
14+
- "i64"
15+
- "o10"
16+
- "o20"
17+
- "o40"
18+
- "o100"
19+
- "u8"
20+
- "u16"
21+
- "u32"
22+
- "u64"
23+
- "x8"
24+
- "x10"
25+
- "x20"
26+
- "x40"
27+
- "X8"
28+
- "X10"
29+
- "X20"
30+
- "X40"
31+
32+
tests:
33+
printk.format:
34+
tags: clib
35+
printk.format_newlib:
36+
tags: clib newlib
37+
filter: TOOLCHAIN_HAS_NEWLIB == 1
38+
extra_configs:
39+
- CONFIG_NEWLIB_LIBC=y

0 commit comments

Comments
 (0)