-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcham_bai.sh~
executable file
·53 lines (47 loc) · 949 Bytes
/
cham_bai.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
test_data=""
binary=""
if [ -d $1 ]
then
test_data=$1
else
echo "$1 directory doesn't exist. Please specify test data location? "
read test_data
fi
if [ -f $2 ]
then
binary=$2
else
echo "$2 file doesn't exist. Please specify binary file to test? "
read binary
fi
echo "######## Testing $binary ########"
flag=1
count=0
for i in $test_data/*.in
do
#cat $i;
answer=$(cat ${i%.*}.ans)
output=$(timeout 15 bash -c "cat $i | $binary")
trimmed=$(echo $output | awk '{print $(NF-1) " " $NF}' | sed 's/[^0-9 ]//g')
#trimmed=$(echo $output | awk '{print $NF}' | sed 's/[^0-9]//g')
if [ "$answer" = "$trimmed" ]
then
let "count=count+1"
else
<<<<<<< HEAD
cat $i
echo "answer = $answer BUT output = $output"
=======
#cat $i
echo $i;
echo "answer = $answer BUT output = $trimmed"
>>>>>>> 6593bb33ec69b08adcf09d972119e07ffbfbc32e
flag=0
fi
done
if [ $flag = 1 ]
then
echo "$binary TRUE"
else
echo "$binary got $count"
fi