projects
/
anna.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug for more that one test case (-L1 to xargs)
[anna.git]
/
example
/
diameter
/
launcher
/
resources
/
ft-client
/
tests
/
experiment2
/
go.sh
diff --git
a/example/diameter/launcher/resources/ft-client/tests/experiment2/go.sh
b/example/diameter/launcher/resources/ft-client/tests/experiment2/go.sh
index
d9a939d
..
44bd53f
100755
(executable)
--- a/
example/diameter/launcher/resources/ft-client/tests/experiment2/go.sh
+++ b/
example/diameter/launcher/resources/ft-client/tests/experiment2/go.sh
@@
-3,12
+3,12
@@
#############
# VARIABLES #
#############
#############
# VARIABLES #
#############
-
CWD
=`dirname $0`
+
SCR_DIR
=`dirname $0`
tmpdir=$(mktemp -d)
SCR_BN=`basename $0`
tmpdir=$(mktemp -d)
SCR_BN=`basename $0`
-OPER_SCR=
`readlink -f $CWD/../../operation.sh`
-RESULT_LOG=
$CWD/
result.log
-RECV_LOG=
`readlink -f $CWD/../../launcher.log.recvfe`
+OPER_SCR=
../../operation.sh
+RESULT_LOG=result.log
+RECV_LOG=
../../launcher.log.recvfe
#############
# FUNCTIONS #
#############
# FUNCTIONS #
@@
-33,12
+33,14
@@
_exit () {
operation_sendxml2e () {
sleep 0.5
$OPER_SCR "sendxml2e|$1"
operation_sendxml2e () {
sleep 0.5
$OPER_SCR "sendxml2e|$1"
+ return $?
}
# $1: hex formatted file to send to the server
operation_sendhex2e () {
sleep 0.5
$OPER_SCR "sendhex2e|$1"
}
# $1: hex formatted file to send to the server
operation_sendhex2e () {
sleep 0.5
$OPER_SCR "sendhex2e|$1"
+ return $?
}
# $1: file to monitor
}
# $1: file to monitor
@@
-56,7
+58,9
@@
wait4message () {
tail -n0 -F --pid=$timerPid $1 | while read line
do
if echo $line | grep "^</message>" >/dev/null; then
tail -n0 -F --pid=$timerPid $1 | while read line
do
if echo $line | grep "^</message>" >/dev/null; then
- echo "Message received"
+ echo "Message received:"
+ echo
+ cat $1
# stop the timer
kill -13 $timerPid
touch .msg_received
# stop the timer
kill -13 $timerPid
touch .msg_received
@@
-71,30
+75,32
@@
wait4message () {
return 0
}
return 0
}
-
+# xml content is serialized (removing CR's) to ease the pattern matching:
# $1: pattern; $2: file
check_pattern () {
# $1: pattern; $2: file
check_pattern () {
- echo
"Matching pattern '$1' in file '$2' ...
"
+ echo
-n "Matching pattern '$1' in file '$2' ...
"
cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null
cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null
- res=${PIPESTATUS[2]}
- [ $res -ne 0 ] && { echo " Cannot found pattern !!" ; test_failed ; }
+ [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; }
+ echo "OK"
+ return 0
}
# $1: pattern file; $2: file
check_pattern_file () {
}
# $1: pattern file; $2: file
check_pattern_file () {
- echo
"Matching file '$1' in file '$2' ...
"
+ echo
-n "Matching whole file '$1' in file '$2' ...
"
grep -f $1 $2 >/dev/null
grep -f $1 $2 >/dev/null
- [ $? -ne 0 ] && { echo " Cannot found pattern file !!" ; test_failed ; }
+ [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; }
+ echo "OK"
+ return 0
}
# Tests result:
test_ok () {
}
# Tests result:
test_ok () {
- echo "$TC Ok" | tee -a $RESULT_LOG
+ echo "
Verdict:
$TC Ok" | tee -a $RESULT_LOG
}
test_failed () {
}
test_failed () {
- echo "$TC Failed" | tee -a $RESULT_LOG
- TEST_FAILED=1
+ echo "Verdict: $TC Failed" | tee -a $RESULT_LOG
}
process_tc () {
}
process_tc () {
@@
-104,7
+110,6
@@
process_tc () {
echo "***** Executing '$TC' ..."
grep -v ^# $TC > $tmpdir/tc
echo "***** Executing '$TC' ..."
grep -v ^# $TC > $tmpdir/tc
- TEST_FAILED=0
while read -r line
do
oper=$(echo $line | awk '{ print $1 }')
while read -r line
do
oper=$(echo $line | awk '{ print $1 }')
@@
-113,30
+118,33
@@
process_tc () {
case $oper in
SENDXML2E)
operation_sendxml2e $tc_dn/$param1 &
case $oper in
SENDXML2E)
operation_sendxml2e $tc_dn/$param1 &
+ [ $? -ne 0 ] && return 1
;;
SENDHEX2E)
operation_sendhex2e $tc_dn/$param1 &
;;
SENDHEX2E)
operation_sendhex2e $tc_dn/$param1 &
+ [ $? -ne 0 ] && return 1
;;
WAIT4MESSAGE)
wait4message $RECV_LOG 5
;;
WAIT4MESSAGE)
wait4message $RECV_LOG 5
+ [ $? -ne 0 ] && return 1
;;
CHECKPATTERN)
check_pattern "$param1" $RECV_LOG
;;
CHECKPATTERN)
check_pattern "$param1" $RECV_LOG
+ [ $? -ne 0 ] && return 1
;;
CHECKPATTERNFILE)
check_pattern_file "$param1" $RECV_LOG
;;
CHECKPATTERNFILE)
check_pattern_file "$param1" $RECV_LOG
+ [ $? -ne 0 ] && return 1
;;
esac
;;
esac
- [ $TEST_FAILED -eq 1 ] && return 1
done < $tmpdir/tc
done < $tmpdir/tc
- test_ok
return 0
}
return 0
}
@@
-149,7
+157,7
@@
process_tc () {
trap sigint_handler SIGINT
# Working directory is script dirname:
trap sigint_handler SIGINT
# Working directory is script dirname:
-cd $
CWD
+cd $
SCR_DIR
# Intro:
echo
# Intro:
echo
@@
-158,11
+166,12
@@
echo "Test cases manager"
echo "------------------"
# Mandatory parameter:
[ -z "$1" ] && _exit "Usage: $SCR_BN <test cases parent directory (or .tc file)>"
echo "------------------"
# Mandatory parameter:
[ -z "$1" ] && _exit "Usage: $SCR_BN <test cases parent directory (or .tc file)>"
+[ ! -f "$1" -a ! -d "$1" ] && _exit "Invalid file or directory '$1' !!"
# Gather .tc files to be processed:
[ ! -f $1 ] && echo -e "\nGathering list of test cases from '`readlink -f $1`' ..."
echo
# Gather .tc files to be processed:
[ ! -f $1 ] && echo -e "\nGathering list of test cases from '`readlink -f $1`' ..."
echo
-find $1 -name *.tc | xargs readlink -f | tee -a $tmpdir/tc_list
+find $1 -name *.tc | xargs
-L1
readlink -f | tee -a $tmpdir/tc_list
echo
echo
echo
echo
@@
-173,6
+182,12
@@
echo "----------------------------"
for TC in `cat $tmpdir/tc_list`
do
process_tc
for TC in `cat $tmpdir/tc_list`
do
process_tc
+ if [ $? -eq 0 ]; then
+ test_ok
+ else
+ test_failed
+ cat $RECV_LOG
+ fi
done
_exit "Done !" 0
done
_exit "Done !" 0