68 lines
1.8 KiB
Plaintext
68 lines
1.8 KiB
Plaintext
|
#!/bin/bash
|
|||
|
#xcrypted
|
|||
|
# Auteur: Pascal Anelli
|
|||
|
# adaptation session 2 : Denis Payet
|
|||
|
# Régis : modification du nom toto qui est bien trop commun
|
|||
|
|
|||
|
source ${LIBSH}/libeval.sh
|
|||
|
|
|||
|
#-----------------------------------------
|
|||
|
rep=/home/alice/Sequence4/A44
|
|||
|
challenge=C44Q1
|
|||
|
scriptname=size.sh
|
|||
|
sample=/tmp/fichier1.txt
|
|||
|
base=300
|
|||
|
res=0
|
|||
|
#---------------------------------
|
|||
|
# Debut
|
|||
|
firstcheck
|
|||
|
|
|||
|
# THE good value
|
|||
|
printf "%d aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" {1..340} >| $sample
|
|||
|
#[ -f $sample ] || { echo "Erreur: recuperer votre travail et redemarrer la weblinux ; exit 1; }
|
|||
|
sizes=$(ls -l $sample | tr -s ' ' | cut -d' ' -f5)
|
|||
|
|
|||
|
# 1 working
|
|||
|
$rep/$scriptname $sample &>/dev/null
|
|||
|
step $(vrzifaux $?) "Le script fonctionne correctement"
|
|||
|
|
|||
|
|
|||
|
# 2 display
|
|||
|
number=$($rep/$scriptname $sample 2>/dev/null)
|
|||
|
[ -n "$number" ]
|
|||
|
step $(vrzifaux $?) "Le resultat est affiché"
|
|||
|
|
|||
|
# 3 is integer
|
|||
|
isinteger "$number"
|
|||
|
step $(vrzifaux $?) " "Le resultat est un entier"
|
|||
|
|
|||
|
# 4 accuracy
|
|||
|
typeset -i size=${number%.*}
|
|||
|
[ "$size" -eq "$sizes" ]
|
|||
|
step $(vrzifaux $?) "Le calcul est correct"
|
|||
|
|
|||
|
# 5 argument missing
|
|||
|
$rep/$scriptname &>/dev/null
|
|||
|
[ $? -eq 1 ]
|
|||
|
step $(vrzifaux $?) "Un code erreur est retourné en cas d'absence de l'argument"
|
|||
|
|
|||
|
# 6 arguments missing: error message
|
|||
|
$rep/$scriptname 2>&1 | grep -q "Usage" &>/dev/null
|
|||
|
step $(vrzifaux $?) "Affichage de l'usage en cas d'absence de l'argument"
|
|||
|
|
|||
|
# 7 wrong argument
|
|||
|
$rep/$scriptname totoXw78K &>/dev/null
|
|||
|
[ $? -eq 1 ]
|
|||
|
step $(vrzifaux $?) "Un code erreur est retourné en cas de mauvais argument"
|
|||
|
|
|||
|
# 8
|
|||
|
$rep/$scriptname totoXw78K 2>&1 | grep -q "Erreur"
|
|||
|
step $(vrzifaux $?) "Affichage d'un message d'erreur en cas de mauvais argument"
|
|||
|
|
|||
|
#--------------------------------
|
|||
|
# Fin
|
|||
|
status "${challenge}_$res"
|
|||
|
exit 0
|
|||
|
|
|||
|
# listcode = [ '000', '738', '4c8', '988', '629', '10b', 'f6d', '25e', '9aa' ]
|