代码拉取完成,页面将自动刷新
#!/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...."
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。