Looks good to me. If this passes `make check`, go ahead and merge it
into master.

On 02/10/2015 12:58 AM, Richard Hansen wrote:
> Define a shell function called port_open() that tests to see if some
> local process is listening on a given TCP port and call that function
> instead of running 'nc -z'.  The port_open() function uses nc, but to
> avoid compatibility problems with versions of nc that don't support
> the -z option it simply redirects output/input to/from /dev/null.
> 
> addresses [#1]
> ---
> 
> This reroll fixes an obvious typo ("nc localhost localhost ...")
> 
>  tests/subsystem/rpki-local-ta/runSubsystemTest4.sh.in | 2 +-
>  tests/subsystem/rtr/test.sh.in                        | 2 +-
>  tests/subsystem/runSubsystemTest.sh.in                | 4 ++--
>  tests/test.include.in                                 | 6 ++++++
>  4 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/subsystem/rpki-local-ta/runSubsystemTest4.sh.in 
> b/tests/subsystem/rpki-local-ta/runSubsystemTest4.sh.in
> index 7218486..ff973f5 100644
> --- a/tests/subsystem/rpki-local-ta/runSubsystemTest4.sh.in
> +++ b/tests/subsystem/rpki-local-ta/runSubsystemTest4.sh.in
> @@ -35,7 +35,7 @@ done
>  run "update_cert" update_cert 0D 2Y testcases4_LTA/C?*.cer
>  
>  # check for existing loader and fail if so
> -if nc -z localhost `config_get RPKIPort`; then
> +if port_open `config_get RPKIPort`; then
>      echo "ERROR: port `config_get RPKIPort` is already in use.  Aborting 
> subsystem test."
>      exit 3
>  fi
> diff --git a/tests/subsystem/rtr/test.sh.in b/tests/subsystem/rtr/test.sh.in
> index 271b488..628d872 100644
> --- a/tests/subsystem/rtr/test.sh.in
> +++ b/tests/subsystem/rtr/test.sh.in
> @@ -209,7 +209,7 @@ start_rtrd () {
>  
>       for _discard in `seq 1 $SERVER_START_TIMEOUT`; do
>               sleep 1
> -             if nc -z localhost "$PORT"; then
> +             if port_open "$PORT"; then
>                       SERVER_STARTED=1
>                       break
>               fi
> diff --git a/tests/subsystem/runSubsystemTest.sh.in 
> b/tests/subsystem/runSubsystemTest.sh.in
> index b9a5955..a9610ea 100644
> --- a/tests/subsystem/runSubsystemTest.sh.in
> +++ b/tests/subsystem/runSubsystemTest.sh.in
> @@ -34,7 +34,7 @@ cd "$TESTS_BUILDDIR"
>  ./initDB || check_errs $? "initDB failed!"
>  
>  # check for existing loader and fail if so
> -if nc -z localhost `config_get RPKIPort`; then
> +if port_open `config_get RPKIPort`; then
>      echo "ERROR: port `config_get RPKIPort` is already in use.  Aborting 
> subsystem test."
>      exit 3
>  fi
> @@ -42,7 +42,7 @@ fi
>  # start loader
>  run_bg "rcli-w" rcli -w -p
>  LOADER_PID=$!
> -while ! nc -z localhost `config_get RPKIPort`; do
> +while ! port_open `config_get RPKIPort`; do
>      sleep 1
>  done
>  echo "Loader started (pid = $LOADER_PID)..."
> diff --git a/tests/test.include.in b/tests/test.include.in
> index e83ace4..c46edef 100644
> --- a/tests/test.include.in
> +++ b/tests/test.include.in
> @@ -94,3 +94,9 @@ use_config_file () {
>  
>      export @CONFIG_ENV_VAR@="$1"
>  }
> +
> +port_open() {
> +    command -v nc >/dev/null 2>/dev/null || fatal "nc utility not found"
> +    [ "$1" -ge 0 ] || fatal "must specify a port number"
> +    nc localhost "$1" </dev/null >/dev/null 2>&1
> +}
> 


-- 
David Eric Mandelberg / dseomn
http://david.mandelberg.org/

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
rpstir-devel mailing list
rpstir-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpstir-devel

Reply via email to