Fix new variables
[anna.git] / example / diameter / launcher / resources / scripts / clone.sh
index 099aa7f..ad89977 100755 (executable)
@@ -12,9 +12,12 @@ MAX_NUMBER_GROUPS=400
 #############
 _exit (){
   echo
-  echo $1
+  echo -e $1
   echo
 
+  # Background jobs:
+  kill -9 $(jobs -p) >/dev/null 2>/dev/null
+
   # Cleanup:
   rm -rf $CLONE_WKDIR
 
@@ -33,16 +36,14 @@ usage() {
   echo "          ADML directory:         path to the ADML directory where 'operation.sh' script is used to load the test cases."
   echo "          testcase variable file: path to the testcase file with parseable variables, for example '<directory>/testcase.txt.msk'."
   echo "                                  xml files within this test case, must exist with aditional .msk extension in the same directory."
+  echo
   echo "                                  Currently, 9 variables are supported to be replaced:"
-  echo "                                    __TESTID__ : sequence number. For example if you provide 1 to 20 for this script, it will be 1 .. 20"
-  echo "                                    __SEQ8__   : 8-digit number corresponding to the sequence number (00000001 for 1, and so on)"
-  echo "                                    __MSISDN9__: 9-digit msisdn"
-  echo "                                    __IPV4HEX__: hexadecimal IPv4 address, for example: 00000001"
-  echo "                                    __IPV4__   : IPv4 address, for example: 0.0.0.1"
-  echo "                                    __SGX1_SUFFIX__: 1<8-digit sequence>"
-  echo "                                    __SRX1_SUFFIX__: \""
-  echo "                                    __SGX2_SUFFIX__: 2<8-digit sequence>"
-  echo "                                    __SRX2_SUFFIX__: \""
+  echo
+  echo "                                  * __TESTID__ : sequence number. For example if you provide 1 to 20 for this script, it will be 1 .. 20"
+  echo "                                  * __SEQ8__   : 8-digit number corresponding to the sequence number (00000001 for 1, and so on)"
+  echo "                                  * __IPV4HEX__: hexadecimal IPv4 address, for example: 00000001"
+  echo "                                  * __IPV4__   : IPv4 address, for example: 0.0.0.1"
+  echo
   echo "                                  Edit the variables section to add more special values if you need them."
   echo
   echo "          initial sequence:       initial sequence number to parse over variables."
@@ -91,28 +92,17 @@ clone() {
   ################################ EDIT THIS SECTION IF YOU NEED NEW SPECIAL VARIABLES ################################
   testid=$sequence
   seq8=$(printf "%08d" $testid)
-  msisdn9=6${seq8}
   ipv4hex=$seq8
   #ipv4=$(for i in $(echo $seq8 | sed 's/\(..\)/0x\1 /g'); do printf "%d." $i; done | sed 's/\.$/\n/')
   # Numbers beginning with "0" are treated as octal (i.e. base-8): we would have 'invalid octal number with 08 and 09'
   # Solution: convert to base-10 in this way: $((10#$i))
   ipv4=$(for i in $(echo $seq8 | sed 's/\(..\)/ \1 /g'); do printf "%d." $((10#$i)); done | sed 's/\.$/\n/')
-  # Sessions
-  sgx1_suffix=1$seq8
-  srx1_suffix=1$seq8
-  sgx2_suffix=2$seq8
-  srx2_suffix=2$seq8
 
   local target=$wkdir/values.${1}
   echo "__TESTID__=$testid" > $target
   echo "__SEQ8__=$seq8" >> $target
-  echo "__MSISDN9__=$msisdn9" >> $target
   echo "__IPV4HEX__=$ipv4hex" >> $target
   echo "__IPV4__=$ipv4" >> $target
-  echo "__SGX1_SUFFIX__=$sgx1_suffix" >> $target
-  echo "__SRX1_SUFFIX__=$srx1_suffix" >> $target
-  echo "__SGX2_SUFFIX__=$sgx2_suffix" >> $target
-  echo "__SRX2_SUFFIX__=$srx2_suffix" >> $target
   source $target
   #rm $target
   ######################################### END SPECIAL VARIABLES SECTION #########################################
@@ -131,7 +121,7 @@ clone() {
   rm $wkdir/testcase.txt.$sequence
 
   # Population:
-  if [ -n "$POPULATION_FILE" ]
+  if [ -n "$POPULATION" ]
   then
     parse_file $sequence $POPULATION_FILE $CLONE_WKDIR/${POPULATION}.$sequence
     cat $CLONE_WKDIR/${POPULATION}.$sequence >> $POPULATION_ALL
@@ -188,7 +178,7 @@ fi
 GROUPS_SIZE=$((N_ITEMS/N_GROUPS))
 if [ "$GROUPS_SIZE" -eq 0 ]
 then
-  echo "Assuming minimum allowed number of groups: $N_ITEMS"
+  echo "Assuming minimum allowed number of groups (one group per item): $N_ITEMS"
   GROUPS_SIZE=1
   N_GROUPS=$N_ITEMS
 fi
@@ -227,7 +217,9 @@ do
   #bn_dn_r_file=`basename $dn_r_file`
   #echo "Programming group $bn_dn_r_file ..."
   $OPERATION -f $r_file >/dev/null
+  res=$?
   #$OPERATION -f $r_file > $dn_r_file/result.txt
+  [ $res -ne 0 ] && _exit "Exception detected programming a testcase:\n\n`cat $r_file`"
   rm -rf $dn_r_file &
 done