5 ################################################################################
6 # Global variables & utility functions
8 SCRIPT_DIR
="$(cd "$
(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
11 # Currently the script only works if it is run in this directory.
12 # TODO Change this dirty workaround.
15 # Suffix that is appened on the Why3 excecutable name
27 Usage: $(basename "$0") [OPTIONS...] <files>"
29 Run the check-ce tests on the given <files>.
30 <files> must be given without the '.mlw' suffix.
31 If <files> is empty, use all files from directory 'check-ce'.
35 Prints this help text.
38 Update the oracles during the run of tests suite.
44 The suffix <s> is appended on the Why3 executable name, e.g. '.opt'.
49 ################################################################################
52 while test $# != 0; do
71 echo "unknown option: $1"
82 if test "$petiot" = 1; then
89 # If files is empty, use all files from directory 'check-ce'.
90 if test "$files" = "" ; then
91 files
="$SCRIPT_DIR/check-ce/*.mlw"
95 readonly removeoutfile
100 # Path to the why3 binary
101 WHY3_BIN
="$SCRIPT_DIR"/..
/bin
/why3
"$SUFFIX"
102 whydata
=$
("$WHY3_BIN" --print-datadir)
103 whylib
=$
("$WHY3_BIN" --print-libdir)
110 if command -v pygmentize
&> /dev
/null
; then
117 remove_solver_details
() {
118 sed -e "s|$whydata|WHY3DATA|g" -e "s|$whylib|WHY3LIB|g" \
119 |
sed 's/ ([0-9.]\+\.[0-9]\+s, / (/' \
120 # | sed 's/ ([0-9.]\+\.[0-9]\+s, [0-9]\+ steps)\.$/\./' \
121 # | sed 's/Prover result is: \(Timeout\.\|Unknown (\(unknown\|incomplete\|unknown + \(incomplete\|interrupted\)\))\.\|Out of memory.\|Step limit exceeded\.\|Step limit exceeded ([^)]*)\.\)$/Prover result is: Unknown or time\/memory\/step limit./'
126 elapsed
=$
(date +%s
%N
)
132 d
=$
(expr $t - $elapsed)
136 lmn
=$
(expr $l - 9 || true
)
137 if [ "$lmn" = "0" ] ; then
141 # printf "lmn=${lmn}\n"
142 s
=$
(expr substr
"${d}" 1 ${lmn} || true
)
144 c
=$
(expr substr
"${d}" ${lmn} 2 || true
)
147 # printf "${elapsed}\n"
156 # $4 = true for WP, false for SP
163 f
="${file_path}_$1_WP"
164 oracle_file
="$2/oracles/$3_$1_WP.oracle"
165 printf "${file_path},WP,$1... "
167 f
="${file_path}_$1_SP"
168 oracle_file
="$2/oracles/$3_$1_SP.oracle"
170 printf "${file_path},SP,$1... "
174 if [ "$3" = "strings" ] && [[ $1 == CVC
* ]] ; then
175 prover
="$1,strings+counterexamples"
177 prover
="$1,counterexamples"
179 # one may add reduction_cont_size,stack_trace, in
180 # the debug flags below to test cont_invariant in reduction engine
181 # (note that stack trace may be more detailed with bytecode)
183 cmd
="$WHY3_BIN prove -a split_vc -P $prover \
184 --stepslimit=$steps --timelimit=10 \
185 --rac-steplimit=$steps --rac-timelimit=10 \
186 --check-ce --rac-prover=$1 --ce-log-verbosity=5 \
187 --library=$2 ${file_path}.mlw \
188 --debug=check_ce:categorization${debug_vc_sp}"
190 if $debug; then echo $cmd ; fi
191 ($cmd || true
) 2>&1 \
192 | remove_solver_details \
195 str_out
=$
(cat "$f.out")
196 if [ -e "$oracle_file" ]; then
197 str_oracle
=$
(cat "$oracle_file")
201 if [ "$str_oracle" = "$str_out" ] ; then
202 echo "OK (in ${elapsed}s)"
204 if $updateoracle; then
205 echo "Updating oracle (in ${elapsed}s)"
206 cp "$f.out" "${oracle_file}"
209 echo "diff is the following:"
210 (diff -u "$oracle_file" "$f.out" \
211 ||
[ $?
-eq 1 ])|colorize
215 if $removeoutfile; then
223 for file in $files; do
224 filedir
="$(realpath --relative-to="$PWD" $(dirname $file))"
225 filebase
=`basename $file .mlw`
226 printf "# Running provers on $filedir/$filebase.mlw\n";
228 altergostepsrac
=$altergosteps
232 cvc4stepsrac
=$cvc4steps
234 cvc5stepsrac
=$cvc5steps
238 "640_no_loc_failure")
247 "array_records_poly")
251 "array_records_mono")
289 altergostepsrac
=$altergosteps
297 "test_result_ce_value2")
309 if [ "$skipae" = "yes" ] ; then
310 echo "Skipping unreproducible run of Alt-Ergo 2.5.4 on $filedir/$filebase.mlw";
312 run Alt-Ergo
,2.5.4 $filedir $filebase true
$altergosteps $altergostepsrac
313 run Alt-Ergo
,2.5.4 $filedir $filebase false
$altergosteps $altergostepsrac
315 if [ "$skipcvc4" = "yes" ] ; then
316 echo "Skipping unreproducible run of CVC4 1.8 on $filedir/$filebase.mlw";
318 run CVC4
,1.8 $filedir $filebase true
$cvc4steps $cvc4stepsrac
319 run CVC4
,1.8 $filedir $filebase false
$cvc4steps $cvc4stepsrac
321 run CVC5
,1.0.5 $filedir $filebase true
$cvc5steps $cvc5stepsrac
322 run CVC5
,1.0.5 $filedir $filebase false
$cvc5steps $cvc5stepsrac
323 run Z3
,4.8.10 $filedir $filebase true
$z3steps $z3stepsrac
324 run Z3
,4.8.10 $filedir $filebase false
$z3steps $z3stepsrac
328 if $updateoracle; then
329 updatearg
="--updateoracle"
334 # Check the reproduction of the experiments by Petiot (2018).
338 bench
/check-ce
/petiot2018
/experiments.sh \
339 --prover $1 --rac-prover $1 \
340 --ce-prover $1,counterexamples
--stepslimit $2 \
342 if [ $?
= 1 ]; then failed
="${failed}Petiot experiments with $1.\n"; fi
345 if test "$petiot" -gt 0; then
346 petiot Alt-Ergo
,2.5.4 10000
347 petiot Z3
,4.8.10 500000
348 petiot CVC4
,1.8 10000
349 petiot CVC5
,1.0.5 10000
354 runtime
=$
((end-start
))
355 if [ "$failed" = "" ]; then
356 echo "check-ce-bench: success (runtime = $runtime seconds)"
359 printf "\ncheck-ce-bench: failed for the following files (runtime = $runtime seconds)\n$failed\n"