From 60b71adbfaf416989b28c91fb972620c67e2f1b5 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 10 Apr 2022 22:25:28 +0000 Subject: [PATCH] test: Don't abort fuzz test when tox_new fails. Right now, it can't fail, but later we want the fuzzer to randomly let I/O functions fail, so we shouldn't assert tox_new succeeded. --- testing/fuzzing/bootstrap_harness.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testing/fuzzing/bootstrap_harness.cc b/testing/fuzzing/bootstrap_harness.cc index 51ab52db..959d5d46 100644 --- a/testing/fuzzing/bootstrap_harness.cc +++ b/testing/fuzzing/bootstrap_harness.cc @@ -125,7 +125,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) Tox_Err_New error_new; Tox *tox = tox_new(opts, &error_new); - assert(tox != nullptr); + if (tox == nullptr) { + // It might fail, because some I/O happens in tox_new, and the fuzzer + // might do things that make that I/O fail. + return 0; + } + assert(error_new == TOX_ERR_NEW_OK); tox_options_free(opts);