Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests:kernel: added tests for printk left justifier #25

Merged
merged 1 commit into from
May 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/kernel/common/src/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ char *expected = "22 113 10000 32768 40000 22\n"
"-42 -42 -042 -0000042\n"
"42 42 42 42\n"
"42 42 0042 00000042\n"
"255 42 abcdef 0x0000002a 42\n"
;


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

ram_console[pos] = '\0';
zassert_true((strcmp(ram_console, expected) == 0), "printk failed");
Expand All @@ -97,7 +99,9 @@ void printk_test(void)
"%u %2u %4u %8u\n", 42, 42, 42, 42);
count += snprintk(ram_console + count, sizeof(ram_console) - count,
"%u %02u %04u %08u\n", 42, 42, 42, 42);

count += snprintk(ram_console + count, sizeof(ram_console) - count,
"%-8u%-6d%-4x%-2p%8d\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the %-2p doesn't seem to work as intended as it's still printing: 0x00000042, was it supposed to print "0x42" instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. You're right, prefix '0' should be unexpected. Thanks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failure tracked as ZEP-2102

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZEP-2102 has been justified by developer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @lpereira, lets adapt the test, making printk always behave as printf is a none goal, printk is a custom version that needs to be small and usable on the smallest of devices.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests adapted.

0xFF, 42, 0xABCDEF, (char *)42, 42);
ram_console[count] = '\0';
zassert_true((strcmp(ram_console, expected) == 0), "snprintk failed");
}