diff options
author | Christopher Ferris <cferris@google.com> | 2017-08-11 02:04:47 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-11 02:04:47 +0000 |
commit | 30438e4cea83628bcacbedff37a35398bb8b40e7 (patch) | |
tree | d0dab96c8f737ae4058b1e144ced6418823b5b77 /benchmarks/string_benchmark.cpp | |
parent | 73c3be22199a42bed53245b9b648e276de0b6422 (diff) | |
parent | a98a5fb63ee00bbd7f1663192453efcdf117cb92 (diff) |
Merge "Improve error handling and fix minor bugs in bionic benchmarks."
Diffstat (limited to 'benchmarks/string_benchmark.cpp')
-rw-r--r-- | benchmarks/string_benchmark.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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 <err.h> #include <stdint.h> #include <string.h> @@ -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<char> 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."); } } |