From 04641c14071865f3d6b8d39a8ab12a1afa9bda72 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 16 Jan 2022 13:22:06 +0100 Subject: [PATCH] test: add test for %pUs Add a unit test for the %pUs printf code. Use ut_asserteq_str() for checking string results. Signed-off-by: Heinrich Schuchardt --- test/print_ut.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/print_ut.c b/test/print_ut.c index 7b2e7bb152..194387f169 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -30,17 +30,29 @@ static int print_guid(struct unit_test_state *uts) unsigned char guid[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + unsigned char guid_esp[16] = { + 0x28, 0x73, 0x2a, 0xc1, 0x1f, 0xf8, 0xd2, 0x11, + 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B + }; char str[40]; int ret; sprintf(str, "%pUb", guid); - ut_assertok(strcmp("01020304-0506-0708-090a-0b0c0d0e0f10", str)); + ut_asserteq_str("01020304-0506-0708-090a-0b0c0d0e0f10", str); sprintf(str, "%pUB", guid); - ut_assertok(strcmp("01020304-0506-0708-090A-0B0C0D0E0F10", str)); + ut_asserteq_str("01020304-0506-0708-090A-0B0C0D0E0F10", str); sprintf(str, "%pUl", guid); - ut_assertok(strcmp("04030201-0605-0807-090a-0b0c0d0e0f10", str)); + ut_asserteq_str("04030201-0605-0807-090a-0b0c0d0e0f10", str); + sprintf(str, "%pUs", guid); + ut_asserteq_str("04030201-0605-0807-090a-0b0c0d0e0f10", str); sprintf(str, "%pUL", guid); - ut_assertok(strcmp("04030201-0605-0807-090A-0B0C0D0E0F10", str)); + ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str); + sprintf(str, "%pUs", guid_esp); + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { /* brace needed */ + ut_asserteq_str("system", str); + } else { + ut_asserteq_str("c12a7328-f81f-11d2-ba4b-00a0c93ec93b", str); + } ret = snprintf(str, 4, "%pUL", guid); ut_asserteq(0, str[3]); ut_asserteq(36, ret); -- 2.39.5