diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-05 08:30:35 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-05 08:30:35 -0400 |
commit | 3b61bdb5aebe3890443e39eed4d79da93aa19c8b (patch) | |
tree | 946b5a25ea856d027319d07cf7eaa6f1eebea4aa /src/test/bench.c | |
parent | 03efb67b42ce88ca6073eadc1b66d6151d646607 (diff) | |
download | tor-3b61bdb5aebe3890443e39eed4d79da93aa19c8b.tar.gz tor-3b61bdb5aebe3890443e39eed4d79da93aa19c8b.zip |
Try to fix new coverity warnings in unit tests.
Diffstat (limited to 'src/test/bench.c')
-rw-r--r-- | src/test/bench.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/test/bench.c b/src/test/bench.c index 3594059057..959d4374b1 100644 --- a/src/test/bench.c +++ b/src/test/bench.c @@ -473,18 +473,19 @@ bench_digest(void) for (int i = 0; lens[i] > 0; ++i) { reset_perftime(); start = perftime(); + int failures = 0; for (int j = 0; j < N; ++j) { switch (alg) { case DIGEST_SHA1: - crypto_digest(out, buf, lens[i]); + failures += crypto_digest(out, buf, lens[i]) < 0; break; case DIGEST_SHA256: case DIGEST_SHA3_256: - crypto_digest256(out, buf, lens[i], alg); + failures += crypto_digest256(out, buf, lens[i], alg) < 0; break; case DIGEST_SHA512: case DIGEST_SHA3_512: - crypto_digest512(out, buf, lens[i], alg); + failures += crypto_digest512(out, buf, lens[i], alg) < 0; break; default: tor_assert(0); @@ -494,6 +495,8 @@ bench_digest(void) printf("%s(%d): %.2f ns per call\n", crypto_digest_algorithm_get_name(alg), lens[i], NANOCOUNT(start,end,N)); + if (failures) + printf("ERROR: crypto_digest failed %d times.\n", failures); } } } |