diff --git a/tests/lib/cbprintf_package/prj.conf b/tests/lib/cbprintf_package/prj.conf index 6dc80c0d7b7..9467c292689 100644 --- a/tests/lib/cbprintf_package/prj.conf +++ b/tests/lib/cbprintf_package/prj.conf @@ -1,2 +1 @@ CONFIG_ZTEST=y -CONFIG_CBPRINTF_COMPLETE=y diff --git a/tests/lib/cbprintf_package/src/main.c b/tests/lib/cbprintf_package/src/main.c index aedd482a5bd..7af886b3fe4 100644 --- a/tests/lib/cbprintf_package/src/main.c +++ b/tests/lib/cbprintf_package/src/main.c @@ -27,7 +27,8 @@ static int out(int c, void *dest) return rv; } -static char runtime_buf[128]; +static char static_buf[512]; +static char runtime_buf[512]; static char compare_buf[128]; void dump(const char *desc, uint8_t *package, size_t len) @@ -58,13 +59,23 @@ void unpack(const char *desc, struct out_buffer *buf, }; \ int rc = cbprintf_package(NULL, 0, fmt, __VA_ARGS__); \ zassert_true(rc > 0, "cbprintf_package() returned %d", rc); \ - size_t len = rc; \ - uint8_t __aligned(8) rt_package[len]; \ + int len = rc; \ + /* Aligned so the package is similar to the static one. */ \ + uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) rt_package[len]; \ memset(rt_package, 0, len); \ rc = cbprintf_package(rt_package, len, fmt, __VA_ARGS__); \ zassert_equal(rc, len, "cbprintf_package() returned %d, expected %d", rc, len); \ dump("runtime", rt_package, len); \ unpack("runtime", &rt_buf, rt_package, len); \ + \ + struct out_buffer st_buf = { \ + .buf = static_buf, .idx = 0, .size = sizeof(static_buf) \ + }; \ + CBPRINTF_STATIC_PACKAGE(NULL, 0, len, fmt, __VA_ARGS__); \ + uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) package[len]; \ + CBPRINTF_STATIC_PACKAGE(package, len, len, fmt, __VA_ARGS__); \ + dump("static", package, len); \ + unpack("static", &st_buf, package, len); \ } while (0) void test_cbprintf_package(void) @@ -97,6 +108,11 @@ void test_cbprintf_package(void) TEST_PACKAGING("test %c %p", c, &c); if (IS_ENABLED(CONFIG_CBPRINTF_FP_SUPPORT)) { TEST_PACKAGING("test %f %a", f, d); +#if CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE + long double ld = 1.2333; + + TEST_PACKAGING("test %Lf", ld); +#endif } } diff --git a/tests/lib/cbprintf_package/testcase.yaml b/tests/lib/cbprintf_package/testcase.yaml index e8ee855d366..c6733a15a6f 100644 --- a/tests/lib/cbprintf_package/testcase.yaml +++ b/tests/lib/cbprintf_package/testcase.yaml @@ -7,6 +7,9 @@ tests: qemu_arc_em qemu_arc_hs qemu_cortex_a53 qemu_cortex_m0 qemu_cortex_m3 qemu_cortex_r5 qemu_leon3 qemu_nios2 qemu_riscv32 qemu_riscv64 qemu_x86 qemu_x86_64 qemu_xtensa + extra_configs: + - CONFIG_CBPRINTF_COMPLETE=y + libraries.cbprintf_package_fp: tags: cbprintf integration_platforms: @@ -17,3 +20,29 @@ tests: qemu_x86_64 qemu_xtensa extra_configs: - CONFIG_CBPRINTF_FP_SUPPORT=y + - CONFIG_CBPRINTF_COMPLETE=y + + libraries.cbprintf_package_long_double: + tags: cbprintf + integration_platforms: + - native_posix + platform_allow: > + qemu_arc_em qemu_arc_hs qemu_cortex_a53 qemu_cortex_m0 qemu_cortex_m3 + qemu_cortex_r5 qemu_leon3 qemu_nios2 qemu_riscv64 + qemu_x86_64 qemu_xtensa + platform_exclude: qemu_riscv32 + extra_configs: + - CONFIG_CBPRINTF_FP_SUPPORT=y + - CONFIG_CBPRINTF_COMPLETE=y + - CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE=y + + libraries.cbprintf_package_nano: + tags: cbprintf + integration_platforms: + - native_posix + platform_allow: > + qemu_arc_em qemu_arc_hs qemu_cortex_a53 qemu_cortex_m0 qemu_cortex_m3 + qemu_cortex_r5 qemu_leon3 qemu_nios2 qemu_riscv32 qemu_riscv64 qemu_x86 + qemu_x86_64 qemu_xtensa + extra_configs: + - CONFIG_CBPRINTF_NANO=y