#!/usr/bin/env bash

source $(dirname "$0")/tools.sh

cp -a "${VCS_PATH}/nss" .
[ -d nspr ] || git clone https://github.com/mozilla/nspr nspr

pushd nspr
git checkout -- .
if [[ -f ../nss/nspr.patch && "$ALLOW_NSPR_PATCH" == "1" ]]; then
  cat ../nss/nspr.patch | patch -p1
fi
popd

out=/builds/worker/artifacts
mkdir -p $out

cd nss
export PYTHONUNBUFFERED=1
./mach fuzz-coverage --outdir=$out --base-rev="$NSS_BASE_REV"
