9 OPER_SCR=../operation.sh
11 realm=`cat ../services.xml | grep originRealm | awk -F'originRealm=' '{ print $2 }' | cut -d\" -f2`
12 RECV_LOG=../${realm}.launcher.log.recvfe
19 _exit "Script interrupted. Cleanup and exit ..."
22 # $1: message; $2: optional rc (1 by default)
33 # $1: hex formatted file to send to the server
34 operation_sendxml2e () {
36 $OPER_SCR "sendxml2e|$1"
40 # $1: hex formatted file to send to the server
41 operation_sendhex2e () {
43 $OPER_SCR "sendhex2e|$1"
48 # $2: timeout (request expiration) in seconds
49 # Result: cats the message when completed
54 [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)"
58 # Monitor for incoming message:
59 tail -n0 -F --pid=$timerPid $1 | while read line
61 if echo $line | grep "^</message>" >/dev/null; then
62 echo "Message received:"
71 if [ ! -f .msg_received ]; then
72 echo "Timeout expired"
79 # xml content is serialized (removing CR's) to ease the pattern matching:
80 # $1: pattern; $2: file
82 echo -n "Matching pattern '$1' in file '$2' ... "
83 cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null
84 [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; }
89 # $1: pattern file; $2: file
90 check_pattern_file () {
91 echo -n "Matching whole file '$1' in file '$2' ... "
92 grep -f $1 $2 >/dev/null
93 [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; }
100 echo "Verdict: $TC Ok" | tee -a $RESULT_LOG
104 echo "Verdict: $TC Failed" | tee -a $RESULT_LOG
108 local tc_dn=`dirname $TC`
111 echo "***** Executing '$TC' ..."
113 grep -v ^# $TC > $tmpdir/tc
116 oper=$(echo $line | awk '{ print $1 }')
117 param1="$(echo $line | cut -d' ' -f2-)"
121 operation_sendxml2e $tc_dn/$param1 &
122 [ $? -ne 0 ] && return 1
126 operation_sendhex2e $tc_dn/$param1 &
127 [ $? -ne 0 ] && return 1
131 wait4message $RECV_LOG 5
132 [ $? -ne 0 ] && return 1
136 check_pattern "$param1" $RECV_LOG
137 [ $? -ne 0 ] && return 1
141 check_pattern_file "$param1" $RECV_LOG
142 [ $? -ne 0 ] && return 1
158 trap sigint_handler SIGINT
160 # Working directory is script dirname:
165 echo "------------------"
166 echo "Test cases manager"
167 echo "------------------"
168 # Mandatory parameter:
169 [ -z "$1" ] && _exit "Usage: $SCR_BN <test cases parent directory (or .tc file)>"
170 [ ! -f "$1" -a ! -d "$1" ] && _exit "Invalid file or directory '$1' !!"
172 # Gather .tc files to be processed:
173 [ ! -f $1 ] && echo -e "\nGathering list of test cases from '`readlink -f $1`' ..."
175 find $1 -name *.tc | xargs -L1 readlink -f | tee -a $tmpdir/tc_list
179 echo "Start processing test cases:"
180 echo "----------------------------"
181 # Process test cases:
183 for TC in `cat $tmpdir/tc_list`
186 if [ $? -eq 0 ]; then
194 echo "=========================================="
195 echo " TEST SUMMARY "
196 echo "=========================================="