<commit_before>#!/bin/sh
if [ "$#" -ne 2 ]; then
    echo "Usage sh $0 num_cores ./executable_path (e.g. ./fuzz-group-dbg)"
    exit 1
fi
NUM_CORES=$1
EXECUTABLE_PATH=$2

COMPILER="afl-g++"
FLAGS=""
if [ "`uname`" = "Darwin" ]; then
    COMPILER="afl-clang++"
    FLAGS="COMPILER_IS_GCC_LIKE=yes"

    # FIXME: Consider detecting if ReportCrash was already unloaded and skip this message
    #        or print and don't try to run AFL.
    echo "----------------------------------------------------------------------------------------"
    echo "Make sure you have unloaded the OS X crash reporter:"
    echo
    echo "launchctl unload -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist"
    echo "sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.Root.plist"
    echo "----------------------------------------------------------------------------------------"
fi

# build core
cd ../../
CXX=$COMPILER make -j check-debug-norun $FLAGS

# build fuzz target
cd -
CXX=$COMPILER make -j check-debug-norun $FLAGS

# clean the findings directory
echo "Cleaning up the findings directory"
pkill afl-fuzz
rm -rf findings/* &> /dev/null

TIME_OUT="100" # ms
MEMORY="100" # MB

# if we have only one fuzzer
if [ $NUM_CORES -eq 1 ]; then
    afl-fuzz  -t $TIME_OUT -m $MEMORY -i testcases -o findings $EXECUTABLE_PATH @@
    exit 0
fi

# start the fuzzers in parallel
afl-fuzz -t $TIME_OUT -m $MEMORY -i testcases -o findings -M fuzzer1 $EXECUTABLE_PATH @@ --name fuzzer1 > /dev/null 2>&1 &

for i in `seq 2 $NUM_CORES`;
do
    afl-fuzz -t $TIME_OUT -m $MEMORY -i testcases -o findings -S fuzzer$i $EXECUTABLE_PATH @@ --name fuzzer$i > /dev/null 2>&1 &
done

echo
echo "Use afl-whatsup findings/ to check progress"
echo "Use pkill afl-fuzz to kill the fuzzers"
echo<commit_msg>Use consistent redirect in script<commit_after>#!/bin/sh
if [ "$#" -ne 2 ]; then
    echo "Usage sh $0 num_cores ./executable_path (e.g. ./fuzz-group-dbg)"
    exit 1
fi
NUM_CORES=$1
EXECUTABLE_PATH=$2

COMPILER="afl-g++"
FLAGS=""
if [ "`uname`" = "Darwin" ]; then
    COMPILER="afl-clang++"
    FLAGS="COMPILER_IS_GCC_LIKE=yes"

    # FIXME: Consider detecting if ReportCrash was already unloaded and skip this message
    #        or print and don't try to run AFL.
    echo "----------------------------------------------------------------------------------------"
    echo "Make sure you have unloaded the OS X crash reporter:"
    echo
    echo "launchctl unload -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist"
    echo "sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.Root.plist"
    echo "----------------------------------------------------------------------------------------"
fi

# build core
cd ../../
CXX=$COMPILER make -j check-debug-norun $FLAGS

# build fuzz target
cd -
CXX=$COMPILER make -j check-debug-norun $FLAGS

# clean the findings directory
echo "Cleaning up the findings directory"
pkill afl-fuzz
rm -rf findings/* &> /dev/null

TIME_OUT="100" # ms
MEMORY="100" # MB

# if we have only one fuzzer
if [ $NUM_CORES -eq 1 ]; then
    afl-fuzz  -t $TIME_OUT -m $MEMORY -i testcases -o findings $EXECUTABLE_PATH @@
    exit 0
fi

# start the fuzzers in parallel
afl-fuzz -t $TIME_OUT -m $MEMORY -i testcases -o findings -M fuzzer1 $EXECUTABLE_PATH @@ --name fuzzer1 &> /dev/null &

for i in `seq 2 $NUM_CORES`;
do
    afl-fuzz -t $TIME_OUT -m $MEMORY -i testcases -o findings -S fuzzer$i $EXECUTABLE_PATH @@ --name fuzzer$i &> /dev/null &
done

echo
echo "Use afl-whatsup findings/ to check progress"
echo "Use pkill afl-fuzz to kill the fuzzers"
echo
{'fraction_non_alphanumeric': 0.20863309352517986, 'fraction_numerical': 0.00996126175982291, 'mean_word_length': 2.247978436657682, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2242914', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1210, 'n_words': 391}