forked from d33tah/aflize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-dir.bash
executable file
·75 lines (60 loc) · 1.58 KB
/
run-dir.bash
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
73
74
75
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TEMP=`getopt -o d: --long dir: -- "$@"`
if [ $? != 0 ]
then
exit 1
fi
eval set -- "$TEMP"
DIRS=""
while true
do
case "$1" in
-d|--dir)
TDIR="$2"
shift 2
DIRS="$DIRS $TDIR"
;;
--) shift; break;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
if [ "$DIRS" = "" ]
then
echo "You must specify at least one directory"
exit 1
fi
PKG="${1?No package specified}"
shift
VOLDIR="$DIR/$PKG-covdata"
CMD="$@"
if [ ! -d "$VOLDIR" ]
then
echo "Settuping up coverage enabled build of $PKG"
$DIR/setup-local-image.bash "$PKG"
fi
mkdir -p "$VOLDIR/lcov"
rm /tmp/cov "$VOLDIR/cov.map" || true
touch /tmp/cov
$DIR/lcov/bin/lcov -z --directory "$VOLDIR"
n=0
for testcase in $(find $DIRS -type f -printf '%p %T@\n' | sort -n -k2,2 | awk '{print $1}')
do
#lcov -z --directory "$VOLDIR"
timeout -k 60 60 $DIR/run-command.bash "$PKG" $testcase "$CMD" >&2
$DIR/lcov/bin/lcov --ignore-errors source --capture --directory "$VOLDIR" | $DIR/parse-info.py | sort -u > /tmp/new
timestamp=$(find "$testcase" -printf '%T@\n')
while read -r l
do
n=$((n+1))
echo \"$testcase\",\"$l\",\"$n\",\"$timestamp\" >> "$VOLDIR/lcov/cov.map"
done < <(comm -13 /tmp/cov /tmp/new)
cat /tmp/cov /tmp/new | sort -u > /tmp/cov2
mv /tmp/cov2 /tmp/cov
done
rm /tmp/cov
$DIR/lcov/bin/lcov --directory "$VOLDIR" --capture > /tmp/cov
$DIR/lcov/bin/genhtml --ignore-errors source -o "$VOLDIR/lcov" /tmp/cov