9 OPER_SCR=`readlink -f $CWD/../../operation.sh`
10 RESULT_LOG=$CWD/result.log
11 RECV_LOG=`readlink -f $CWD/../../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"
38 # $1: hex formatted file to send to the server
39 operation_sendhex2e () {
41 $OPER_SCR "sendhex2e|$1"
45 # $2: timeout (request expiration) in seconds
46 # Result: cats the message when completed
51 [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)"
55 # Monitor for incoming message:
56 tail -n0 -F --pid=$timerPid $1 | while read line
58 if echo $line | grep "^</message>" >/dev/null; then
59 echo "Message received"
66 if [ ! -f .msg_received ]; then
67 echo "Timeout expired"
75 # $1: pattern; $2: file
77 echo "Matching pattern '$1' in file '$2' ..."
78 cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null
80 [ $res -ne 0 ] && { echo " Cannot found pattern !!" ; test_failed ; }
83 # $1: pattern file; $2: file
84 check_pattern_file () {
85 echo "Matching file '$1' in file '$2' ..."
86 grep -f $1 $2 >/dev/null
87 [ $? -ne 0 ] && { echo " Cannot found pattern file !!" ; test_failed ; }
92 echo "$TC Ok" | tee -a $RESULT_LOG
96 echo "$TC Failed" | tee -a $RESULT_LOG
101 local tc_dn=`dirname $TC`
104 echo "***** Executing '$TC' ..."
106 grep -v ^# $TC > $tmpdir/tc
110 oper=$(echo $line | awk '{ print $1 }')
111 param1="$(echo $line | cut -d' ' -f2-)"
115 operation_sendxml2e $tc_dn/$param1 &
119 operation_sendhex2e $tc_dn/$param1 &
123 wait4message $RECV_LOG 5
127 check_pattern "$param1" $RECV_LOG
131 check_pattern_file "$param1" $RECV_LOG
135 [ $TEST_FAILED -eq 1 ] && return 1
149 trap sigint_handler SIGINT
151 # Working directory is script dirname:
156 echo "------------------"
157 echo "Test cases manager"
158 echo "------------------"
159 # Mandatory parameter:
160 [ -z "$1" ] && _exit "Usage: $SCR_BN <test cases parent directory (or .tc file)>"
162 # Gather .tc files to be processed:
163 [ ! -f $1 ] && echo -e "\nGathering list of test cases from '`readlink -f $1`' ..."
165 find $1 -name *.tc | xargs readlink -f | tee -a $tmpdir/tc_list
169 echo "Start processing test cases:"
170 echo "----------------------------"
171 # Process test cases:
173 for TC in `cat $tmpdir/tc_list`