9 OPER_SCR=../../operation.sh
11 RECV_LOG=../../launcher.log.recvfe
18 _exit "Script interrupted. Cleanup and exit ..."
21 # $1: message; $2: optional rc (1 by default)
32 # $1: hex formatted file to send to the server
33 operation_sendxml2e () {
35 $OPER_SCR "sendxml2e|$1"
39 # $1: hex formatted file to send to the server
40 operation_sendhex2e () {
42 $OPER_SCR "sendhex2e|$1"
47 # $2: timeout (request expiration) in seconds
48 # Result: cats the message when completed
53 [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)"
57 # Monitor for incoming message:
58 tail -n0 -F --pid=$timerPid $1 | while read line
60 if echo $line | grep "^</message>" >/dev/null; then
61 echo "Message received:"
70 if [ ! -f .msg_received ]; then
71 echo "Timeout expired"
78 # xml content is serialized (removing CR's) to ease the pattern matching:
79 # $1: pattern; $2: file
81 echo -n "Matching pattern '$1' in file '$2' ... "
82 cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null
83 [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; }
88 # $1: pattern file; $2: file
89 check_pattern_file () {
90 echo -n "Matching whole file '$1' in file '$2' ... "
91 grep -f $1 $2 >/dev/null
92 [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; }
99 echo "Verdict: $TC Ok" | tee -a $RESULT_LOG
103 echo "Verdict: $TC Failed" | tee -a $RESULT_LOG
107 local tc_dn=`dirname $TC`
110 echo "***** Executing '$TC' ..."
112 grep -v ^# $TC > $tmpdir/tc
115 oper=$(echo $line | awk '{ print $1 }')
116 param1="$(echo $line | cut -d' ' -f2-)"
120 operation_sendxml2e $tc_dn/$param1 &
121 [ $? -ne 0 ] && return 1
125 operation_sendhex2e $tc_dn/$param1 &
126 [ $? -ne 0 ] && return 1
130 wait4message $RECV_LOG 5
131 [ $? -ne 0 ] && return 1
135 check_pattern "$param1" $RECV_LOG
136 [ $? -ne 0 ] && return 1
140 check_pattern_file "$param1" $RECV_LOG
141 [ $? -ne 0 ] && return 1
157 trap sigint_handler SIGINT
159 # Working directory is script dirname:
164 echo "------------------"
165 echo "Test cases manager"
166 echo "------------------"
167 # Mandatory parameter:
168 [ -z "$1" ] && _exit "Usage: $SCR_BN <test cases parent directory (or .tc file)>"
169 [ ! -f "$1" -a ! -d "$1" ] && _exit "Invalid file or directory '$1' !!"
171 # Gather .tc files to be processed:
172 [ ! -f $1 ] && echo -e "\nGathering list of test cases from '`readlink -f $1`' ..."
174 find $1 -name *.tc | xargs -L1 readlink -f | tee -a $tmpdir/tc_list
178 echo "Start processing test cases:"
179 echo "----------------------------"
180 # Process test cases:
182 for TC in `cat $tmpdir/tc_list`
185 if [ $? -eq 0 ]; then