Skip to content

Commit dca079d

Browse files
author
Sharron LIU
committed
tests:kernel: added tests for printk left justifier
Added test case for printk the '-' indicator in format string (left justifier). Jira: ZEP-1599 Signed-off-by: Sharron LIU <[email protected]>
1 parent b7f6aaa commit dca079d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/kernel/common/src/printk.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ char *expected = "22 113 10000 32768 40000 22\n"
2323
"-42 -42 -042 -0000042\n"
2424
"42 42 42 42\n"
2525
"42 42 0042 00000042\n"
26+
"255 42 abcdef 0x0000002a 42\n"
2627
;
2728

2829

@@ -71,6 +72,7 @@ void printk_test(void)
7172
printk("%d %02d %04d %08d\n", -42, -42, -42, -42);
7273
printk("%u %2u %4u %8u\n", 42, 42, 42, 42);
7374
printk("%u %02u %04u %08u\n", 42, 42, 42, 42);
75+
printk("%-8u%-6d%-4x%-2p%8d\n", 0xFF, 42, 0xABCDEF, (char *)42, 42);
7476

7577
ram_console[pos] = '\0';
7678
zassert_true((strcmp(ram_console, expected) == 0), "printk failed");
@@ -97,7 +99,9 @@ void printk_test(void)
9799
"%u %2u %4u %8u\n", 42, 42, 42, 42);
98100
count += snprintk(ram_console + count, sizeof(ram_console) - count,
99101
"%u %02u %04u %08u\n", 42, 42, 42, 42);
100-
102+
count += snprintk(ram_console + count, sizeof(ram_console) - count,
103+
"%-8u%-6d%-4x%-2p%8d\n",
104+
0xFF, 42, 0xABCDEF, (char *)42, 42);
101105
ram_console[count] = '\0';
102106
zassert_true((strcmp(ram_console, expected) == 0), "snprintk failed");
103107
}

0 commit comments

Comments
 (0)