From fbe71916b6bcafa22a9f47f0bc2a2e30ee5a8d88 Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Sun, 20 Dec 2015 13:54:57 +0100 Subject: [PATCH] Variant P1 for clone. Allow test changes in-progress --- .../launcher/resources/scripts/clone.sh | 20 +++++++++++++++---- .../diameter/launcher/testing/TestCase.cpp | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/example/diameter/launcher/resources/scripts/clone.sh b/example/diameter/launcher/resources/scripts/clone.sh index e994e9e..9fd487c 100755 --- a/example/diameter/launcher/resources/scripts/clone.sh +++ b/example/diameter/launcher/resources/scripts/clone.sh @@ -41,10 +41,15 @@ usage() { echo echo " Currently, 9 variables are supported to be replaced:" 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 " * __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 " One variant (former ones plus 1):" + echo " * __SEQ8P1__ : 8-digit number corresponding to the sequence number (00000002 for 1, and so on)" + echo " * __IPV4HEXP1__: hexadecimal IPv4 address, for example: 00000002" + echo " * __IPV4P1__ : IPv4 address, for example: 0.0.0.2" echo echo " Edit the variables section to add more special values if you need them." echo @@ -94,17 +99,24 @@ clone() { ################################ EDIT THIS SECTION IF YOU NEED NEW SPECIAL VARIABLES ################################ testid=$sequence seq8=$(printf "%08d" $testid) + seq8_p1=$((seq8+1)) ipv4hex=$seq8 + ipv4hex_p1=$seq8_p1 #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/') + ipv4_p1=$(for i in $(echo $seq8_p1 | sed 's/\(..\)/ \1 /g'); do printf "%d." $((10#$i)); done | sed 's/\.$/\n/') local target=$wkdir/values.${1} echo "__TESTID__=$testid" > $target echo "__SEQ8__=$seq8" >> $target echo "__IPV4HEX__=$ipv4hex" >> $target echo "__IPV4__=$ipv4" >> $target + # First variant: + echo "__SEQ8P1__=$seq8_p1" >> $target + echo "__IPV4HEXP1__=$ipv4hex_p1" >> $target + echo "__IPV4P1__=$ipv4_p1" >> $target source $target #rm $target ######################################### END SPECIAL VARIABLES SECTION ######################################### diff --git a/example/diameter/launcher/testing/TestCase.cpp b/example/diameter/launcher/testing/TestCase.cpp index 6bc033d..8cbba4b 100644 --- a/example/diameter/launcher/testing/TestCase.cpp +++ b/example/diameter/launcher/testing/TestCase.cpp @@ -223,8 +223,8 @@ bool TestCase::reset(bool hard) throw() { } void TestCase::assertInitialized() const throw(anna::RuntimeException) { - if (a_state != State::Initialized) - throw anna::RuntimeException(anna::functions::asString("Cannot program anymore. The test case %llu was started. You must reset it to append new steps.", a_id), ANNA_FILE_LOCATION); + if (isFinished()) + throw anna::RuntimeException(anna::functions::asString("Cannot program anymore. The test case %llu has finished. You must reset it to append new steps (or do it during execution, which is also allowed).", a_id), ANNA_FILE_LOCATION); } void TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) throw(anna::RuntimeException) { -- 2.20.1