X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Fdeployments%2Fft-client%2Ftests%2Fexperiment2%2Fgo.sh;fp=example%2Fdiameter%2Flauncher%2Fdeployments%2Fft-client%2Ftests%2Fexperiment2%2Fgo.sh;h=0000000000000000000000000000000000000000;hb=4c3f0a4d7e4db76996404d80c6f939548fca656f;hp=44bd53f1e254dbeafb23d907096bd917c52e4e6f;hpb=c82a3818b279727e943a76343f3cf1a278ac9e19;p=anna.git diff --git a/example/diameter/launcher/deployments/ft-client/tests/experiment2/go.sh b/example/diameter/launcher/deployments/ft-client/tests/experiment2/go.sh deleted file mode 100755 index 44bd53f..0000000 --- a/example/diameter/launcher/deployments/ft-client/tests/experiment2/go.sh +++ /dev/null @@ -1,194 +0,0 @@ -#!/bin/bash - -############# -# VARIABLES # -############# -SCR_DIR=`dirname $0` -tmpdir=$(mktemp -d) -SCR_BN=`basename $0` -OPER_SCR=../../operation.sh -RESULT_LOG=result.log -RECV_LOG=../../launcher.log.recvfe - -############# -# FUNCTIONS # -############# - -sigint_handler () { - _exit "Script interrupted. Cleanup and exit ..." -} - -# $1: message; $2: optional rc (1 by default) -_exit () { - rc=1 - [ -n "$2" ] && rc=$2 - echo - echo -e $1 - echo - rm -rf $tmpdir - exit $rc -} - -# $1: hex formatted file to send to the server -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" - return $? -} - -# $1: file to monitor -# $2: timeout (request expiration) in seconds -# Result: cats the message when completed -wait4message () { - 0>$1 - rm -f .msg_received - - [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)" - sleep $2 & - local timerPid=$! - - # Monitor for incoming message: - tail -n0 -F --pid=$timerPid $1 | while read line - do - if echo $line | grep "^" >/dev/null; then - echo "Message received:" - echo - cat $1 - # stop the timer - kill -13 $timerPid - touch .msg_received - fi - done - - if [ ! -f .msg_received ]; then - echo "Timeout expired" - return 1 - fi - - return 0 -} - -# xml content is serialized (removing CR's) to ease the pattern matching: -# $1: pattern; $2: file -check_pattern () { - echo -n "Matching pattern '$1' in file '$2' ... " - cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null - [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; } - echo "OK" - return 0 -} - -# $1: pattern file; $2: file -check_pattern_file () { - echo -n "Matching whole file '$1' in file '$2' ... " - grep -f $1 $2 >/dev/null - [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; } - echo "OK" - return 0 -} - -# Tests result: -test_ok () { - echo "Verdict: $TC Ok" | tee -a $RESULT_LOG -} - -test_failed () { - echo "Verdict: $TC Failed" | tee -a $RESULT_LOG -} - -process_tc () { - local tc_dn=`dirname $TC` - - echo - echo "***** Executing '$TC' ..." - - grep -v ^# $TC > $tmpdir/tc - while read -r line - do - oper=$(echo $line | awk '{ print $1 }') - param1="$(echo $line | cut -d' ' -f2-)" - - case $oper in - SENDXML2E) - operation_sendxml2e $tc_dn/$param1 & - [ $? -ne 0 ] && return 1 - ;; - - SENDHEX2E) - operation_sendhex2e $tc_dn/$param1 & - [ $? -ne 0 ] && return 1 - ;; - - WAIT4MESSAGE) - wait4message $RECV_LOG 5 - [ $? -ne 0 ] && return 1 - ;; - - CHECKPATTERN) - check_pattern "$param1" $RECV_LOG - [ $? -ne 0 ] && return 1 - ;; - - CHECKPATTERNFILE) - check_pattern_file "$param1" $RECV_LOG - [ $? -ne 0 ] && return 1 - ;; - - esac - - done < $tmpdir/tc - - return 0 -} - - -############# -# EXECUTION # -############# - -# Trap sigint: -trap sigint_handler SIGINT - -# Working directory is script dirname: -cd $SCR_DIR - -# Intro: -echo -echo "------------------" -echo "Test cases manager" -echo "------------------" -# Mandatory parameter: -[ -z "$1" ] && _exit "Usage: $SCR_BN " -[ ! -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 -find $1 -name *.tc | xargs -L1 readlink -f | tee -a $tmpdir/tc_list -echo -echo - -echo "Start processing test cases:" -echo "----------------------------" -# Process test cases: -0> $RESULT_LOG -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 -