tests: use common function to check for file existence

This addresses issue with "docker cp" in some systems.
This commit is contained in:
Nikos Mavrogiannopoulos
2015-05-20 15:51:25 +02:00
parent 76f2c91e6b
commit f4e9b2e698
6 changed files with 79 additions and 114 deletions

View File

@@ -38,6 +38,56 @@ if test -z $FEDORA && test -z $DEBIAN;then
exit 77
fi
check_for_file() {
FILENAME=$1
rm -f out$TMP
$DOCKER exec -i -t $IMAGE_NAME ls $FILENAME >out$TMP
grep "$FILENAME" out$TMP|grep -v "cannot access"
if test $? != 0;then
echo "could not find $FILENAME"
return 1
else
rm -f out$TMP
return 0
fi
}
retrieve_user_info() {
USERNAME=$1
MATCH=$2
counter=0
ret=1
while [ $counter -lt 4 ]
do
$DOCKER exec -i -t $IMAGE_NAME occtl show user $USERNAME >out$TMP 2>&1
if test -z "$MATCH";then
grep "Username" out$TMP
else
grep "$MATCH" out$TMP
fi
ret=$?
if test $ret == 0;then
break
fi
counter=`expr $counter + 1`
sleep 2
done
if test $ret != 0;then
kill $PID
cat out$TMP
echo "could not find user information"
stop
else
rm -f out$TMP
fi
}
retrieve_route_info() {
retrieve_user_info $1 $2
}
stop() {
$DOCKER stop $IMAGE_NAME
$DOCKER rm $IMAGE_NAME