First commit
This commit is contained in:
commit
4de409b957
4 changed files with 78 additions and 0 deletions
1
messages
Submodule
1
messages
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit e1f41d37fa105ea24749cf44d731c958ecfc2073
|
5
q1.txt
Normal file
5
q1.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
:3
|
||||||
|
o o:4
|
||||||
|
O:0
|
||||||
|
n:1
|
||||||
|
oui:5
|
8
q2.txt
Normal file
8
q2.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fich1 rep1:0
|
||||||
|
fich1 rep1 12:0
|
||||||
|
fich1:3
|
||||||
|
bidon rep1:4
|
||||||
|
fich2 rep1:4
|
||||||
|
fich1 rep2:5
|
||||||
|
fich1 rep1 -99:6
|
||||||
|
fich2 rep1 -99:4
|
64
test_q1.sh
Executable file
64
test_q1.sh
Executable file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/bash
|
||||||
|
source ./messages/message.sh
|
||||||
|
COMMAND=""
|
||||||
|
TEST_FILE=""
|
||||||
|
PWD=$(pwd)
|
||||||
|
DIR=""
|
||||||
|
|
||||||
|
process_args () {
|
||||||
|
while :; do
|
||||||
|
case $1 in
|
||||||
|
-h|-\?|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
v|--version)
|
||||||
|
show_version
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-s|--script)
|
||||||
|
COMMAND=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-t|--test-file)
|
||||||
|
[[ ! -f ${PWD}/${2} ]] && error "Test file (${2}) not found"
|
||||||
|
TEST_FILE=${PWD}/${2}
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-d|--directory)
|
||||||
|
[[ ! -d $2 ]] && error "Directory ${2} not found"
|
||||||
|
DIR=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage (){
|
||||||
|
msg "\n**Script de test de code retour**\n"
|
||||||
|
msg "Ce script permet de comparer les codes retour attendu et ceux obtenus\n"
|
||||||
|
msg "Dans le cadre du Mooc bash de la licence ADSILLH\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo " Hououuuu ${PWD}"
|
||||||
|
process_args $@
|
||||||
|
msg "Test $COMMAND script with $TEST_FILE\n\n"
|
||||||
|
|
||||||
|
while IFS='' read -r i || [[ -n "$line" ]]; do
|
||||||
|
args=$(echo $i | cut -d: -f1)
|
||||||
|
e_code=$(echo $i | cut -d: -f2)
|
||||||
|
msg "\nExécution de la command ${COMMAND} avec les paramètres **${args}**\n"
|
||||||
|
ret=$(${DIR}${COMMAND} $args 2>&1)
|
||||||
|
if [[ $? == $e_code ]]
|
||||||
|
then
|
||||||
|
msg "green" "\tLe code de retour est celui attendu (${e_code})\n"
|
||||||
|
else
|
||||||
|
msg "yellow" "\tLe code de retour n'est pas correct script : ${#} attendu : ${e_code}\n"
|
||||||
|
fi
|
||||||
|
msg "blue" "\tRetour : ${ret}\n"
|
||||||
|
done < "$TEST_FILE"
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue