From 89c8f9bb52bd0c11386ac114fdfd8723d9ca643e Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Mon, 16 Mar 2015 00:09:09 +0100 Subject: [PATCH] Completed test case automation (shell scripting resources). Pending new features in launcher to admit raw hex messages for sending and answer programming. --- .../resources/ft-client/tests/case_1.sh | 29 +++++++- .../resources/ft-client/tests/common.sh | 67 ++++++++++++++++++- 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/example/diameter/launcher/resources/ft-client/tests/case_1.sh b/example/diameter/launcher/resources/ft-client/tests/case_1.sh index 7eca089..b353c63 100755 --- a/example/diameter/launcher/resources/ft-client/tests/case_1.sh +++ b/example/diameter/launcher/resources/ft-client/tests/case_1.sh @@ -1,9 +1,15 @@ #!/bin/bash +# In this test we will send a incorrect message (AAR) to the server peer: +# Warning | source/diameter/codec/Message.cpp (387) | Internal Avp decoding error (avp code = 443): Avp format error, the avp length is incorrect (must be multiple of 4 on grouped type) +# +# The server shall answer with the FailedAVP and we will check this to validate the test. + ############# # VARIABLES # ############# - +# Paths from the point of view of ADL executable: +REQ1_HEX=./hex_examples/aar-bad.hex ############# # FUNCTIONS # @@ -20,5 +26,22 @@ cd `dirname $0` # Source utils: source common.sh -# xxxx -echo "testing ..." +# Clean traffic traces: +rm ../launcher.log* + +# Send incorrect AAR: +send_hex $REQ1_HEX & + +# Monitor activity: +monitor_4_message ../launcher.log.recvfe 10 + +# Check if message was received: +[ $? -ne 0 ] && test_failed "Missing answer from the server" + +# Check launcher.log.recvfe: +check_pattern "" ../launcher.log.recvfe +check_pattern "( *)/dev/null + res=${PIPESTATUS[2]} + [ $? -ne 0 ] && _exit "Test failed: miss pattern !!" +} + +test_ok () { + echo + echo $1 + echo "Test OK !" + echo + exit 0 +} + +test_failed () { + echo + echo $1 + echo "Test FAILED !" + echo + exit 1 +} + + +# $1: traffic log to monitor +# $2: timeout (request expiration) in seconds +# Result: cats the message when completed +monitor_4_message () { + 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" + # stop the timer + kill -13 $timerPid + touch .msg_received + fi + done + + if [ ! -f .msg_received ]; then + echo "Timeout expired" + return 1 + fi + + return 0 +} + ############# # EXECUTION # ############# # Trap sigint signal: trap sigint_handler SIGINT + -- 2.20.1