} else if (opType == "decode") {
// Get DataBlock from file with hex content:
if (!getDataBlockFromHexFile(param1, db_aux))
- throw anna::RuntimeException("Cannot interpret hexadecimal content from file provided", ANNA_FILE_LOCATION);
+ throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION);
// Decode
try { G_codecMsg.decode(db_aux); } catch (anna::RuntimeException &ex) { ex.trace(); }
else {
// Get DataBlock from file with hex content:
if (!getDataBlockFromHexFile(param1, db_aux))
- throw anna::RuntimeException("Cannot interpret hexadecimal content from file provided", ANNA_FILE_LOCATION);
+ throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION);
G_commMsgSent2e.setBody(db_aux);
}
throw anna::RuntimeException("Wrong body content format on HTTP Request for 'burst' operation (unexpected action parameter). See help", ANNA_FILE_LOCATION);
}
- } else if ((opType == "sendxml2c")||(opType == "sendhex2c")) {
+ } else if ((opType == "sendxml2c") || (opType == "sendhex2c")) {
anna::diameter::comm::LocalServer *localServer = getDiameterLocalServer();
if (!localServer) throw anna::RuntimeException("No local server configured to send the message", ANNA_FILE_LOCATION);
else {
// Get DataBlock from file with hex content:
if (!getDataBlockFromHexFile(param1, db_aux))
- throw anna::RuntimeException("Cannot interpret hexadecimal content from file provided", ANNA_FILE_LOCATION);
+ throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION);
G_commMsgSent2c.setBody(db_aux);
}
startDiameterServer(diameterServerSessions);
else
getDiameterLocalServer()->setMaxConnections(diameterServerSessions);
- } else if ((opType == "answerxml") || (opType == "answerxml2c")) {
+ } else if ((opType == "answerxml") || (opType == "answerxml2c") || (opType == "answerhex") || (opType == "answerhex2c")) {
anna::diameter::comm::LocalServer *localServer = getDiameterLocalServer();
if (!localServer)
response_content = "Programmed answers dumped on stdout\n";
return;
}
- } else if ((opType == "answerxml2e")) {
+ } else if ((opType == "answerxml2e") || (opType == "answerhex2e")) {
anna::diameter::comm::Entity *entity = getEntity();
if (!entity)
response_content += param1;
response_content += "' loaded.";
response_content += "\n";
- } else if ((opType == "answerxml") || (opType == "answerxml2c")) {
+ } else if ((opType == "answerxml") || (opType == "answerxml2c") || (opType == "answerhex") || (opType == "answerhex2c")) {
response_content += "Answer to client '";
response_content += param1;
response_content += "' programmed.";
response_content += "\n";
- } else if ((opType == "answerxml2e")) {
+ } else if ((opType == "answerxml2e") || (opType == "answerhex2e")) {
response_content += "Answer to entity '";
response_content += param1;
response_content += "' programmed.";
+++ /dev/null
-#!/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 #
-#############
-
-
-#############
-# EXECUTION #
-#############
-
-# Goto working directory
-cd `dirname $0`
-
-# Source utils:
-source common.sh
-
-# Clean traffic traces:
-rm -f ../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 "<avp name=\"Result-Code\" data=\"5004\" alias=\"DIAMETER_INVALID_AVP_VALUE\"/>" ../launcher.log.recvfe
-check_pattern "<avp name=\"Failed-AVP\">( *)<avp name=\"Subscription-Id\"" ../launcher.log.recvfe
-
-# Test OK
-test_ok "Received answer to bad-aar message indicating Failed-AVP as Subscription-Id"
-
+++ /dev/null
-#!/bin/bash
-
-#############
-# VARIABLES #
-#############
-tmpdir=$(mktemp -d)
-
-#############
-# FUNCTIONS #
-#############
-
-_exit () {
- echo
- echo $1
- echo
- rm -rf $tmpdir
- exit 1
-}
-
-sigint_handler() {
- _exit "Script interrupted. Cleanup & exit ..."
-}
-
-# $1: hex formatted file to send to the server
-send_xml () {
- ../operation.sh "sendxml|$1"
-}
-
-send_hex () {
- sleep 1
- ../operation.sh "sendhex|$1"
-}
-
-# $1: pattern; $2: file
-check_pattern () {
- echo "Matching pattern '$1' ..."
- cat $2 | tr '\n' ' ' | egrep "$1" >/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 "^</message>" >/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
-
--- /dev/null
+#!/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 #
+#############
+
+
+#############
+# EXECUTION #
+#############
+
+# Goto working directory
+cd `dirname $0`
+
+# Source utils:
+source common.sh
+
+# Clean traffic traces:
+rm -f ../../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 "<avp name=\"Result-Code\" data=\"5004\" alias=\"DIAMETER_INVALID_AVP_VALUE\"/>" ../../launcher.log.recvfe
+check_pattern "<avp name=\"Failed-AVP\">( *)<avp name=\"Subscription-Id\"" ../../launcher.log.recvfe
+
+# Test OK
+test_ok "Received answer to bad-aar message indicating Failed-AVP as Subscription-Id"
+
--- /dev/null
+#!/bin/bash
+
+#############
+# FUNCTIONS #
+#############
+
+_exit () {
+ echo
+ echo $1
+ echo
+ exit 1
+}
+
+sigint_handler() {
+ _exit "Script interrupted. Cleanup & exit ..."
+}
+
+# $1: hex formatted file to send to the server
+send_xml () {
+ ../../operation.sh "sendxml|$1"
+}
+
+send_hex () {
+ sleep 1
+ ../../operation.sh "sendhex|$1"
+}
+
+# $1: pattern; $2: file
+check_pattern () {
+ echo "Matching pattern '$1' ..."
+ cat $2 | tr '\n' ' ' | egrep "$1" >/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 "^</message>" >/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
+
--- /dev/null
+../../../../hex_examples/aar-bad.hex
\ No newline at end of file
--- /dev/null
+# Send malformed AAR to the server:
+SENDHEX2E aar-bad.hex
+
+# Wait for message:
+WAIT4MESSAGE
+
+# Check Failed-AVP & Subscription-Id within:
+CHECKPATTERN <avp name="Result-Code" data="5004" alias="DIAMETER_INVALID_AVP_VALUE"/>
+CHECKPATTERN <avp name="Failed-AVP">( *)<avp name="Subscription-Id"
--- /dev/null
+#!/bin/bash
+
+#############
+# VARIABLES #
+#############
+CWD=`dirname $0`
+tmpdir=$(mktemp -d)
+SCR_BN=`basename $0`
+OPER_SCR=`readlink -f $CWD/../../operation.sh`
+RESULT_LOG=$CWD/result.log
+RECV_LOG=`readlink -f $CWD/../../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"
+}
+
+# $1: hex formatted file to send to the server
+operation_sendhex2e () {
+ sleep 0.5
+ $OPER_SCR "sendhex2e|$1"
+}
+
+# $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 "^</message>" >/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
+}
+
+
+# $1: pattern; $2: file
+check_pattern () {
+ echo "Matching pattern '$1' in file '$2' ..."
+ cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null
+ res=${PIPESTATUS[2]}
+ [ $res -ne 0 ] && { echo " Cannot found pattern !!" ; test_failed ; }
+}
+
+# $1: pattern file; $2: file
+check_pattern_file () {
+ echo "Matching file '$1' in file '$2' ..."
+ grep -f $1 $2 >/dev/null
+ [ $? -ne 0 ] && { echo " Cannot found pattern file !!" ; test_failed ; }
+}
+
+# Tests result:
+test_ok () {
+ echo "$TC Ok" | tee -a $RESULT_LOG
+}
+
+test_failed () {
+ echo "$TC Failed" | tee -a $RESULT_LOG
+ TEST_FAILED=1
+}
+
+process_tc () {
+ local tc_dn=`dirname $TC`
+
+ echo
+ echo "***** Executing '$TC' ..."
+
+ grep -v ^# $TC > $tmpdir/tc
+ TEST_FAILED=0
+ 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 &
+ ;;
+
+ SENDHEX2E)
+ operation_sendhex2e $tc_dn/$param1 &
+ ;;
+
+ WAIT4MESSAGE)
+ wait4message $RECV_LOG 5
+ ;;
+
+ CHECKPATTERN)
+ check_pattern "$param1" $RECV_LOG
+ ;;
+
+ CHECKPATTERNFILE)
+ check_pattern_file "$param1" $RECV_LOG
+ ;;
+
+ esac
+ [ $TEST_FAILED -eq 1 ] && return 1
+
+ done < $tmpdir/tc
+
+ test_ok
+ return 0
+}
+
+
+#############
+# EXECUTION #
+#############
+
+# Trap sigint:
+trap sigint_handler SIGINT
+
+# Working directory is script dirname:
+cd $CWD
+
+# Intro:
+echo
+echo "------------------"
+echo "Test cases manager"
+echo "------------------"
+# Mandatory parameter:
+[ -z "$1" ] && _exit "Usage: $SCR_BN <test cases parent directory (or .tc file)>"
+
+# 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 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
+done
+
+_exit "Done !" 0
+