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'.
48 Prints the why3 command used
52 ################################################################################
55 while test $# != 0; do
78 echo "unknown option: $1"
89 if test "$petiot" = 1; then
96 # If files is empty, use all files from directory 'check-ce'.
97 if test "$files" = "" ; then
98 files
="$SCRIPT_DIR/check-ce/*.mlw"
102 readonly removeoutfile
103 readonly updateoracle
107 # Path to the why3 binary
108 WHY3_BIN
="$SCRIPT_DIR"/..
/bin
/why3
"$SUFFIX"
109 whydata
=$
("$WHY3_BIN" --print-datadir)
110 whylib
=$
("$WHY3_BIN" --print-libdir)
117 if command -v pygmentize
&> /dev
/null
; then
124 remove_solver_details
() {
125 sed -e "s|$whydata|WHY3DATA|g" -e "s|$whylib|WHY3LIB|g" \
126 |
sed 's/ ([0-9.]\+\.[0-9]\+s, / (/' \
127 # | sed 's/ ([0-9.]\+\.[0-9]\+s, [0-9]\+ steps)\.$/\./' \
128 # | 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./'
133 elapsed
=$
(date +%s
%N
)
139 d
=$
(expr $t - $elapsed)
143 lmn
=$
(expr $l - 9 || true
)
144 if [ "$lmn" = "0" ] ; then
148 # printf "lmn=${lmn}\n"
149 s
=$
(expr substr
"${d}" 1 ${lmn} || true
)
151 c
=$
(expr substr
"${d}" ${lmn} 2 || true
)
154 # printf "${elapsed}\n"
163 # $4 = true for WP, false for SP
170 f
="${file_path}_$1_WP"
171 oracle_file
="$2/oracles/$3_$1_WP.oracle"
172 printf "${file_path},WP,$1... "
174 f
="${file_path}_$1_SP"
175 oracle_file
="$2/oracles/$3_$1_SP.oracle"
177 printf "${file_path},SP,$1... "
181 if [ "$3" = "strings" ] && [[ $1 == CVC
* ]] ; then
182 prover
="$1,strings+counterexamples"
184 prover
="$1,counterexamples"
186 # one may add reduction_cont_size,stack_trace, in
187 # the debug flags below to test cont_invariant in reduction engine
188 # (note that stack trace may be more detailed with bytecode)
190 cmd
="$WHY3_BIN prove -a split_vc -P $prover \
191 --stepslimit=$steps --timelimit=5 \
192 --rac-steplimit=$racsteps --rac-timelimit=2 \
193 --check-ce --rac-prover=$1 --ce-log-verbosity=5 \
194 --library=$2 ${file_path}.mlw \
195 --debug=check_ce:categorization${debug_vc_sp}"
197 if $debug; then echo $cmd ; fi
198 ($cmd || true
) 2>&1 \
199 | remove_solver_details \
202 str_out
=$
(cat "$f.out")
203 if [ -e "$oracle_file" ]; then
204 str_oracle
=$
(cat "$oracle_file")
208 if [ "$str_oracle" = "$str_out" ] ; then
209 echo "OK (in ${elapsed}s)"
211 if $updateoracle; then
212 echo "Updating oracle (in ${elapsed}s)"
213 cp "$f.out" "${oracle_file}"
216 echo "diff is the following:"
217 (diff -u "$oracle_file" "$f.out" \
218 ||
[ $?
-eq 1 ])|colorize
222 if $removeoutfile; then
230 for file in $files; do
231 filedir
="$(realpath --relative-to="$PWD" $(dirname $file))"
232 filebase
=`basename $file .mlw`
233 printf "# Running provers on $filedir/$filebase.mlw\n";
235 altergostepsrac
=$altergosteps
239 cvc4stepsrac
=$cvc4steps
241 cvc5stepsrac
=$cvc5steps
245 "640_no_loc_failure")
265 "array_records_poly")
269 "array_records_mono")
292 altergostepsrac
=$altergosteps
320 altergostepsrac
=$altergosteps
322 cvc5stepsrac
=$cvc5steps
326 cvc5stepsrac
=$cvc5steps
332 "test_result_ce_value2")
345 if [ "$skipae" = "yes" ] ; then
346 echo "Skipping unreproducible run of Alt-Ergo 2.5.4 on $filedir/$filebase.mlw";
348 run Alt-Ergo
,2.5.4 $filedir $filebase true
$altergosteps $altergostepsrac
349 run Alt-Ergo
,2.5.4 $filedir $filebase false
$altergosteps $altergostepsrac
351 if [ "$skipcvc4" = "yes" ] ; then
352 echo "Skipping unreproducible run of CVC4 1.8 on $filedir/$filebase.mlw";
354 run CVC4
,1.8 $filedir $filebase true
$cvc4steps $cvc4stepsrac
355 run CVC4
,1.8 $filedir $filebase false
$cvc4steps $cvc4stepsrac
357 run CVC5
,1.0.5 $filedir $filebase true
$cvc5steps $cvc5stepsrac
358 run CVC5
,1.0.5 $filedir $filebase false
$cvc5steps $cvc5stepsrac
359 run Z3
,4.8.10 $filedir $filebase true
$z3steps $z3stepsrac
360 run Z3
,4.8.10 $filedir $filebase false
$z3steps $z3stepsrac
364 if $updateoracle; then
365 updatearg
="--updateoracle"
370 # Check the reproduction of the experiments by Petiot (2018).
374 bench
/check-ce
/petiot2018
/experiments.sh \
375 --prover $1 --rac-prover $1 \
376 --ce-prover $1,counterexamples
--stepslimit $2 \
378 if [ $?
= 1 ]; then failed
="${failed}Petiot experiments with $1.\n"; fi
381 if test "$petiot" -gt 0; then
382 petiot Alt-Ergo
,2.5.4 10000
383 petiot Z3
,4.8.10 500000
384 petiot CVC4
,1.8 10000
385 petiot CVC5
,1.0.5 10000
390 runtime
=$
((end-start
))
391 if [ "$failed" = "" ]; then
392 echo "check-ce-bench: success (runtime = $runtime seconds)"
395 printf "\ncheck-ce-bench: failed for the following files (runtime = $runtime seconds)\n$failed\n"