forked from microsoft/onefuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource-coverage.sh
More file actions
executable file
·48 lines (37 loc) · 1.1 KB
/
source-coverage.sh
File metadata and controls
executable file
·48 lines (37 loc) · 1.1 KB
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
#!/bin/bash
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
set -ex
if [ $# -lt 3 ]; then
echo usage: FUZZER RESULT_DIR FILE [... FILE_N]
exit 1
fi
FUZZER=$1; shift
RESULTS=$1; shift
mkdir -p ${RESULTS}/inputs
MERGED=${RESULTS}/coverage.profdata
REPORT=${RESULTS}/coverage.report
LCOV=${RESULTS}/coverage.lcov
COV_TOOL=$(which llvm-cov || which llvm-cov-10)
PROF_TOOL=$(which llvm-profdata || which llvm-profdata-10)
for file in $@; do
SHA=$(sha256sum ${file} | cut -d ' ' -f 1)
RAW=${RESULTS}/inputs/${SHA}.profraw
if [ -f ${RAW} ]; then
continue
fi
LLVM_PROFILE_FILE=${RAW} ${FUZZER} ${file}
if [ ! -f ${RAW} ]; then
echo "no coverage file generated ${RAW}"
exit 1
fi
if [ -f ${MERGED} ]; then
${PROF_TOOL} merge -output ${MERGED}.tmp ${RAW} ${MERGED}
mv ${MERGED}.tmp ${MERGED}
else
${PROF_TOOL} merge -output ${MERGED} ${RAW}
fi
${COV_TOOL} export ${FUZZER} -instr-profile=${MERGED} > ${REPORT}
${COV_TOOL} export ${FUZZER} -instr-profile=${MERGED} --format lcov > ${LCOV}
done