forked from arminbiere/aiger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunaigcnfuzz
executable file
·45 lines (45 loc) · 1006 Bytes
/
runaigcnfuzz
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
#!/bin/sh
die () {
echo "*** runaigcnfuzz: $*" 1>&2
exit 1
}
prg=""
while [ $# -gt 0 ]
do
case $1 in
-h) echo "usage: runaigcnfuzz <prg>";exit 0;;
-*) die "invalid command line option";;
*) prg=$1;;
esac
shift
done
[ x"$prg" = x ] && die "no program specified"
aig=/tmp/runaigcnfuzz-$$.aig
cnf=/tmp/runaigcnfuzz-$$.cnf
log=runaigcnfuzz-$$.log
rm -f $log
trap "rm -f $cnf;exit 1" 2
i=0
echo "[runaigcnfuzz] running $prg"
echo "[runaigcnfuzz] logging $log"
while true
do
rm -f $cnf $aig
aigfuzz -m > $aig
aigtocnf $aig > $cnf
seed=`aiginfo $aig|awk '/^seed /{print $NF}'`
head="`awk '/p cnf /{print $3, $4}' $cnf`"
echo -n "$i $seed $head\r"
i=`expr $i + 1`
$prg $cnf 1>/dev/null 2>/dev/null
case $? in
10|20) continue;;
esac
echo "[runaigcnfuzz] failing seed: $seed"
echo $seed >> $log
red=reduced-$seed
ddcnfuzzed $seed $prg 1>/dev/null 2>/dev/null
head="`awk '/p cnf /{print $3, $4}' $red`"
echo "[runaigcnfuzz] $red $head"
rm -f bug-$seed
done