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
|
|
|
|
|
|
|
|
java=0
|
|
|
|
c=0
|
|
|
|
|
|
|
|
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
|
2010-09-13 01:16:37 +02:00
|
|
|
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
|
2011-02-07 14:24:17 +01:00
|
|
|
echo
|
2011-01-12 16:08:33 +01:00
|
|
|
echo "Tests goods"
|
2011-03-22 17:43:04 +01:00
|
|
|
for f in ../good/*.ept ../image_filters/*.ept; do
|
2010-06-21 12:11:06 +02:00
|
|
|
echec=0
|
2010-09-13 01:16:37 +02:00
|
|
|
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 ?
|
2011-01-24 16:07:26 +01:00
|
|
|
#if [[ ($echec == 0) && ($java == 1) ]]; then
|
|
|
|
# pushd "${base_f}_java" > /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
|
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 -c $cf >/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=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
|
|
|
|
|
|
|
|
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.";;
|
2010-07-02 16:03:04 +02:00
|
|
|
3 )
|
2010-12-15 23:22:34 +01:00
|
|
|
echo "Java compilation 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
|
|
|
|
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_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
|
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;;
|
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 : "
|
2011-02-07 14:24:17 +01:00
|
|
|
echo "-clean : clean build dir"
|
2010-06-21 12:11:06 +02:00
|
|
|
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
|