Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / test / test-compile.sh @ c1adf235

History | View | Annotate | Download (6.25 KB)

1
#!/bin/bash
2

    
3
eval set -- $(getopt -n $0 -o "-aciwvh:" -- "$@")
4

    
5
declare c i w h a v
6
declare -a files
7

    
8
#SRC_PREFIX="../.."
9
SRC_PREFIX=`svn info --xml | grep wcroot | sed "s/<[^>]*>//g"`/lustre_compiler
10
NOW=`date "+%y%m%d%H%M"`
11
report=`pwd`/report-$NOW
12
#LUSTREC="../../_build/src/lustrec"
13
LUSTREC=lustrec
14
mkdir -p build
15
build=`pwd`"/build"
16
    
17

    
18
base_compile() {
19
    while IFS=, read -r file main opts
20
    do
21
	name=`basename "$file" .lus`
22
	dir=${SRC_PREFIX}/`dirname "$file"`
23
	pushd $dir > /dev/null
24
    if [ "$main" != "" ]; then
25
	$LUSTREC -d $build -verbose 0 $opts -node $main "$name".lus;
26
        if [ $? -ne 0 ]; then
27
            rlustrec1="INVALID";
28
        else
29
            rlustrec1="VALID"
30
	fi
31
	pushd $build > /dev/null
32
        gcc -c -Wall -Wno-unused-but-set-variable -I ../../include/ "$name".c > /dev/null
33
	popd > /dev/null
34
        if [ $? -ne 0 ]; then
35
            rgcc1="INVALID";
36
        else
37
            rgcc1="VALID"
38
	fi	
39
    else
40
	$LUSTREC -d $build -verbose 0 $opts "$name".lus;
41
        if [ $? -ne 0 ]; then
42
            rlustrec1="INVALID";
43
        else
44
            rlustrec1="VALID"
45
        fi
46
	pushd $build > /dev/null
47
        gcc -c -Wall -Wno-unused-but-set-variable -I ../../include/ "$name".c > /dev/null
48
	popd > /dev/null
49
        if [ $? -ne 0 ]; then
50
            rgcc1="INVALID";
51
        else
52
            rgcc1="VALID"
53
        fi
54
    fi
55
    popd > /dev/null
56
    if [ $verbose -gt 0 ]; then
57
	echo "lustrec ($rlustrec1), gcc($rgcc1), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report;
58
    else
59
	echo "lustrec ($rlustrec1), gcc($rgcc1), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report | grep "INVALID\|ERROR\|UNKNOWN"
60
    fi;
61
    done < $file_list
62
}
63

    
64
inline_compile () {
65
    while IFS=, read -r file main opts
66
    do
67
	name=`basename "$file" .lus`
68
	dir=${SRC_PREFIX}/`dirname "$file"`
69

    
70
	pushd $dir > /dev/null
71

    
72
# Checking inlining
73
    $LUSTREC -d $build -verbose 0 $opts -inline -witnesses -node $main "$name".lus;
74
    if [ $? -ne 0 ]; then
75
        rlustrec2="INVALID";
76
    else
77
        rlustrec2="VALID"
78
    fi
79
    pushd $build > /dev/null
80
    gcc -c -Wall -Wno-unused-but-set-variable -I ../../include/ "$name".c > /dev/null
81
    popd > /dev/null
82
    if [ $? -ne 0 ]; then
83
        rgcc2="INVALID";
84
    else
85
        rgcc2="VALID"
86
    fi	
87
    if [ $verbose -gt 0 ]; then
88
	echo "lustrec inlined ($rlustrec2), gcc ($rgcc2), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report;
89
    else
90
	echo "lustrec inlined ($rlustrec2), gcc ($rgcc2), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report | grep "INVALID\|ERROR\|UNKNOWN"
91
    fi;
92
    popd > /dev/null
93
done < $file_list
94
}
95

    
96
inline_compile_with_check () {
97
# Checking inlining
98
    while IFS=, read -r file main opts
99
    do
100
	name=`basename "$file" .lus`
101
	dir=${SRC_PREFIX}/`dirname "$file"`
102
	pushd $dir > /dev/null
103
    $LUSTREC -d $build -verbose 0 $opts -inline -witnesses -node $main "$name".lus;
104
    if [ $? -ne 0 ]; then
105
        rlustrec2="INVALID";
106
    else
107
        rlustrec2="VALID"
108
    fi
109
    pushd $build > /dev/null
110
    gcc -c -Wall -Wno-unused-but-set-variable -I ../../include/ "$name".c > /dev/null
111
    popd > /dev/null
112
    if [ $? -ne 0 ]; then
113
        rgcc2="INVALID";
114
    else
115
        rgcc2="VALID"
116
    fi	
117
	# Cheching witness
118
    pushd $build > /dev/null
119
    $LUSTREC -verbose 0 -horn -d $build/${name}_witnesses -node check $build/${name}_witnesses/inliner_witness.lus 
120
    popd > /dev/null
121
    z3="`z3 -T:10 $build/${name}_witnesses/inliner_witness.smt2 | xargs`"
122
    if [ "x`echo $z3 | grep unsat`" == "xunsat" ]; then
123
	rinlining="VALID";
124
    elif [ "x`echo $z3 | xargs | grep -o error`" == "xerror" ]; then
125
	rinlining="ERROR";
126
    elif [ "x`echo $z3 | xargs | grep -o unknown`" == "xunknown" ]; then
127
	rinlining="UNKNOWN";
128
    else
129
	rinlining="INVALID/TIMEOUT"
130
    fi  
131
    if [ $verbose -gt 0 ]; then
132
	echo "lustrec inlined ($rlustrec2), gcc ($rgcc2), inlining valid ($rinlining), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report;
133
    else
134
	echo "lustrec inlined ($rlustrec2), gcc ($rgcc2), inlining valid ($rinlining), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report | grep "INVALID\|ERROR\|UNKNOWN"
135
    fi
136
    popd > /dev/null
137
done < $file_list
138

    
139
}
140

    
141
check_prop () {
142
    while IFS=, read -r file main opts
143
    do
144
	name=`basename "$file" .lus`
145
	dir=${SRC_PREFIX}/`dirname "$file"`
146
	pushd $dir > /dev/null
147
	
148
    # Checking horn backend
149
    if [ "$main" != "" ]; then
150
	$LUSTREC -horn -d $build -verbose 0 $opts -node $main "$name".lus;
151
    else
152
	$LUSTREC -horn -d $build -verbose 0 $opts "$name".lus
153
    fi
154
    # echo "z3 $build/$name".smt2 
155
    # TODO: This part of the script has to be optimized
156
    z3 -T:10 "$build/$name".smt2 | grep unsat > /dev/null
157
    if [ $? -ne 0 ]; then
158
        rhorn="INVALID";
159
    else
160
        rhorn="VALID"
161
    fi
162
    if [ $verbose -gt 0 ]; then
163
	echo "horn-pdr ($rhorn), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report;
164
    else
165
	echo "horn-pdr ($rhorn), $dir, ${name}.lus, node $main" | column -t -s',' | tee -a $report | grep "INVALID\|ERROR\|UNKNOWN"
166
    fi
167
    popd > /dev/null
168
done < $file_list
169
}
170

    
171
usage () {
172
echo "usage: $0 [-aciwh] file_list"
173
echo "-a: perform all steps"
174
echo "-c: basic compilation"
175
echo "-i: compile with inline mode"
176
echo "-w: compile with inline mode. Check the inlining with z3"
177
echo "-h: check files with the horn-pdf backend (requires z3)"
178
echo "-v <int>: verbose level"
179
}
180

    
181
verbose=0
182
nobehavior=1
183

    
184
while [ $# -gt 0 ] ; do
185
        case "$1" in
186
	        -v) shift ; verbose="$1"; shift ;;
187
	        -a) nobehavior=0; c=1 ; w=1; h=1; shift ;;
188
                -c) nobehavior=0; c=1 ; shift ;;
189
                -i) nobehavior=0; i=1 ; shift ;;
190
                -w) nobehavior=0; w=1 ; shift ;;
191
                -h) nobehavior=0; h=1 ; shift ;;
192
                --) shift ;;
193
                -*) echo "bad option '$1'" ; exit 1 ;;
194
                *) files=("${files[@]}" "$1") ; shift ;;
195
         esac
196
done
197

    
198
file_list=${files[0]}
199

    
200

    
201
if [ ${#files} -eq 0 ] ; then
202
    echo input list required
203
    usage
204
    exit 1
205
fi
206

    
207
[ ! -z "$c" ] && base_compile
208
[ ! -z "$i" ] && inline_compile
209
[ ! -z "$w" ] && inline_compile_with_check
210
[ ! -z "$h" ] && check_prop
211
[ "$nobehavior" -eq 1 ] && echo "Must provide an argument in [aciwh]" && usage
212

    
213

    
214
	# Removing Generated lusi file
215
	#grep generated ../${file}i > /dev/null
216
	#if [ $? -ne 1 ];then
217
	#  rm ../${file}i
218
	#fi
219