#!/bin/bash # # Cours "Sémantique et Application à la Vérification de programmes" # # Josslin Giet 2021 # Ecole normale supérieure, Paris, France / CNRS / INRIA # shopt -s lastpipe RED="\e[91m" GREEN="\e[92m" BOLD="\e[1m" RESET="\e[0m" BLUE="\e[94m" fill=" " # Default solver path. You can change it if you need analyzer_path=$1 analyzer=$analyzer_path/analyzer options=$analyzer_path/options.txt result_folder="results" index_html="${result_folder}/index.html" nb_test=0 timeout=0 failure=0 completness=0 soundness=0 # max time allowed max_time="5s" all_opts="$2" if [ "$all_opts" != "" ]; then echo "Launching code with extra options: '${all_opts}'" fi # Pattern for failure in log patt_assert="line [0-9]*: Assertion failure" # Pattern for expêctyed failure in file patt_ko="assert.*//@KO" create_file() { file=$1 filename=$(basename $file) file_html="${result_folder}/${filename}.html" if [[ ! -e "$file_html" ]] then cat "scripts/header.html" > $file_html sed -i "s@TITLE@${filename}@" $file_html echo "
" >> $file_html echo "" >> $file_html echo "" >> $file_html echo "Expected: ${expected}
" >> $file_html echo "Failures: ${failures}
" >> $file_html # echo -e "\nnb_expected: ${nb_expected}" # echo -e "expected:\n--\n${expected}\n--" # echo -e "nb_failures: ${nb_failures}" # echo -e "failures:\n--\n${failures}\n--" # Soundness part: for line number in expected, # we search for it in failures for nb in `seq 1 $nb_expected`; do cmd="echo \"${expected}\" | head -${nb} | tail -1" line_nb=$(eval "${cmd}") echo "${failures}" | grep -q "^${line_nb}$" found=$? if [[ $found -ne 0 ]] then line=$(get_nth_line $line_nb $file) col_sound="red" soundness=$((soundness+1)) sound_loc=$((sound_loc+1)) if [ "$need_new_line" = true ] then echo -e "\n${BOLD}${RED} SOUNDNESS ERRORS${RESET}" need_new_line=false else echo -e "${BOLD}${RED} SOUNDNESS ERRORS${RESET}" fi echo -e "${RED}missing fail assertions:${RESET}${line}" echo "${line_nb}${line}
" >> $file_html fi done # Completness part: for each line number in failures, # we search for it in expected for nb in `seq 1 $nb_failures`; do cmd="echo \"${failures}\" | head -${nb} | tail -1" line_nb=$(eval "${cmd}") echo "${expected}" | grep -q "^${line_nb}$" found=$? if [[ $found -ne 0 ]] then completness=$((completness+1)) compl_loc=$((compl_loc+1)) col_compl="blue" line=$(grep "${patt_assert}" $log | head -${nb} | tail -1) if [ "$need_new_line" = true ] then echo -e "\n${BOLD}${BLUE} COMPLETNESS ERROR${RESET}" need_new_line=false else echo -e "${BOLD}${BLUE} COMPLETNESS ERROR${RESET}" fi echo -e "${BLUE}unexpected fail assertions:${RESET} ${line}" echo "${line}
" >> $file_html fi done echo "" >> $file_html cat $log >> $file_html echo "" >> $file_html if [ "$need_new_line" = false ] then echo -e "" fi echo -n "" >> $index_html echo -n "${sound_loc}, " >> $index_html echo -n "${compl_loc}" >> $index_html echo "" >> $index_html } treat_examples() { folder="examples/${1}" bench_name=$2 options="$3 $all_opts" # analyzer CLI options expected_folder=$4 # subfolder containing expected result bench_regexp="${folder}/*.c" nb_file=$(find $folder -iname "*.c" | wc -l) nb_test=$(( nb_test + nb_file )) if [[ $nb_file -eq 0 ]] then echo "bench ${bench_name}: No files found (${bench_regexp})" return fi echo "
${filename}
" >> $file_html cat $log >> $file_html echo "" >> $file_html elif [[ $out -ne 0 ]] then failure=$((failure+1)) echo "FAIL" >> $index_html echo "FAIL" >> $file_html echo -e "\n ${BOLD}${RED}FAILED ($out) ${RESET}\n" echo "
" >> $file_html cat $log >> $file_html echo "" >> $file_html else treat_file $file $log $expected_folder fi echo "