-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.sh
129 lines (126 loc) · 3.32 KB
/
tester.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
make;
mkdir outputs
while getopts "fdar" opt;
do
case $opt in
r)
read -e -p "Directory to evaluate (Default /resources/bin/): " dir
dir=${dir:-resources/bin}
declare -a arr=("")
for i in "$dir"/*;
do
arr+=($i)
done
len=$((${#arr[@]} - 1))
for i in {1..1000};
do
f1=${arr[$(jot -r 1 0 len)]}
f2=${arr[$(jot -r 1 0 len)]}
f3=${arr[$(jot -r 1 0 len)]}
f4=${arr[$(jot -r 1 0 len)]}
if [[ ( -z $f1 && -z $f2 && -z $f3 && -z $f4 ) ]]
then
continue
fi
printf "\033[32mEvaluating %s %s %s %s\033[0m\n" $f1 $f2 $f3 $f4;
./prueba $f1 $f2 $f3 $f4 -i > outputs/our.txt;
./corewar $f1 $f2 $f3 $f4 -v 4 > outputs/real.txt;
diff outputs/our.txt outputs/real.txt > outputs/diff.txt;
if [ -s outputs/diff.txt ]
then
printf "\033[31mDiferences of:\n%s %s %s %s\nStored in outputs/diff.txt\033[0m\n" $f1 $f2 $f3 $f4;
exit 2
else
printf "\033[32mOK\033[0m\n"
fi
done
;;
f)
read -e -p "Enter files: " dir
printf "\033[1;32mEvaluating %s\033[0m\n" "$dir";
./prueba $dir -i > outputs/our.txt;
# ex=$?; if [[ $ex != 0 ]]; then exit $ex; fi
./corewar $dir -v 4 > outputs/real.txt;
# ex=$?; if [[ $ex != 0 ]]; then exit $ex; fi
diff outputs/our.txt outputs/real.txt > outputs/diff.txt;
if [ -s outputs/diff.txt ]
then
printf "\033[31mDiferences of:\n%s\nStored in outputs/diff.txt\033[0m\n" "$dir";
else
printf "\033[32mOK\033[0m\n"
fi
;;
a)
read -e -p "Directory to evaluate (Default /resources/sources/): " dir
dir=${dir:-resources/sources}
for f1 in $dir/*;
do
printf "\033[32mEvaluating %s\033[0m\n" $f1;
printf "Our says:"
./srcs_asm/asm $f1
printf "\n"
our=$(echo $f1 | sed 's/\(.*\.\)s/\1cor/g')
cat $our > outputs/our.cor
rm -f $our
printf "Real says:"
./srcs_asm/vm_champs/asm $f1
printf "\n"
real=$(echo $f1 | sed 's/\(.*\.\)s/\1cor/g')
cat $real > outputs/real.cor
rm -f $real
diff outputs/our.cor outputs/real.cor > outputs/diff.txt;
if [ -s outputs/diff.txt ]
then
printf "\033[31mDiferences of:\n%s %s %s %s\nStored in outputs/diff.txt\033[0m\n" $(basename $f1);
exit 2
else
printf "\033[32mOK\033[0m\n"
fi
done
;;
d)
read -e -p "Directory to evaluate (Default /resources/bin/): " dir
dir=${dir:-resources/bin}
declare -a arr=("")
for i in "$dir"/*;
do
arr+=($i)
done
for f1 in "${arr[@]}";
do
for f2 in "${arr[@]}";
do
for f3 in "${arr[@]}";
do
for f4 in "${arr[@]}";
do
if [[ ( -z $f1 && -z $f2 && -z $f3 && -z $f4 ) ]]
then
continue
fi
printf "\033[32mEvaluating %s %s %s %s\033[0m\n" $f1 $f2 $f3 $f4;
./prueba $f1 $f2 $f3 $f4 -i > outputs/our.txt;
./corewar $f1 $f2 $f3 $f4 -v 4 > outputs/real.txt;
diff outputs/our.txt outputs/real.txt > outputs/diff.txt;
if [ -s outputs/diff.txt ]
then
printf "\033[31mDiferences of:\n%s %s %s %s\nStored in outputs/diff.txt\033[0m\n" $f1 $f2 $f3 $f4;
exit 2
else
printf "\033[32mOK\033[0m\n"
fi
done
done
done
done
;;
\?)
echo "\033[31mInvalid option: -$OPTARG\033[0m" >&2
exit 1
;;
:)
echo "\033[31mOption: -$OPTARG requires argument\033[0m" >&2
exit 1
;;
esac
done