-
Notifications
You must be signed in to change notification settings - Fork 14
/
verifyAll.sh
executable file
·96 lines (81 loc) · 2.39 KB
/
verifyAll.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! /bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
error=0
processedfiles=0
myfiles=()
mystatus=()
# default dafny configuration for verification
#defaultverifconf="/dafnyVerify:1 /compile:0 /tracePOs /traceTimes /trace /noCheating:0 /proverWarnings:1 /vcsMaxKeepGoingSplits:10 /vcsCores:12 /vcsMaxCost:1000 /vcsKeepGoingTimeout:12 /restartProver /verifySeparately"
# defaultverifconf="/dafnyVerify:1 /compile:0 /tracePOs /traceTimes /trace /noCheating:1"
defaultverifconf="/dafnyVerify:1 /compile:0 /noCheating:1"
# help and usage
help()
{
# Display Help
echo "Usage: $0 dir, where dirname is the folder you want to check."
echo "All .dfy files in the folder dirname will be checked."
echo
}
# Check number of arguments
if [ "$#" -ne 1 ];
then
echo "Illegal number of parameters"
help
exit 1
fi
if [ ! -d "$1" ]
then
echo -e "${RED}Error: Directory $1 DOES NOT exists.${NC}"
exit 2
fi
# try to process files in the directory $1
for entry in "$1"/*.dfy
do
# check file exists (this can occur if directory does not have *.dfy files)
[ -f "$entry" ] || continue
processedfiles=$((processedfiles + 1))
# try to get the verification configuration in the file
verif=`cat $entry | grep "@dafny" | sed 's/\/\/[ \t]*@dafny[ \t]*//g' | sed 's/[ \t]*$//g'`
# echo "verif options [$verif]"
if [ -z "$verif" ]
then
config="$defaultverifconf"
else
config="$verif"
fi
echo -e "${BLUE}-------------------------------------------------------${NC}"
echo -e "${BLUE}Processing $entry with config $config${NC}"
myfiles+=($entry)
# Run dafny with a config
dafny $config $entry
# echo "$result"
if [ $? -eq 0 ]
then
echo -e "${GREEN}No errors in $entry${NC}"
mystatus+=(1)
else
echo -e "${RED}Some errors occured in $entry${NC}"
error=$((error + 1))
mystatus+=(0)
fi
done
echo -e "${BLUE}-------------------------------------------------------${NC}"
for i in ${!myfiles[@]}; do
if [ ${mystatus[$i]} -ne 1 ]
then
echo -e "${RED}[FAIL] ${myfiles[$i]} has some errors :-(${NC}"
else
echo -e "${GREEN}[OK] ${myfiles[$i]}${NC}"
fi
done
if [ $error -ne 0 ]
then
echo -e "Summary: ${RED}Some files [$error/$processedfiles] has(ve) errors :-("
exit 1
else
echo -e "Summary: ${GREEN}$processedfiles files processed - No errors occured! Great job.${NC}"
exit 0
fi