diff options
Diffstat (limited to 'regress/unittests/test_helper')
-rw-r--r-- | regress/unittests/test_helper/test_helper.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/regress/unittests/test_helper/test_helper.c b/regress/unittests/test_helper/test_helper.c index e7a47b265..127e76c2b 100644 --- a/regress/unittests/test_helper/test_helper.c +++ b/regress/unittests/test_helper/test_helper.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: test_helper.c,v 1.11 2018/11/23 02:53:57 dtucker Exp $ */ | 1 | /* $OpenBSD: test_helper.c,v 1.12 2019/08/02 01:41:24 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2011 Damien Miller <djm@mindrot.org> | 3 | * Copyright (c) 2011 Damien Miller <djm@mindrot.org> |
4 | * | 4 | * |
@@ -391,6 +391,8 @@ assert_mem(const char *file, int line, const char *a1, const char *a2, | |||
391 | const void *aa1, const void *aa2, size_t l, enum test_predicate pred) | 391 | const void *aa1, const void *aa2, size_t l, enum test_predicate pred) |
392 | { | 392 | { |
393 | int r; | 393 | int r; |
394 | char *aa1_tohex = NULL; | ||
395 | char *aa2_tohex = NULL; | ||
394 | 396 | ||
395 | if (l == 0) | 397 | if (l == 0) |
396 | return; | 398 | return; |
@@ -401,8 +403,12 @@ assert_mem(const char *file, int line, const char *a1, const char *a2, | |||
401 | r = memcmp(aa1, aa2, l); | 403 | r = memcmp(aa1, aa2, l); |
402 | TEST_CHECK_INT(r, pred); | 404 | TEST_CHECK_INT(r, pred); |
403 | test_header(file, line, a1, a2, "STRING", pred); | 405 | test_header(file, line, a1, a2, "STRING", pred); |
404 | fprintf(stderr, "%12s = %s (len %zu)\n", a1, tohex(aa1, MIN(l, 256)), l); | 406 | aa1_tohex = tohex(aa1, MIN(l, 256)); |
405 | fprintf(stderr, "%12s = %s (len %zu)\n", a2, tohex(aa2, MIN(l, 256)), l); | 407 | aa2_tohex = tohex(aa2, MIN(l, 256)); |
408 | fprintf(stderr, "%12s = %s (len %zu)\n", a1, aa1_tohex, l); | ||
409 | fprintf(stderr, "%12s = %s (len %zu)\n", a2, aa2_tohex, l); | ||
410 | free(aa1_tohex); | ||
411 | free(aa2_tohex); | ||
406 | test_die(); | 412 | test_die(); |
407 | } | 413 | } |
408 | 414 | ||
@@ -427,6 +433,7 @@ assert_mem_filled(const char *file, int line, const char *a1, | |||
427 | size_t where = -1; | 433 | size_t where = -1; |
428 | int r; | 434 | int r; |
429 | char tmp[64]; | 435 | char tmp[64]; |
436 | char *aa1_tohex = NULL; | ||
430 | 437 | ||
431 | if (l == 0) | 438 | if (l == 0) |
432 | return; | 439 | return; |
@@ -436,8 +443,10 @@ assert_mem_filled(const char *file, int line, const char *a1, | |||
436 | r = memvalcmp(aa1, v, l, &where); | 443 | r = memvalcmp(aa1, v, l, &where); |
437 | TEST_CHECK_INT(r, pred); | 444 | TEST_CHECK_INT(r, pred); |
438 | test_header(file, line, a1, NULL, "MEM_ZERO", pred); | 445 | test_header(file, line, a1, NULL, "MEM_ZERO", pred); |
446 | aa1_tohex = tohex(aa1, MIN(l, 20)); | ||
439 | fprintf(stderr, "%20s = %s%s (len %zu)\n", a1, | 447 | fprintf(stderr, "%20s = %s%s (len %zu)\n", a1, |
440 | tohex(aa1, MIN(l, 20)), l > 20 ? "..." : "", l); | 448 | aa1_tohex, l > 20 ? "..." : "", l); |
449 | free(aa1_tohex); | ||
441 | snprintf(tmp, sizeof(tmp), "(%s)[%zu]", a1, where); | 450 | snprintf(tmp, sizeof(tmp), "(%s)[%zu]", a1, where); |
442 | fprintf(stderr, "%20s = 0x%02x (expected 0x%02x)\n", tmp, | 451 | fprintf(stderr, "%20s = 0x%02x (expected 0x%02x)\n", tmp, |
443 | ((u_char *)aa1)[where], v); | 452 | ((u_char *)aa1)[where], v); |