heptagon/test/check

342 lines
6.7 KiB
Text
Raw Normal View History

2010-06-21 12:11:06 +02:00
#!/bin/bash
2011-01-05 15:48:09 +01:00
checkdir=_check_builds
2010-07-02 16:03:04 +02:00
# TODO: rewrite in OCaml or something better than sh
2010-06-21 12:11:06 +02:00
shopt -s nullglob
# script de test
2011-01-05 15:48:09 +01:00
compilo=../../heptc
2010-06-21 12:11:06 +02:00
coption=
# compilateurs utilises pour les tests de gen. de code
CAMLC=ocamlc
JAVAC=javac
LUSTREC=lustre
2010-07-16 12:13:40 +02:00
CC="gcc -std=c99"
2010-06-21 12:11:06 +02:00
# par defaut : pas de test de generation de code
caml=0
2010-06-21 12:11:06 +02:00
java=0
lustre=0
2010-06-21 12:11:06 +02:00
c=0
minils=0
vhdl=0
2010-06-21 12:11:06 +02:00
score=0
max=0
verbose=0
2011-01-12 16:08:33 +01:00
clean=0
2010-06-21 12:11:06 +02:00
compile () {
2010-07-16 11:19:56 +02:00
args_comp=""
2010-07-02 16:03:04 +02:00
assert_node=$(eval grep CHECK $1 | awk '{ print $3 }')
if [ -n "$assert_node" ]; then
args_comp="-assert $assert_node"
fi
if [ $verbose != 0 ]; then
args_comp="$args_comp -v"
fi
if grep "node main()" $1 >/dev/null; then
args_comp="$args_comp -s main"
fi
if [ $verbose != 0 ]; then
2011-01-12 16:08:33 +01:00
logfile=`basename $1`.log
echo "Compile -i $coption $args_comp $1"
$compilo $coption -I good $args_comp $1 >$logfile 2>&1
2010-07-02 16:03:04 +02:00
else
2010-12-15 23:22:34 +01:00
if [ $2 == 1 ]; then
$compilo $coption -I good $args_comp $1 >/dev/null 2>&1
else
$compilo $coption -I good $args_comp $1 2>&1
fi
2010-07-02 16:03:04 +02:00
fi
failed=$?
return $failed
2010-06-21 12:11:06 +02:00
}
launch_check () {
2010-07-02 16:03:04 +02:00
score=0
max=0
2010-06-21 12:11:06 +02:00
2011-01-12 16:08:33 +01:00
if [ $clean = 1 ]; then
rm -r $checkdir
exit 0
fi
if [ ! -d $checkdir ]; then
mkdir $checkdir
fi
cd $checkdir
2010-06-21 12:11:06 +02:00
2010-07-02 16:03:04 +02:00
# les mauvais
2011-01-12 16:08:33 +01:00
echo "Tests bads"
2011-01-05 15:48:09 +01:00
for f in ../bad/*.ept ; do
if [ $verbose = 0 ]; then
echo -n "."
fi
2010-06-21 12:11:06 +02:00
max=`expr $max + 1`;
2010-12-15 23:22:34 +01:00
if compile $f 1; then
2010-07-02 16:03:04 +02:00
echo
echo "ERROR on "$f" (should fail to compile)";
2010-06-21 12:11:06 +02:00
else
2010-07-02 16:03:04 +02:00
score=`expr $score + 1`;
2010-06-21 12:11:06 +02:00
fi
2010-07-02 16:03:04 +02:00
done
echo
2011-01-12 16:08:33 +01:00
echo "Tests goods"
pushd good > /dev/null
for f in *.ept; do
2010-06-21 12:11:06 +02:00
echec=0
if [ $verbose = 0 ]; then
echo -n "."
fi
2010-06-21 12:11:06 +02:00
max=`expr $max + 1`;
base_f=`basename $f .ept`
2010-12-15 23:22:34 +01:00
if compile $f 0; then
2010-06-21 12:11:06 +02:00
echec=0
else
echec=1
fi
# Compil. minils ?
if [[ ($echec == 0) && ($minils == 1) ]]; then
2010-07-16 11:19:56 +02:00
if $MLC ${base_f}.mls > /dev/null 2>&1; then
2010-06-21 12:11:06 +02:00
echec=0
else
echec=2
fi
fi
# Compil. java ?
if [[ ($echec == 0) && ($java == 1) ]]; then
pushd "${base_f}" > /dev/null
for java_file in *.java ; do
if $JAVAC -warn:-unused -sourcepath .:..:../t1 ${java_file} > /dev/null
then
echec=0
else
echec=3
fi
done
popd > /dev/null
fi
# Compil. caml ?
if [[ ($echec == 0) && ($caml == 1) ]]; then
if $CAMLC -c ${base_f}.ml > /dev/null; then
echec=0
else
echec=4
fi
fi
2010-06-21 12:11:06 +02:00
# Compil. c ?
if [[ ($echec == 0) && ($c == 1) ]]; then
2010-07-16 11:19:56 +02:00
pushd ${base_f}_c >/dev/null
2010-07-02 16:03:04 +02:00
for cf in *.c; do
if $CC -I ../t1_c -c $cf >/dev/null 2>&1; then
echec=$echec
2010-07-02 16:03:04 +02:00
else
echec=5
fi
done
if [ $echec != 5 ]; then
if egrep "(node main\(\))|(CHECK)" ../${base_f}.ept >/dev/null 2>&1
then
if $CC *.o -o ${base_f} 2>&1; then
2010-12-15 23:22:34 +01:00
echec=0
2010-07-02 16:03:04 +02:00
else
echec=6
fi
if [ $echec != 6 ]; then
step_count=`grep CHECK ../$base_f.ept | awk '{ print $4 }'`
if [ -n "$step_count" ]; then
if ./${base_f} $step_count >/dev/null 2>&1; then
2010-12-15 23:22:34 +01:00
echec=0
2010-07-02 16:03:04 +02:00
else
echec=7
fi
fi
fi
fi
2010-06-21 12:11:06 +02:00
fi
2010-07-02 16:03:04 +02:00
popd >/dev/null
2010-06-21 12:11:06 +02:00
fi
# Compil. VHDL ?
if [[ ($echec == 0) && ($vhdl == 1) ]]; then
pushd ${base_f}_vhdl > /dev/null
for vhdl_file in *.vhd; do
if $VHDLC -a ${vhdl_file} && $VHDLC -e ${vhdl_file} > /dev/null 2>&1
then
echec=${echec}
else
echec=8
fi
done
fi
2010-06-21 12:11:06 +02:00
if [[ $echec == 0 ]]; then
2010-07-02 16:03:04 +02:00
score=`expr $score + 1`;
2010-06-21 12:11:06 +02:00
else
2010-07-02 16:03:04 +02:00
echo
echo "ERROR on \"$f\" (should compile)";
case $echec in
1 )
2010-12-15 23:22:34 +01:00
echo "Compilation failed.";;
2 )
echo "Compilation to Minils failed.";;
2010-07-02 16:03:04 +02:00
3 )
echo "Compilation to Java failed.";;
4 )
echo "Compilation to Caml failed.";;
2010-07-02 16:03:04 +02:00
5 )
2010-12-15 23:22:34 +01:00
echo "C compilation failed.";;
2010-07-02 16:03:04 +02:00
6 )
echo "Link failure.";;
7 )
echo "Run-time assertion failure.";;
esac
2010-06-21 12:11:06 +02:00
fi
2010-07-02 16:03:04 +02:00
done
popd > /dev/null
2010-07-02 16:03:04 +02:00
echo
2010-06-21 12:11:06 +02:00
2010-07-02 16:03:04 +02:00
percent=`expr 100 \* $score / $max`;
2010-06-21 12:11:06 +02:00
2010-07-02 16:03:04 +02:00
echo -n "Test: $score/$max : $percent%";
2010-06-21 12:11:06 +02:00
}
2011-01-12 16:08:33 +01:00
activate_clean () {
clean=1
}
2010-06-21 12:11:06 +02:00
activate_minils () {
2010-07-02 16:03:04 +02:00
minils=1
2010-06-21 12:11:06 +02:00
}
activate_java () {
2010-07-02 16:03:04 +02:00
java=1
coption="$coption -target java"
2010-06-21 12:11:06 +02:00
}
activate_caml () {
caml=1
coption="$coption -target caml"
}
activate_vhdl () {
vhdl=1
coption="$coption -target vhdl"
}
2010-06-21 12:11:06 +02:00
activate_c () {
2010-07-02 16:03:04 +02:00
c=1
coption="$coption -target c"
2010-06-21 12:11:06 +02:00
}
activate_all () {
2010-07-02 16:03:04 +02:00
activate_java
activate_c
2010-06-21 12:11:06 +02:00
}
activate_tomato () {
coption="$coption -tomato"
}
activate_cse () {
coption="$coption -cse"
}
activate_inter () {
coption="$coption -inter"
}
activate_boolean () {
coption="$coption -bool"
}
activate_deadcode () {
coption="$coption -deadcode"
}
2010-06-21 12:11:06 +02:00
# -1, -2, -3, -v1, -v2, -v3 kept for backward compatibility
# (to be suppressed)
while [ $# -gt 0 ]; do
2010-07-02 16:03:04 +02:00
case $1 in
2011-01-12 16:08:33 +01:00
"-clean" )
activate_clean
shift;;
2010-07-02 16:03:04 +02:00
"-v" )
2010-06-21 12:11:06 +02:00
verbose=1;
shift;;
2010-07-02 16:03:04 +02:00
"-all" )
2010-06-21 12:11:06 +02:00
activate_all
shift;;
2010-07-02 16:03:04 +02:00
"-java" )
2010-06-21 12:11:06 +02:00
activate_java
shift;;
2010-07-02 16:03:04 +02:00
"-c" )
2010-06-21 12:11:06 +02:00
activate_c
shift;;
"-caml" )
activate_caml
shift;;
"-vhdl" )
activate_vhdl
shift;;
2010-07-02 16:03:04 +02:00
"-mls" )
2010-06-21 12:11:06 +02:00
activate_minils
shift;;
"-tomato" )
activate_tomato
shift;;
"-cse" )
activate_cse
shift;;
"-inter" )
activate_inter
shift;;
"-bool" )
activate_boolean
shift;;
"-deadcode" )
activate_deadcode
shift;;
2010-07-02 16:03:04 +02:00
"-h" )
2010-06-21 12:11:06 +02:00
echo "usage : $0 <options> <compilo>"
echo "options : "
echo "-clean : clean build dir"
2010-06-21 12:11:06 +02:00
echo "-java : test of code generation (java code)"
echo "-caml : test of code generation (caml code)"
echo "-lustre : test of code generation (lustre code)"
echo "-vhdl : test of code generation (vhdl)"
echo "-bool : test of boolean translation"
echo "-deadcode : test of deadcode removal"
echo "-inter : test of intermediate equations removal"
echo "-tomato : test of automata minimization"
echo "-cse : test of common sub-expression elimination"
2010-06-21 12:11:06 +02:00
echo "-c : test of code generation (c code)"
echo "-all : test all"
echo "-v : verbose"
exit 0;;
2010-07-02 16:03:04 +02:00
* )
2010-06-21 12:11:06 +02:00
compilo=$1
shift
coption="$coption $*"
break
2010-07-02 16:03:04 +02:00
esac
2010-06-21 12:11:06 +02:00
done
launch_check
echo