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 <peress@google.com>
This commit is contained in:
Yuval Peress 2022-03-25 00:22:51 -06:00 committed by Marti Bolivar
parent 44ddb308c7
commit fab5bb9ed3
4 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,9 @@
# Copyright (c) 2021 Google LLC
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(print_format)
target_sources(app PRIVATE src/main.c)

View file

@ -0,0 +1 @@
# Empty

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2021 Google LLC
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
void main(void)
{
printk("d%" PRId8 "\n", INT8_C(8));
printk("d%" PRId16 "\n", INT16_C(16));
printk("d%" PRId32 "\n", INT32_C(32));
printk("d%" PRId64 "\n", INT64_C(64));
printk("i%" PRIi8 "\n", INT8_C(8));
printk("i%" PRIi16 "\n", INT16_C(16));
printk("i%" PRIi32 "\n", INT32_C(32));
printk("i%" PRIi64 "\n", INT64_C(64));
printk("o%" PRIo8 "\n", INT8_C(8));
printk("o%" PRIo16 "\n", INT16_C(16));
printk("o%" PRIo32 "\n", INT32_C(32));
printk("o%" PRIo64 "\n", INT64_C(64));
printk("u%" PRIu8 "\n", UINT8_C(8));
printk("u%" PRIu16 "\n", UINT16_C(16));
printk("u%" PRIu32 "\n", UINT32_C(32));
printk("u%" PRIu64 "\n", UINT64_C(64));
printk("x%" PRIx8 "\n", UINT8_C(8));
printk("x%" PRIx16 "\n", UINT16_C(16));
printk("x%" PRIx32 "\n", UINT32_C(32));
printk("x%" PRIx64 "\n", UINT64_C(64));
printk("X%" PRIX8 "\n", UINT8_C(8));
printk("X%" PRIX16 "\n", UINT16_C(16));
printk("X%" PRIX32 "\n", UINT32_C(32));
printk("X%" PRIX64 "\n", UINT64_C(64));
}

View file

@ -0,0 +1,39 @@
common:
harness: console
harness_config:
type: multi_line
ordered: true
regex:
- "d8"
- "d16"
- "d32"
- "d64"
- "i8"
- "i16"
- "i32"
- "i64"
- "o10"
- "o20"
- "o40"
- "o100"
- "u8"
- "u16"
- "u32"
- "u64"
- "x8"
- "x10"
- "x20"
- "x40"
- "X8"
- "X10"
- "X20"
- "X40"
tests:
printk.format:
tags: clib
printk.format_newlib:
tags: clib newlib
filter: TOOLCHAIN_HAS_NEWLIB == 1
extra_configs:
- CONFIG_NEWLIB_LIBC=y