e08120fdfe51f363bbc25f49ebf5a5dd19c6f7b1
[anna.git] / example / diameter / launcher / resources / scripts / tinyTestcase.sh
1 #!/bin/bash
2
3 #############
4 # VARIABLES #
5 #############
6 SCR_DIR=`readlink -f $0 | xargs dirname`
7
8 #############
9 # FUNCTIONS #
10 #############
11 _exit() {
12   echo
13   echo -e $1
14   echo
15   exit 1
16 }
17
18 usage() {
19   echo "Usage: $0 <source directory>"
20   echo
21   echo "       The source directory may contain .xml and .metadata files grouped by pairs and alphabetically classified:"
22   echo
23   echo "          11.hex.as.xml  15.hex.as.xml  19.hex.as.xml ..."
24   echo "          11.metadata    15.metadata    19.metadata   ..."
25   echo "          13.hex.as.xml  17.hex.as.xml  21.hex.as.xml ..."
26   echo "          13.metadata    17.metadata    21.metadata   ..."
27   echo
28   echo "       Normally the order comes from first dot-separated part, which is the decoded frame from pcap:"
29   echo
30   echo "          11.hex.as.xml: would be the ANNA-Diameter decoded message from hexadecimal sniffed one."
31   echo "          11.metadata:   would contain parsed metadata from tshark or another fulfilling this information:"
32   echo
33   echo "                           date=Sat Dec 19 11:50:55 CET 2015"
34   echo "                           timestamp=1450522255.205673000"
35   echo "                           src=gentraf"
36   echo "                           dst=testbed"
37   echo "                           code=257"
38   echo "                           isrequest=1"
39   echo "                           applicationid=0"
40   echo
41   echo "       Presented example has been achieved using the 'example/diameter/pcapDecoder/tsharkDecoder.sh' script"
42   echo "        and then decoding with 'example/diameter/batchConverter' tool with appropiate diameter dictionaries."
43   echo
44   echo "      This script will create a basic testcase based on frames timeline (11, 13, 15, etc.), from the desired"
45   echo "      end-point. For example, from the 'gentraf' point of view, outgoing requests will be translated as send"
46   echo "      operations with corresponding waits for answers and successful result code (2001). CER/A are detected"
47   echo "      creating a symbolic link to better reference them, and DPR/A are ignored."
48   echo
49   echo "      The resulting 'testcase.txt' will have all the operations needed to program the test case and will be"
50   echo "      written on same source directory referencing xml files as local-relative ones. Probably, 'change-dir'"
51   echo "      operation will be used before programming to ease the procedure without having to copy the stuff into"
52   echo "      installed ADML execution directory."
53   echo
54   echo "      Connection issues (CER/A), disconnect procedures (DPR/A), database populations and sanity checks are"
55   echo "      not responsability for this script. Such operations shall be externally performed to guarantee that"
56   echo "      programming this testcase is going to be valid in context of test execution."
57   _exit
58 }
59
60 #############
61 # EXECUTION #
62 #############
63 cd $SCR_DIR
64 source ../../configure.sh
65 echo
66 SOURCE_DIR=$1
67 [ -z "$SOURCE_DIR" ] && usage
68 SOURCE_DIR=`readlink -f $SOURCE_DIR`
69 [ ! -d "$SOURCE_DIR" ] && _exit "Can't found provided directory '$SOURCE_DIR'"
70
71 # UNDER CONSTRUCTION
72 # .........