Skip to content

Commit 7a8496d

Browse files
committed
better debug output
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent cf58641 commit 7a8496d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tests/der_test.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ int der_test(void)
17011701
for (z = 0; z < 1024; z++) {
17021702
#endif
17031703
if (yarrow_read(buf[0], z, &yarrow_prng) != z) {
1704-
fprintf(stderr, "Failed to read %lu bytes from yarrow\n", z);
1704+
fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, z);
17051705
return 1;
17061706
}
17071707
DO(mp_read_unsigned_bin(a, buf[0], z));
@@ -1724,7 +1724,7 @@ int der_test(void)
17241724
for (zz = 0; zz < 256; zz++) {
17251725
for (z = 1; z < 4; z++) {
17261726
if (yarrow_read(buf[2], z, &yarrow_prng) != z) {
1727-
fprintf(stderr, "Failed to read %lu bytes from yarrow\n", z);
1727+
fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, z);
17281728
return 1;
17291729
}
17301730
/* encode with normal */
@@ -1763,7 +1763,10 @@ int der_test(void)
17631763

17641764
/* Test bit string */
17651765
for (zz = 1; zz < 1536; zz++) {
1766-
yarrow_read(buf[0], zz, &yarrow_prng);
1766+
if (yarrow_read(buf[0], zz, &yarrow_prng) != zz) {
1767+
fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, zz);
1768+
return 1;
1769+
}
17671770
for (z = 0; z < zz; z++) {
17681771
buf[0][z] &= 0x01;
17691772
}
@@ -1785,7 +1788,10 @@ int der_test(void)
17851788

17861789
/* Test octet string */
17871790
for (zz = 1; zz < 1536; zz++) {
1788-
yarrow_read(buf[0], zz, &yarrow_prng);
1791+
if (yarrow_read(buf[0], zz, &yarrow_prng) != zz) {
1792+
fprintf(stderr, "%d: Failed to read %lu bytes from yarrow\n", __LINE__, zz);
1793+
return 1;
1794+
}
17891795
x = sizeof(buf[1]);
17901796
DO(der_encode_octet_string(buf[0], zz, buf[1], &x));
17911797
DO(der_length_octet_string(zz, &y));
@@ -1823,7 +1829,10 @@ int der_test(void)
18231829
/* do random strings */
18241830
for (zz = 0; zz < 5000; zz++) {
18251831
/* pick a random number of words */
1826-
yarrow_read(buf[0], 4, &yarrow_prng);
1832+
if (yarrow_read(buf[0], 4, &yarrow_prng) != 4) {
1833+
fprintf(stderr, "%d: Failed to read %d bytes from yarrow\n", __LINE__, 4);
1834+
return 1;
1835+
}
18271836
LOAD32L(z, buf[0]);
18281837
z = 2 + (z % ((sizeof(oid[0])/sizeof(oid[0][0])) - 2));
18291838

@@ -1832,7 +1841,10 @@ int der_test(void)
18321841
oid[0][1] = buf[0][1] % 40;
18331842

18341843
for (y = 2; y < z; y++) {
1835-
yarrow_read(buf[0], 4, &yarrow_prng);
1844+
if (yarrow_read(buf[0], 4, &yarrow_prng) != 4) {
1845+
fprintf(stderr, "%d: Failed to read %d bytes from yarrow\n", __LINE__, 4);
1846+
return 1;
1847+
}
18361848
LOAD32L(oid[0][y], buf[0]);
18371849
}
18381850

0 commit comments

Comments
 (0)