-
Notifications
You must be signed in to change notification settings - Fork 30
/
codecoverage.sh
executable file
·52 lines (40 loc) · 1.4 KB
/
codecoverage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -ex
# Save off the current folder as the build root.
export BUILD_ROOT=$PWD
SCRIPTDIR=${BUILD_ROOT}/scripts
# Use gcc to test the code as code coverage is easier.
export CC=gcc
export CXX=g++
FUZZ_FLAG="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
export CFLAGS=""
export CXXFLAGS="$FUZZ_FLAG"
export CPPFLAGS="$FUZZ_FLAG"
OPENSSLDIR=/tmp/openssl
NGHTTPDIR=/tmp/nghttp2
INSTALLDIR=/tmp/curlcov_install
# mainline.sh and codecoverage.sh use different compilers and the ASAN and
# other LLVM specific things don't work with GCC so make sure we clean up
# if there have been earlier mainline runs locally
if [[ -d .deps/ && -f Makefile ]]
then
make distclean
fi
# Install openssl
${SCRIPTDIR}/handle_x.sh openssl ${OPENSSLDIR} ${INSTALLDIR} || exit 1
# Install nghttp2
${SCRIPTDIR}/handle_x.sh nghttp2 ${NGHTTPDIR} ${INSTALLDIR} || exit 1
# Download cURL to a temporary folder.
${SCRIPTDIR}/download_curl.sh /tmp/curlcov
# Move cURL to a subfolder of this folder to get the paths right.
if [[ -d ${BUILD_ROOT}/curl ]]
then
rm -rf ${BUILD_ROOT}/curl
fi
mv /tmp/curlcov ${BUILD_ROOT}/curl
# Compile and install cURL to a second folder with code coverage.
${SCRIPTDIR}/install_curl.sh -c ${BUILD_ROOT}/curl ${INSTALLDIR}
# Compile and test the fuzzer with code coverage
${SCRIPTDIR}/compile_fuzzer.sh -c ${INSTALLDIR}
# Do a "make check-code-coverage" run to generate the coverage info.
make check-code-coverage