73 lines
1.5 KiB
Plaintext
73 lines
1.5 KiB
Plaintext
|
#!/bin/bash
|
||
|
#xcrypted
|
||
|
|
||
|
# Auteur: Pascal ANELLI
|
||
|
# Session 3
|
||
|
# 5 Fev 2020
|
||
|
|
||
|
source ${LIBSH}/libeval.sh
|
||
|
|
||
|
#-----------------------------------------
|
||
|
rep=~/Sequence4/A45
|
||
|
challenge=C45Q2
|
||
|
scriptname=sum.sh
|
||
|
exo=$rep/$scriptname
|
||
|
sample=/tmp/num.data
|
||
|
#---------------------------------
|
||
|
cat >|${sample} <<EOF
|
||
|
2.09
|
||
|
1.65
|
||
|
1.21
|
||
|
1.19
|
||
|
1.24
|
||
|
1.38
|
||
|
1.47
|
||
|
1.50
|
||
|
-1.65
|
||
|
1.77
|
||
|
EOF
|
||
|
|
||
|
|
||
|
# Debut
|
||
|
firstcheck
|
||
|
|
||
|
# 1 working
|
||
|
$exo $sample &>/dev/null
|
||
|
step $(vraifaux $?) "L'execution du script s'effectue sans erreur " true
|
||
|
|
||
|
|
||
|
# 2 display.
|
||
|
display=$($exo $sample 2>/dev/null)
|
||
|
[ -n "$display" ]
|
||
|
step $(vraifaux $?) "Un resultat s'affiche "
|
||
|
|
||
|
# 3 accuracy
|
||
|
$exo $sample 2>&1 | grep -q "11.85" &>/dev/null
|
||
|
step $(vraifaux $?) "Le calcul est correct "
|
||
|
|
||
|
# 4 display ERROR
|
||
|
$exo rien 2>&1 | grep -q -i ERROR &>/dev/null
|
||
|
step $(vraifaux $?) "Affichage d'un message avec ERROR sur stderr "
|
||
|
|
||
|
# 5 file is checked
|
||
|
$exo rien &>/dev/null
|
||
|
[ $? -eq 1 ]
|
||
|
step $(vraifaux $?) "Code retour=1 quand l'argument n'est pas un fichier"
|
||
|
|
||
|
# 6 compute with 2 files
|
||
|
$exo $sample $sample 2>&1 | grep -q "23.70" >/dev/null
|
||
|
step $(vraifaux $?) "Le script traite plusieurs fichiers en entrée "
|
||
|
|
||
|
# 7 stdin
|
||
|
cat $sample | $exo 2>&1 | grep -q "11.85" &>/dev/null
|
||
|
step $(vraifaux $?) "Le script reçoit une suite de données par l'entrée standard "
|
||
|
|
||
|
#--------------------------------
|
||
|
# Fin
|
||
|
status "${challenge}_$res"
|
||
|
exit 0
|
||
|
|
||
|
#---- evaluation code
|
||
|
#listcode = [ '000', 'a7b', 'f97', 'e51', 'aa4', '2dc', '794', 'ff4' ]
|
||
|
#-----
|