From 9546903ce7b309e0ddf21ab67208a150f280a795 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sat, 1 Sep 2012 16:32:50 +0930 Subject: [PATCH 1/5] Don't use an uninitialised variable. A compiler is well within its rights to throw this value away completely (and clang does so). See http://kqueue.org/blog/2012/06/25/more-randomness-or-less/ --- srandomdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/srandomdev.c b/srandomdev.c index 16c141e5..17fb41fb 100644 --- a/srandomdev.c +++ b/srandomdev.c @@ -77,8 +77,7 @@ srandomdev(void) { gettimeofday(&tv, NULL); - /* NOTE: intentional use of uninitialized variable */ - seed ^= (getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec; + seed = (getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec; } srandom(seed); } From e99462642949297b07d08bf0bbd43662d2f2910f Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Fri, 14 Sep 2012 15:04:05 +0930 Subject: [PATCH 2/5] Refactor test definitions Move create_rhizome_identities() from testdefs_rhizome.sh to create_identities() in testdefs.sh Rename create_identity() in testdefs.sh to create_single_identity(), uses create_identities() to do its work. --- testdefs.sh | 138 +++++++++++++++++++++++++++++++----------- testdefs_rhizome.sh | 46 -------------- tests/dnahelper | 3 + tests/rhizomeops | 4 +- tests/rhizomeprotocol | 4 +- 5 files changed, 108 insertions(+), 87 deletions(-) diff --git a/testdefs.sh b/testdefs.sh index 71bfdf0d..ac0b9763 100644 --- a/testdefs.sh +++ b/testdefs.sh @@ -416,41 +416,89 @@ assert_all_servald_servers_no_errors() { } # Utility function -# - create an identity +# - create an identity in the current instance {I} # - assign a phone number (DID) and name to the new identity, use defaults # if not specified by arg1 and arg2 -# - set the SID variable to the SID of the new identity -# - set the DID variable to the phone number of the new identity -# - set the NAME variable to the name of the new identity -create_identity() { - executeOk_servald keyring add - assert [ -e "$SERVALINSTANCE_PATH/serval.keyring" ] +# - assert the new identity is the only one in this instance +# - set the SID{I} variable, eg SIDA, to the SID of the new identity +# - set the DID{I} variable, eg DIDA, to the phone number of the new identity +# - set the NAME{I} variable, eg NAMEA, to the name of the new identity +create_single_identity() { + DID${instance_name}1="${1-$((5550000 + $instance_number))}" + NAME${instance_name}1="${2-Agent $instance_name Smith}" + create_identities 1 + local sidvar=SID${instance_name}1 + local didvar=DID${instance_name}1 + local namevar=NAME${instance_name}1 + eval SID$instance_name="${!sidvar}" + eval DID$instance_name="${!didvar}" + eval NAME$instance_name="${!namevar}" +} + +# Utility function: +# - create N identities in the current instance {I} +# - if variables DID{I}{1..N} and/or NAME{I}{1..N} are already set, then use +# them to set the DIDs and names of each identity +# - assert that all SIDs are unique +# - assert that all SIDs appear in keyring list +# - set variables SID{I}{1..N} to SIDs of identities, eg, SIDA1, SIDA2... +# - set variables DID{I}{1..N} to DIDs of identities, eg, DIDA1, DIDA2... +# - set variables NAME{I}{1..N} to names of identities, eg, NAMEA1, NAMEA2... +create_identities() { + local N="$1" + case "$N" in + +([0-9]));; + *) error "invalid arg1: $N";; + esac + local i j + for ((i = 1; i <= N; ++i)); do + executeOk_servald keyring add + assert [ -e "$SERVALINSTANCE_PATH/serval.keyring" ] + local sidvar=SID$instance_name$i + local didvar=DID$instance_name$i + local namevar=NAME$instance_name$i + extract_stdout_keyvalue $sidvar sid "$rexp_sid" + tfw_log "$sidvar=${!sidvar}" + # If the DID and/or NAME is already specified in the variables, then use + # them, otherwise extract the DID and NAME automatically generated by + # servald. + if [ -n "${!didvar}" -o -n "${!namevar}" ]; then + executeOk_servald set did $SID "${!didvar}" "${!namevar}" + eval "$didvar=\${!didvar}" + eval "$namevar=\${!namevar}" + else + extract_stdout_keyvalue_optional DID$instance_name$i did "$rexp_did" && tfw_log "$didvar=${!didvar}" + extract_stdout_keyvalue_optional NAME$instance_name$i name ".*" && tfw_log "$namevar=${!namevar}" + fi + done + for ((i = 1; i <= N; ++i)); do + for ((j = 1; j <= N; ++j)); do + [ $i -ne $j ] && eval assert [ "\$SID$instance_name$i" != "\$SID$instance_name$j" ] + done + done executeOk_servald keyring list - SID=$(replayStdout | sed -ne "1s/^\($rexp_sid\):.*\$/\1/p") - assert --message='main identity known' [ -n "$SID" ] - DID="${1-$((5550000 + $instance_number))}" - NAME="${2-Agent $instance_name Smith}" - executeOk_servald set did $SID "$DID" "$NAME" - tfw_log "Identity $instance_name: $SID $DID $NAME" + assertStdoutLineCount '==' $N + for ((i = 1; i <= N; ++i)); do + local sidvar=SID$instance_name$i + local didvar=DID$instance_name$i + local namevar=NAME$instance_name$i + local re_name=$(escape_grep_basic "${!namevar}") + assertStdoutGrep --matches=1 "^${!sidvar}:${!didvar}:${re_name}\$" + done } # Utility function, to be overridden as needed: -# - set up the configuration immediately prior to starting a servald server -# process +# - set up the configuration immediately prior to starting a servald server process # - called by start_servald_instances configure_servald_server() { : } # Utility function: -# - start a set of servald server processes running on a shared dummy interface -# and with its own private monitor and MDP abstract socket names +# - start a set of servald server processes running on a shared dummy interface and with its own +# private monitor and MDP abstract socket names # - set variable DUMMYNET to the full path name of shared dummy interface -# - set variables SIDx to the SID of instance x: SIDA, SIDB, etc. -# - set variables DIDx to the DID of instance x: DIDA, DIDB, etc. -# - set variables NAMEx to the names of instance x: NAMEA, NAMEB, etc. -# - set variables LOGx to the full path of server log file for instance x: LOGA, -# LOGB, etc, +# - set variables LOGx to the full path of server log file for instance x: LOGA, LOGB, etc, # - wait for all instances to detect each other # - assert that all instances are in each others' peer lists start_servald_instances() { @@ -458,47 +506,63 @@ start_servald_instances() { tfw_log "# start servald instances $*" DUMMYNET=$SERVALD_VAR/dummy >$DUMMYNET - local I J + local I for I; do set_instance $I - create_identity + # These config settings can be overridden in a caller-supplied configure_servald_server(). + # They are extremely useful for the majority of fixtures. executeOk_servald config set interfaces "+>$DUMMYNET" executeOk_servald config set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" configure_servald_server start_servald_server - eval SID$instance_name="$SID" - eval DID$instance_name="$(shellarg "$DID")" - eval NAME$instance_name="$(shellarg "$NAME")" eval LOG$instance_name="$(shellarg "$instance_servald_log")" done # Now wait until they see each other. wait_until --sleep=0.25 instances_see_each_other "$@" tfw_log "# dummynet file:" $(ls -l $DUMMYNET) - # Assert that all instances report complete all-peer lists. + pop_instance +} + +# Assertion function: +# - asserts that all running instances report peer lists that contain all the SIDs of all the other +# running instances +# - uses the SID{I}{1..N} variables set by create_instances() +assert_all_instance_peers_complete() { + push_instance + local I J N for I; do set_instance $I executeOk_servald id allpeers - assertStdoutLineCount '==' $(($# - 1)) for J; do [ $I = $J ] && continue - local sidvar=SID${J#+} - assertStdoutGrep "${!sidvar}" + for ((N=1; 1; ++N)); do + local sidvar=SID${J#+}$N + [ -n "${!sidvar}" ] || break + assertStdoutGrep "${!sidvar}" + done done done pop_instance } +# Predicate function: +# - useful in combination with assert() and wait_until() +# - return true if all instances have logged that they have seen all other instances via the +# selfannounce mechanism instances_see_each_other() { - local I J + local I J N for I; do + local logvar=LOG${I#+} for J; do [ $I = $J ] && continue - local logvar=LOG${I#+} - local sidvar=SID${J#+} - if ! grep "ADD OVERLAY NODE sid=${!sidvar}" "${!logvar}"; then - return 1 - fi + for ((N=1; 1; ++N)); do + local sidvar=SID${J#+}$N + [ -n "${!sidvar}" ] || break + if ! grep "ADD OVERLAY NODE sid=${!sidvar}" "${!logvar}"; then + return 1 + fi + done done done return 0 diff --git a/testdefs_rhizome.sh b/testdefs_rhizome.sh index a8b36fc0..721483bb 100644 --- a/testdefs_rhizome.sh +++ b/testdefs_rhizome.sh @@ -26,52 +26,6 @@ rexp_filesize='[0-9]\{1,\}' rexp_version='[0-9]\{1,\}' rexp_date='[0-9]\{1,\}' -# Utility function: -# - create N identities in the current instance (I) -# - set variable SID to SID of first identity -# - set variable SID{I} to SID of first identity, eg, SIDA -# - set variables SID{I}{1..N} to SIDs of identities, eg, SIDA1, SIDA2... -# - set variables DID{I}{1..N} to DIDs of identities, eg, DIDA1, DIDA2... -# - set variables NAME{I}{1..N} to names of identities, eg, NAMEA1, NAMEA2... -# - assert that all SIDs are unique -# - assert that all SIDs appear in keyring list -create_rhizome_identities() { - local N="$1" - case "$N" in - +([0-9]));; - *) error "invalid arg1: $N";; - esac - local i j - for ((i = 1; i <= N; ++i)); do - executeOk_servald keyring add - local sidvar=SID$instance_name$i - local didvar=DID$instance_name$i - local namevar=NAME$instance_name$i - extract_stdout_keyvalue $sidvar sid "$rexp_sid" - tfw_log "$sidvar=${!sidvar}" - if [ $i -eq 1 ]; then - SID="${!sidvar}" - eval SID$instance_name="$SID" - fi - extract_stdout_keyvalue_optional DID$instance_name$i did "$rexp_did" && tfw_log "$didvar=${!didvar}" - extract_stdout_keyvalue_optional NAME$instance_name$i name ".*" && tfw_log "$namevar=${!namevar}" - done - for ((i = 1; i <= N; ++i)); do - for ((j = 1; j <= N; ++j)); do - [ $i -ne $j ] && eval assert [ "\$SID$instance_name$i" != "\$SID$instance_name$j" ] - done - done - executeOk_servald keyring list - assertStdoutLineCount '==' $N - for ((i = 1; i <= N; ++i)); do - local sidvar=SID$instance_name$i - local didvar=DID$instance_name$i - local namevar=NAME$instance_name$i - local re_name=$(escape_grep_basic "${!namevar}") - assertStdoutGrep --matches=1 "^${!sidvar}:${!didvar}:${re_name}\$" - done -} - assert_manifest_complete() { local manifest="$1" tfw_cat -v "$manifest" diff --git a/tests/dnahelper b/tests/dnahelper index 262f1603..433d6d1a 100755 --- a/tests/dnahelper +++ b/tests/dnahelper @@ -26,6 +26,7 @@ setup() { assert_no_servald_processes setup_dnahelper start_servald_instances +A + assert_all_instance_peers_complete +A } teardown() { @@ -221,6 +222,7 @@ setup_ExecError() { dnahelper=/non/existent assert [ ! -e "$dnahelper" ] start_servald_instances +A + assert_all_instance_peers_complete +A } test_ExecError() { executeOk_servald dna lookup 12345 @@ -246,6 +248,7 @@ done EOF chmod 0755 "$dnahelper" start_servald_instances +A + assert_all_instance_peers_complete +A } test_ExecArg1() { executeOk_servald dna lookup 12345 diff --git a/tests/rhizomeops b/tests/rhizomeops index 827d3aa6..836189be 100755 --- a/tests/rhizomeops +++ b/tests/rhizomeops @@ -27,10 +27,10 @@ shopt -s extglob setup_rhizome() { set_instance +A executeOk_servald config set debug.rhizome on - create_rhizome_identities 1 + create_identities 1 set_instance +B executeOk_servald config set debug.rhizome on - create_rhizome_identities 4 + create_identities 4 assert [ $SIDB1 != $SIDA1 ] assert [ $SIDB2 != $SIDA1 ] assert [ $SIDB3 != $SIDA1 ] diff --git a/tests/rhizomeprotocol b/tests/rhizomeprotocol index 6a37c334..5d620f76 100755 --- a/tests/rhizomeprotocol +++ b/tests/rhizomeprotocol @@ -32,9 +32,9 @@ teardown() { setup_rhizome() { set_instance +A - create_rhizome_identities 1 + create_identities 1 set_instance +B - create_rhizome_identities 1 + create_identities 1 } # Called by start_servald_instances for each instance. From 87133cb2de62671e3386481d1df7553361118fbf Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Fri, 14 Sep 2012 16:09:28 +0930 Subject: [PATCH 3/5] Improve testdefs: foreach_instance() function The 'rhizomeprotocol' tests now use create_single_identity() in fixtures (which tests the 'keyring list' command). Use foreach_instance() function in various places, and replace functions that used to loop over instances with functions that work on the current instance. --- testdefs.sh | 117 +++++++++++++++++++++++++++++------------- tests/rhizomeprotocol | 14 +++-- 2 files changed, 91 insertions(+), 40 deletions(-) diff --git a/testdefs.sh b/testdefs.sh index ac0b9763..cd531d9d 100644 --- a/testdefs.sh +++ b/testdefs.sh @@ -131,7 +131,8 @@ set_instance() { error "missing instance name argument" ;; +[A-Z]) - instance_name="${1#+}" + instance_arg="${1}" + instance_name="${instance_arg#+}" instance_number=$((36#$instance_name - 9)) tfw_log "# set instance = $instance_name, number = $instance_number" export instance_dir="${servald_instances_dir?:}/$instance_name" @@ -146,6 +147,48 @@ set_instance() { esac } +# Composition function: +# - invoke a command once in many instances +# - in "--all" mode (default), returns the count of commands that returned +# nonzero (ie, failure count); this returns zero only if all commands in all +# instances return zero, ie, is an AND relation on success; this is +# guaranteed to invoke the command in all instances (unless terminated +# by a failed assertion) +# - in "--any" mode, returns zero as soon as any command returns zero; ie, is +# an OR relation on success; N.B. this may not invoke the command in all +# instances +foreach_instance() { + mode=all + case "$1" in + --any) mode=any; shift;; + --all) mode=all; shift;; + esac + local -a instances=() + while [ $# -ne 0 ]; do + case "$1" in + +[A-Z]) instances+=("$1"); shift;; + *) break;; + esac + done + push_instance + local ret=0 + local I + for I in ${instances[*]}; do + set_instance $I + if "$@"; then + case $mode in + any) break;; + esac + else + case $mode in + all) let ++ret;; + esac + fi + done + pop_instance + return $ret +} + # Utility function for setting up servald JNI fixtures: # - check that libservald.so is present # - set LD_LIBRARY_PATH so that libservald.so can be found @@ -424,12 +467,12 @@ assert_all_servald_servers_no_errors() { # - set the DID{I} variable, eg DIDA, to the phone number of the new identity # - set the NAME{I} variable, eg NAMEA, to the name of the new identity create_single_identity() { - DID${instance_name}1="${1-$((5550000 + $instance_number))}" - NAME${instance_name}1="${2-Agent $instance_name Smith}" - create_identities 1 local sidvar=SID${instance_name}1 local didvar=DID${instance_name}1 local namevar=NAME${instance_name}1 + eval "$didvar=\${1-\$((5550000 + \$instance_number))}" + eval "$namevar=\${2-Agent \$instance_name Smith}" + create_identities 1 eval SID$instance_name="${!sidvar}" eval DID$instance_name="${!didvar}" eval NAME$instance_name="${!namevar}" @@ -463,12 +506,12 @@ create_identities() { # them, otherwise extract the DID and NAME automatically generated by # servald. if [ -n "${!didvar}" -o -n "${!namevar}" ]; then - executeOk_servald set did $SID "${!didvar}" "${!namevar}" + executeOk_servald set did "${!sidvar}" "${!didvar}" "${!namevar}" eval "$didvar=\${!didvar}" eval "$namevar=\${!namevar}" else - extract_stdout_keyvalue_optional DID$instance_name$i did "$rexp_did" && tfw_log "$didvar=${!didvar}" - extract_stdout_keyvalue_optional NAME$instance_name$i name ".*" && tfw_log "$namevar=${!namevar}" + extract_stdout_keyvalue_optional $didvar did "$rexp_did" && tfw_log "$didvar=${!didvar}" + extract_stdout_keyvalue_optional $namevar name ".*" && tfw_log "$namevar=${!namevar}" fi done for ((i = 1; i <= N; ++i)); do @@ -525,25 +568,39 @@ start_servald_instances() { } # Assertion function: -# - asserts that all running instances report peer lists that contain all the SIDs of all the other -# running instances +# - asserts that the current instance reports a peer list that contains all the +# SIDs of all the other instances # - uses the SID{I}{1..N} variables set by create_instances() -assert_all_instance_peers_complete() { - push_instance - local I J N +assert_peers_are_instances() { + local I N + executeOk_servald id allpeers for I; do - set_instance $I - executeOk_servald id allpeers - for J; do - [ $I = $J ] && continue - for ((N=1; 1; ++N)); do - local sidvar=SID${J#+}$N - [ -n "${!sidvar}" ] || break - assertStdoutGrep "${!sidvar}" - done + for ((N=1; 1; ++N)); do + local sidvar=SID${I#+}$N + [ -n "${!sidvar}" ] || break + assertStdoutGrep "${!sidvar}" done done - pop_instance +} + +# Predicate function: +# - useful in combination with assert() and wait_until() +# - return true if the current instance has logged that it has seen all other instances via the +# selfannounce mechanism +has_seen_instances() { + local I N + local logvar=LOG$instance_name + for I; do + [ $I = $instance_arg ] && continue + for ((N=1; 1; ++N)); do + local sidvar=SID${I#+}$N + [ -n "${!sidvar}" ] || break + if ! grep "ADD OVERLAY NODE sid=${!sidvar}" "${!logvar}"; then + return 1 + fi + done + done + return 0 } # Predicate function: @@ -551,19 +608,5 @@ assert_all_instance_peers_complete() { # - return true if all instances have logged that they have seen all other instances via the # selfannounce mechanism instances_see_each_other() { - local I J N - for I; do - local logvar=LOG${I#+} - for J; do - [ $I = $J ] && continue - for ((N=1; 1; ++N)); do - local sidvar=SID${J#+}$N - [ -n "${!sidvar}" ] || break - if ! grep "ADD OVERLAY NODE sid=${!sidvar}" "${!logvar}"; then - return 1 - fi - done - done - done - return 0 + foreach_instance "$@" has_seen_instances "$@" } diff --git a/tests/rhizomeprotocol b/tests/rhizomeprotocol index 5d620f76..8c27f301 100755 --- a/tests/rhizomeprotocol +++ b/tests/rhizomeprotocol @@ -31,10 +31,8 @@ teardown() { } setup_rhizome() { - set_instance +A - create_identities 1 + foreach_instance +A +B create_single_identity set_instance +B - create_identities 1 } # Called by start_servald_instances for each instance. @@ -110,6 +108,8 @@ setup_FileTransfer() { set_instance +A add_file file1 start_servald_instances +A +B + foreach_instance +A assert_peers_are_instances +B + foreach_instance +B assert_peers_are_instances +A } test_FileTransfer() { wait_until bundle_received_by +B @@ -131,6 +131,8 @@ setup_FileTransferBig() { ls -l file1 add_file file1 start_servald_instances +A +B + foreach_instance +A assert_peers_are_instances +B + foreach_instance +B assert_peers_are_instances +A } test_FileTransferBig() { wait_until bundle_received_by +B @@ -156,6 +158,10 @@ setup_FileTransferMulti() { set_instance +A add_file file1 start_servald_instances +A +B +C +D +E + foreach_instance +A assert_peers_are_instances +B +C +D +E + foreach_instance +B assert_peers_are_instances +A +C +D +E + foreach_instance +C assert_peers_are_instances +A +B +D +E + foreach_instance +D assert_peers_are_instances +A +B +C +E } test_FileTransferMulti() { wait_until bundle_received_by +B +C +D +E @@ -172,6 +178,8 @@ setup_FileTransferDelete() { set_instance +A add_file file1 start_servald_instances +A +B + foreach_instance +A assert_peers_are_instances +B + foreach_instance +B assert_peers_are_instances +A wait_until bundle_received_by +B set_instance +A >file1_2 From 7452c215e2cc1ee397497f469a8bf3d4083d279f Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Fri, 14 Sep 2012 16:23:32 +0930 Subject: [PATCH 4/5] Fix bug in 'keyring list' command Revealed by recent rhizomeprotocol test improvements. Was always printing empty DID and name fields. --- keyring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyring.c b/keyring.c index 95c3d189..0997f7dd 100644 --- a/keyring.c +++ b/keyring.c @@ -1350,7 +1350,7 @@ int keyring_find_sid(const keyring_file *k, int *cn, int *in, int *kp, const uns void keyring_identity_extract(const keyring_identity *id, const unsigned char **sidp, const char **didp, const char **namep) { - int todo = (sidp ? 1 : 0) | (didp ? 2 : 0) || (namep ? 4 : 0); + int todo = (sidp ? 1 : 0) | (didp ? 2 : 0) | (namep ? 4 : 0); int kpn; for (kpn = 0; todo && kpn < id->keypair_count; ++kpn) { keypair *kp = id->keypairs[kpn]; From 9d8707a0add0c5fd3578abff8ccb18b1325fd36d Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Mon, 17 Sep 2012 15:30:05 +0930 Subject: [PATCH 5/5] Fix broken 'dnaprotocol' tests Explicitly create identities in 'dnaprotocol' fixtures because start_servald_instances() no longer does it. The create_single_identity() function was not setting NAMEA, NAMEB, etc. when they contained a space, because of shell misquoting. --- testdefs.sh | 22 +++++++++++++++------- tests/dnaprotocol | 7 +++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/testdefs.sh b/testdefs.sh index cd531d9d..b75e0513 100644 --- a/testdefs.sh +++ b/testdefs.sh @@ -470,12 +470,18 @@ create_single_identity() { local sidvar=SID${instance_name}1 local didvar=DID${instance_name}1 local namevar=NAME${instance_name}1 - eval "$didvar=\${1-\$((5550000 + \$instance_number))}" - eval "$namevar=\${2-Agent \$instance_name Smith}" + eval "$didvar=\"\${1-\$((5550000 + \$instance_number))}\"" + eval "$namevar=\"\${2-Agent \$instance_name Smith}\"" create_identities 1 - eval SID$instance_name="${!sidvar}" - eval DID$instance_name="${!didvar}" - eval NAME$instance_name="${!namevar}" + eval "SID$instance_name=\"\${!sidvar}\"" + eval "DID$instance_name=\"\${!didvar}\"" + eval "NAME$instance_name=\"\${!namevar}\"" + sidvar=SID${instance_name} + didvar=DID${instance_name} + namevar=NAME${instance_name} + tfw_log "SID$instance_name=$(shellarg "${!sidvar}")" + tfw_log "DID$instance_name=$(shellarg "${!didvar}")" + tfw_log "NAME$instance_name=$(shellarg "${!namevar}")" } # Utility function: @@ -509,9 +515,11 @@ create_identities() { executeOk_servald set did "${!sidvar}" "${!didvar}" "${!namevar}" eval "$didvar=\${!didvar}" eval "$namevar=\${!namevar}" + tfw_log "$didvar=$(shellarg "${!didvar}")" + tfw_log "$namevar=$(shellarg "${!namevar}")" else - extract_stdout_keyvalue_optional $didvar did "$rexp_did" && tfw_log "$didvar=${!didvar}" - extract_stdout_keyvalue_optional $namevar name ".*" && tfw_log "$namevar=${!namevar}" + extract_stdout_keyvalue_optional $didvar did "$rexp_did" && tfw_log "$didvar=$(shellarg "${!didvar}")" + extract_stdout_keyvalue_optional $namevar name ".*" && tfw_log "$namevar=$(shellarg "${!namevar}")" fi done for ((i = 1; i <= N; ++i)); do diff --git a/tests/dnaprotocol b/tests/dnaprotocol index 30d94f02..f89506d2 100755 --- a/tests/dnaprotocol +++ b/tests/dnaprotocol @@ -39,6 +39,7 @@ instances_reach_each_other() { setup() { setup_servald assert_no_servald_processes + foreach_instance +A +B create_single_identity configure_servald_server() { set_server_vars; } start_servald_instances +A +B wait_until --sleep=0.25 instances_reach_each_other +A +B @@ -70,6 +71,7 @@ doc_MultiServer="Start three servald servers with dummy interfaces" setup_MultiServer() { setup_servald assert_no_servald_processes + foreach_instance +A +B +C create_single_identity configure_servald_server() { set_server_vars; } } test_MultiServer() { @@ -80,8 +82,8 @@ doc_LookupWildcard="Lookup by wildcard" test_LookupWildcard() { executeOk_servald dna lookup "*" assertStdoutLineCount '==' 2 - assertStdoutGrep --matches=1 "^sid://$SIDA/$DIDA:$DIDA:$NAMEA$" - assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB$" + assertStdoutGrep --matches=1 "^sid://$SIDA/$DIDA:$DIDA:$NAMEA\$" + assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB\$" } doc_LookupEmpty="Lookup by empty string" @@ -164,6 +166,7 @@ do done EOF chmod 0755 "$dnahelper" + foreach_instance +A +B +C +D create_single_identity configure_servald_server() { set_server_vars executeOk_servald config set debug.dnahelper on