From a98a5fb63ee00bbd7f1663192453efcdf117cb92 Mon Sep 17 00:00:00 2001 From: Anders Lewis Date: Wed, 9 Aug 2017 16:52:19 -0700 Subject: Improve error handling and fix minor bugs in bionic benchmarks. Test: Unit tests. Change-Id: I224ae4c7f195176eb8a87deddb2debcbf0f24ba3 --- benchmarks/string_benchmark.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'benchmarks/string_benchmark.cpp') diff --git a/benchmarks/string_benchmark.cpp b/benchmarks/string_benchmark.cpp index 94e7583f6..eb04c9396 100644 --- a/benchmarks/string_benchmark.cpp +++ b/benchmarks/string_benchmark.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -263,7 +264,7 @@ static void BM_string_strstr(benchmark::State& state) { while (state.KeepRunning()) { if (strstr(haystack_aligned, needle_aligned) == nullptr) { - abort(); + errx(1, "ERROR: strstr failed to find valid substring."); } } @@ -277,10 +278,11 @@ static void BM_string_strchr(benchmark::State& state) { std::vector haystack; char* haystack_aligned = GetAlignedPtrFilled(&haystack, haystack_alignment, nbytes, 'x'); + haystack_aligned[nbytes-1] = '\0'; while (state.KeepRunning()) { if (strchr(haystack_aligned, 'y') != nullptr) { - abort(); + errx(1, "ERROR: strchr found a chr where it should have failed."); } } -- cgit v1.2.3