|
Lines 391-396
assert_mem(const char *file, int line, const char *a1, const char *a2,
Link Here
|
| 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; |
|
Lines 401-408
assert_mem(const char *file, int line, const char *a1, const char *a2,
Link Here
|
| 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 |
|
|
Lines 427-432
assert_mem_filled(const char *file, int line, const char *a1,
Link Here
|
| 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; |
|
Lines 436-443
assert_mem_filled(const char *file, int line, const char *a1,
Link Here
|
| 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); |
| 444 |
- |
|
|