diff --git a/scripts/client.test b/scripts/client.test index 086f19f6..c2fe1d27 100755 --- a/scripts/client.test +++ b/scripts/client.test @@ -31,6 +31,10 @@ generate_port() { # function to produce a random port number echo -e "Using port $port" } +check_broker() { + timeout 10 sh -c 'until nc -v -z $0 $1; do sleep 1; done' localhost $port +} + # Check for application [ ! -x ./examples/mqttclient/mqttclient ] && echo -e "\n\nMQTT Client doesn't exist" && exit 1 @@ -68,8 +72,9 @@ then mosquitto $broker_args & broker_pid=$! echo "Broker PID is $broker_pid" - sleep 0.1 + check_broker + def_args="${def_args} -h localhost" tls_port_args="-p 18883" port_args="-p ${port}" diff --git a/scripts/firmware.test b/scripts/firmware.test index 70672914..cbcc57f9 100755 --- a/scripts/firmware.test +++ b/scripts/firmware.test @@ -34,6 +34,9 @@ generate_port() { # function to produce a random port number echo -e "Using port $port" } +check_broker() { + timeout 10 sh -c 'until nc -v -z $0 $1; do sleep 1; done' localhost $port +} # Check for application [ ! -x ./examples/firmware/fwpush ] && echo -e "\n\nMQTT Example fwpush doesn't exist" && exit 1 @@ -80,8 +83,9 @@ then mosquitto $broker_args & broker_pid=$! echo "Broker PID is $broker_pid" - sleep 0.1 - + + check_broker + def_args="${def_args} -h localhost -p ${port}" fi diff --git a/scripts/nbclient.test b/scripts/nbclient.test index 91624a92..87ac7fb2 100755 --- a/scripts/nbclient.test +++ b/scripts/nbclient.test @@ -31,6 +31,10 @@ generate_port() { # function to produce a random port number echo -e "Using port $port" } +check_broker() { + timeout 10 sh -c 'until nc -v -z $0 $1; do sleep 1; done' localhost $port +} + # Check for application [ ! -x ./examples/nbclient/nbclient ] && echo -e "\n\nNon-blocking Client doesn't exist" && exit 1 @@ -69,8 +73,9 @@ then mosquitto $broker_args & broker_pid=$! echo "Broker PID is $broker_pid" - sleep 0.1 + check_broker + def_args="${def_args} -h localhost" tls_port_args="-p 18883" port_args="-p ${port}"