aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lib/asn1.c4
-rw-r--r--test/lib/strlcat.c4
-rw-r--r--test/unicode_ut.c14
3 files changed, 11 insertions, 11 deletions
diff --git a/test/lib/asn1.c b/test/lib/asn1.c
index 8661fdd3068..a66cdd77df0 100644
--- a/test/lib/asn1.c
+++ b/test/lib/asn1.c
@@ -120,7 +120,7 @@ static int lib_asn1_x509(struct unit_test_state *uts)
cert = x509_cert_parse(cert_data, cert_data_len);
- ut_assertf(cert != NULL, "decoding failed\n");
+ ut_assertf(!IS_ERR(cert), "decoding failed\n");
ut_assertf(!strcmp(cert->subject, "Linaro: Tester"),
"subject doesn't match\n");
ut_assertf(!strcmp(cert->issuer, "Linaro: Tester"),
@@ -313,7 +313,7 @@ static int lib_asn1_pkcs7(struct unit_test_state *uts)
pkcs7 = pkcs7_parse_message(image_pk7, image_pk7_len);
- ut_assertf(pkcs7 != NULL, "decoding failed\n");
+ ut_assertf(!IS_ERR(pkcs7), "decoding failed\n");
ut_assertf(pkcs7->data_len == 104, "signature size doesn't match\n");
ut_assertf(pkcs7->signed_infos != NULL, "sign-info doesn't exist\n");
ut_assertf(pkcs7->signed_infos->msgdigest_len == 32,
diff --git a/test/lib/strlcat.c b/test/lib/strlcat.c
index a0ec037388b..d8453fe78e2 100644
--- a/test/lib/strlcat.c
+++ b/test/lib/strlcat.c
@@ -43,11 +43,11 @@ static int do_test_strlcat(struct unit_test_state *uts, int line, size_t align1,
s2[i] = 32 + 23 * i % (127 - 32);
s2[len2 - 1] = '\0';
- expected = len2 < n ? min(len1 + len2 - 1, n) : n;
+ expected = min(strlen(s2), n) + strlen(s1);
actual = strlcat(s2, s1, n);
if (expected != actual) {
ut_failf(uts, __FILE__, line, __func__,
- "strlcat(s2, s1, 2) == len2 < n ? min(len1 + len2, n) : n",
+ "strlcat(s2, s1, n) == min(len2, n) + len1",
"Expected %#zx (%zd), got %#zx (%zd)",
expected, expected, actual, actual);
return CMD_RET_FAILURE;
diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index b27d7116b9e..1d0d90c2d73 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -807,28 +807,28 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts)
/* dest and src are empty string */
memset(buf, 0, sizeof(buf));
- ret = u16_strlcat(buf, &null_src, sizeof(buf));
- ut_asserteq(1, ret);
+ ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf));
+ ut_asserteq(0, ret);
/* dest is empty string */
memset(buf, 0, sizeof(buf));
- ret = u16_strlcat(buf, src, sizeof(buf));
- ut_asserteq(5, ret);
+ ret = u16_strlcat(buf, src, ARRAY_SIZE(buf));
+ ut_asserteq(4, ret);
ut_assert(!unicode_test_u16_strcmp(buf, src, 40));
/* src is empty string */
memset(buf, 0xCD, (sizeof(buf) - sizeof(u16)));
buf[39] = 0;
memcpy(buf, dest, sizeof(dest));
- ret = u16_strlcat(buf, &null_src, sizeof(buf));
- ut_asserteq(6, ret);
+ ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf));
+ ut_asserteq(5, ret);
ut_assert(!unicode_test_u16_strcmp(buf, dest, 40));
for (i = 0; i <= 40; i++) {
memset(buf, 0xCD, (sizeof(buf) - sizeof(u16)));
buf[39] = 0;
memcpy(buf, dest, sizeof(dest));
- expected = 10;
+ expected = min(5, i) + 4;
ret = u16_strlcat(buf, src, i);
ut_asserteq(expected, ret);
if (i <= 6) {