llvm-project/llvm/lib/Fuzzer/fuzzer-test-suite/common.sh

30 lines
802 B
Bash

#!/bin/bash
# Don't allow to call these scripts from their directories.
[ -e $(basename $0) ] && echo "PLEASE USE THIS SCRIPT FROM ANOTHER DIR" && exit 1
SCRIPT_DIR=$(dirname $0)
EXECUTABLE_NAME_BASE=$(basename $SCRIPT_DIR)
LIBFUZZER_SRC=$(dirname $(dirname $SCRIPT_DIR))
FUZZ_CXXFLAGS="-O2 -g -fsanitize=address -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div"
CORPUS=CORPUS-$EXECUTABLE_NAME_BASE
JOBS=8
get_git_revision() {
GIT_REPO="$1"
GIT_REVISION="$2"
TO_DIR="$3"
[ ! -e $TO_DIR ] && git clone $GIT_REPO $TO_DIR && (cd $TO_DIR && git reset --hard $GIT_REVISION)
}
get_git_tag() {
GIT_REPO="$1"
GIT_TAG="$2"
TO_DIR="$3"
[ ! -e $TO_DIR ] && git clone $GIT_REPO $TO_DIR && (cd $TO_DIR && git checkout $GIT_TAG)
}
build_libfuzzer() {
$LIBFUZZER_SRC/build.sh
}