-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimizing.sh
executable file
·72 lines (52 loc) · 1.31 KB
/
minimizing.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -x
set -e
MINDIR=.minimizing
rm -vrf $MINDIR
mkdir -vp $MINDIR
# ## freeze original coverage
rm -rf $MINDIR/htmlcov
rm -vf .coverage
# skip instrument due we do not require new corpus but coverage
export SKIP_ATHERIS_INSTRUMENT=1
python -m coverage run \
--source=. \
fuzz.py \
-rss_limit_mb=2048 \
-atheris_runs=$(( 1 + $(ls corpus | wc -l) )) \
-verbosity=1 \
corpus/ \
;
original_cov="$(python -m coverage report | tail -1)"
python -m coverage html
mv htmlcov $MINDIR
# ## run minimization for all corpuses
declare -a CORPUS
i=0
for f in $(ls corpus | shuf); do
CORPUS[$i]+=$f
i=$(( 1 + $i ))
done
for f in ${CORPUS[@]}; do
echo "test $f"
mkdir -vp $MINDIR/$f
mv -vf corpus/$f $MINDIR/$f/
python -m coverage run \
--source=. \
fuzz.py \
-rss_limit_mb=2048 \
-atheris_runs=$(( 1 + $(ls corpus | wc -l) )) \
-verbosity=1 \
corpus/ \
;
python -m coverage html
mv htmlcov $MINDIR/$f/
python -m coverage report >$MINDIR/$f/report.txt
test_cov="$(tail -1 $MINDIR/$f/report.txt)"
if [ "$test_cov" != "$original_cov" ]; then
echo "corpus $f impacts on coverage"
cp -v $MINDIR/$f/$f corpus/
else
echo "corpus $f does not impact on coverage"
fi
done