2010-06-21 12:11:06 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
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
|
|
|
|
|
2010-07-16 17:33:14 +02: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
|
|
|
|
|
|
|
|
java=0
|
|
|
|
c=0
|
|
|
|
|
|
|
|
score=0
|
|
|
|
max=0
|
|
|
|
verbose=0
|
|
|
|
|
|
|
|
for d in good bad; do
|
2010-07-02 16:03:04 +02:00
|
|
|
rm -f -r $d/*.obc $d/*_java $d/*_c $d/*.mci $d/*.mls $d/*.epci
|
2010-06-21 12:11:06 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
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
|
|
|
|
echo Compile -i $coption $1 $2 $args_comp
|
|
|
|
$compilo $coption -I good $1 $2 $args_comp
|
|
|
|
else
|
|
|
|
$compilo $coption -I good $args_comp $1 $2 >/dev/null 2>&1
|
|
|
|
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
|
|
|
|
2010-07-02 16:03:04 +02:00
|
|
|
echo "Test"
|
2010-06-21 12:11:06 +02:00
|
|
|
|
2010-07-02 16:03:04 +02:00
|
|
|
# les mauvais
|
|
|
|
echo -n "bad "
|
|
|
|
for f in bad/*.ept ; do
|
2010-06-21 12:11:06 +02:00
|
|
|
echo -n ".";
|
|
|
|
max=`expr $max + 1`;
|
|
|
|
if compile $f; 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
|
2010-06-21 12:11:06 +02:00
|
|
|
|
2010-07-02 16:03:04 +02:00
|
|
|
echo -n "bons"
|
|
|
|
for f in good/*.ept; do
|
2010-06-21 12:11:06 +02:00
|
|
|
echec=0
|
|
|
|
echo -n ".";
|
|
|
|
max=`expr $max + 1`;
|
|
|
|
base_f=`basename $f .ept`
|
|
|
|
if compile $f; then
|
|
|
|
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
|
2010-07-16 11:19:56 +02:00
|
|
|
pushd "${base_f}" > /dev/null
|
2010-06-21 12:11:06 +02:00
|
|
|
for java_file in *.java ; do
|
2010-07-02 16:03:04 +02:00
|
|
|
if $JAVAC -warn:-unused -sourcepath .:..:../t1 ${java_file} > /dev/null
|
|
|
|
then
|
2010-06-21 12:11:06 +02:00
|
|
|
echec=${echec}
|
|
|
|
else
|
|
|
|
echec=3
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
popd > /dev/null
|
|
|
|
fi
|
|
|
|
# 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 -c $cf >/dev/null 2>&1; then
|
|
|
|
echec=$echec
|
|
|
|
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
|
|
|
|
echec=$echec
|
|
|
|
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
|
|
|
|
echec=${echec}
|
|
|
|
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
|
|
|
|
|
|
|
|
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 )
|
|
|
|
echo "Compilation to Obc failed.";;
|
|
|
|
3 )
|
|
|
|
echo "Compilation to Java failed.";;
|
|
|
|
5 )
|
|
|
|
echo "Compilation to C failed.";;
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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_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
|
|
|
}
|
|
|
|
|
|
|
|
# -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
|
|
|
|
"-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;;
|
2010-07-02 16:03:04 +02:00
|
|
|
"-mls" )
|
2010-06-21 12:11:06 +02:00
|
|
|
activate_minils
|
|
|
|
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 "-java : test of code generation (java code)"
|
|
|
|
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
|