aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-11-20 09:36:37 -0500
committerTom Rini <trini@konsulko.com>2021-11-20 09:36:37 -0500
commit2ad8d0cb950da2233a2ec030533f4e54c6d04126 (patch)
treea4505235689e4fb85770a72a6f57c249a5832a0c /test
parent454a97485a1854d4ac4f3b7d408caf3b355beca0 (diff)
parentd6b55a420cfce660343cc1f60e68fcad0157925a (diff)
Merge branch 'efi-2022-01' of https://source.denx.de/u-boot/custodians/u-boot-efi
Scripts: * Update spelling.txt LMB: * remove extern keyword in lmb.h * drop unused lmb_size_bytes() Test: * test truncation in snprintf() Documentation: * add include/lmb.h to HTML documentation UEFI: * reduce non-debug logging output for measured boot * fix use after free in measured boot * startup the tpm device when installing the protocol * implement EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES * record capsule result only if capsule is read
Diffstat (limited to 'test')
-rw-r--r--test/lib/lmb.c5
-rw-r--r--test/print_ut.c18
2 files changed, 23 insertions, 0 deletions
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index b2c2b99ef1..157c26394d 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -12,6 +12,11 @@
#include <test/test.h>
#include <test/ut.h>
+static inline bool lmb_is_nomap(struct lmb_property *m)
+{
+ return m->flags & LMB_NOMAP;
+}
+
static int check_lmb(struct unit_test_state *uts, struct lmb *lmb,
phys_addr_t ram_base, phys_size_t ram_size,
unsigned long num_reserved,
diff --git a/test/print_ut.c b/test/print_ut.c
index 152a8c3334..7b2e7bb152 100644
--- a/test/print_ut.c
+++ b/test/print_ut.c
@@ -31,6 +31,7 @@ static int print_guid(struct unit_test_state *uts)
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
};
char str[40];
+ int ret;
sprintf(str, "%pUb", guid);
ut_assertok(strcmp("01020304-0506-0708-090a-0b0c0d0e0f10", str));
@@ -40,6 +41,9 @@ static int print_guid(struct unit_test_state *uts)
ut_assertok(strcmp("04030201-0605-0807-090a-0b0c0d0e0f10", str));
sprintf(str, "%pUL", guid);
ut_assertok(strcmp("04030201-0605-0807-090A-0B0C0D0E0F10", str));
+ ret = snprintf(str, 4, "%pUL", guid);
+ ut_asserteq(0, str[3]);
+ ut_asserteq(36, ret);
return 0;
}
@@ -349,6 +353,20 @@ static int print_itoa(struct unit_test_state *uts)
}
PRINT_TEST(print_itoa, 0);
+static int snprint(struct unit_test_state *uts)
+{
+ char buf[10] = "xxxxxxxxx";
+ int ret;
+
+ ret = snprintf(buf, 4, "%s:%s", "abc", "def");
+ ut_asserteq(0, buf[3]);
+ ut_asserteq(7, ret);
+ ret = snprintf(buf, 4, "%s:%d", "abc", 9999);
+ ut_asserteq(8, ret);
+ return 0;
+}
+PRINT_TEST(snprint, 0);
+
static int print_xtoa(struct unit_test_state *uts)
{
ut_asserteq_str("7f", simple_xtoa(127));