From f73d47dfb897e22294383aee95460fb30bff4f4d Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Thu, 20 Mar 2025 15:10:14 +0100 Subject: [PATCH] More stable `just test` for `libfuzzer_stb_image_sugar` (#3097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * aa * tab to space * bash syntax is ❤❤❤❤ --- .../libfuzzer_stb_image_sugar/Justfile | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fuzzers/inprocess/libfuzzer_stb_image_sugar/Justfile b/fuzzers/inprocess/libfuzzer_stb_image_sugar/Justfile index 4fa6f647f9..ac06cf0f29 100644 --- a/fuzzers/inprocess/libfuzzer_stb_image_sugar/Justfile +++ b/fuzzers/inprocess/libfuzzer_stb_image_sugar/Justfile @@ -35,17 +35,26 @@ run: fuzzer [macos] test: fuzzer #!/bin/bash + success=0 rm -rf libafl_unix_shmem_server || true - (timeout 31s ./{{FUZZER_NAME}} | tee fuzz_stdout.log 2>/dev/null || true) & + (timeout 5s ./{{FUZZER_NAME}} >fuzz_stdout.log 2>/dev/null || true) & sleep 0.2 - timeout 30s ./{{FUZZER_NAME}} >/dev/null 2>/dev/null || true - if grep -qa "corpus: 30" fuzz_stdout.log; then - echo "Fuzzer is working" + timeout 5s ./{{FUZZER_NAME}} >/dev/null 2>/dev/null || true + while read -r line; do + corpus_number=$(echo "$line" | cut -d' ' -f2) + if (( corpus_number > 50 )); then + success=1 + fi + done < <(grep -o 'corpus: [0-9]\+' fuzz_stdout.log) + + if [ "$success" -eq 1 ]; then + echo "Fuzzer is working!" + exit 0 else - echo "Fuzzer does not generate any testcases or any crashes" + echo "Fuzzer not working!" exit 1 fi - + clean: #!/bin/bash rm -f {{FUZZER_NAME}}