-
Notifications
You must be signed in to change notification settings - Fork 4
/
tests_all.sh
90 lines (87 loc) · 1.49 KB
/
tests_all.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
#!/bin/bash
log(){
str="$1"
echo -e "\033[32m$str \033[0m "
}
clean() {
if ls $1 > /dev/null 2>&1; then
rm -rf $1
fi
}
failed(){
str="$1"
echo -e "\033[31m$str \033[0m"
ps aux|grep tests_asmer.sh|awk '{print $2}' |xargs kill -9
exit 1
}
check(){
if [ "$?" != 0 ]; then
# actual=`./a.out`
# if [ "$?" != 0 ]; then
failed "exec failed"
# fi
# rm ./a.out
fi
}
assert(){
expected="$1"
input="$2"
log "[compile] tu -s $input"
clean "*.s"
clean "*.o"
tu -s $input
check
log "[asmer] tu -c ."
tu -c .
echo "start linking..."
echo "tu -o . -o /usr/local/lib/colib"
tu -o . -o /usr/local/lib/colib
chmod 777 a.out
check
echo "exec a.out..."
./a.out
check
rm ./a.out
clean "*.s"
clean "*.o"
echo "exec done..."
return
# failed "[compile] $input failed"
}
read_dir(){
dir="$1"
cd $dir
for file in `ls *.tu`
do
echo $file
if [ -d $file ] ; then
read_dir $file
else
"clean *.s"
"clean *.o"
assert "OK" $file
log "[compile] $file passed!\n"
fi
done
cd ..
}
install_env(){
cd tests
if [ "$?" != 0 ]; then
failed "make failed"
fi
}
install_env
if [ "$1" != "" ]; then
read_dir $1
exit 0
fi
for dir in `ls`
do
if [ -d $dir ] ; then
read_dir $dir
clean "$dir/*.o"
clean "$dir/*.s"
fi
done
log "all passing...."