diff mbox series

[1/2] tests/sctp: fix a race condition in the new ASCONF test

Message ID 20201021214453.400811-2-omosnace@redhat.com (mailing list archive)
State Accepted
Delegated to: Ondrej Mosnáček
Headers show
Series Fix ASCONF test and ensure it can be always run | expand

Commit Message

Ondrej Mosnacek Oct. 21, 2020, 9:44 p.m. UTC
The new ASCONF test introduced recently (see Fixes: tag) is unstable and
can randomly fail on slow machines. The problem seems to be triggered
when the server does the sctp_bindx() calls before the client starts
listening for a new message, so add a 1 second sleep before the bindx
calls.

It is possible that this delay will not be enough on some very slow
machines, but let's start with a small value and see how it goes. The
one second seems to be enough for the Travis CI at least.

Fixes: 841ccaabb366 ("selinux-testsuite: Update SCTP asconf client/server")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 tests/sctp/sctp_asconf_params_server.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Richard Haines Oct. 22, 2020, 2:09 p.m. UTC | #1
On Wed, 2020-10-21 at 23:44 +0200, Ondrej Mosnacek wrote:
> The new ASCONF test introduced recently (see Fixes: tag) is unstable
> and
> can randomly fail on slow machines. The problem seems to be triggered
> when the server does the sctp_bindx() calls before the client starts
> listening for a new message, so add a 1 second sleep before the bindx
> calls.
> 
> It is possible that this delay will not be enough on some very slow
> machines, but let's start with a small value and see how it goes. The
> one second seems to be enough for the Travis CI at least.
> 
> Fixes: 841ccaabb366 ("selinux-testsuite: Update SCTP asconf
> client/server")
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
>  tests/sctp/sctp_asconf_params_server.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Tested the three asconf tests over 1000 interations with no problems.
In the meantime I'll review these tests to find a more reliable way to
run them.

Acked-by: Richard Haines <richard_c_haines@btinternet.com>
> 
> diff --git a/tests/sctp/sctp_asconf_params_server.c
> b/tests/sctp/sctp_asconf_params_server.c
> index 18e2cb2..ded782e 100644
> --- a/tests/sctp/sctp_asconf_params_server.c
> +++ b/tests/sctp/sctp_asconf_params_server.c
> @@ -225,6 +225,13 @@ int main(int argc, char **argv)
>  		       ((struct sockaddr_in6 *)
>  			new_pri_addr_res->ai_addr)->sin6_scope_id);
>  
> +	/*
> +	 * We can't do the sctp_bindx() calls too fast, otherwise the
> test
> +	 * that checks if these are denied would fail. Therefore, sleep
> for
> +	 * a bit to allow the client to catch up.
> +	 */
> +	sleep(1);
> +
>  	/*
>  	 * Now call sctp_bindx(3) to add 'new_pri_addr'. This uses
> Dynamic
>  	 * Address Reconfiguration by sending an asconf chunk with
diff mbox series

Patch

diff --git a/tests/sctp/sctp_asconf_params_server.c b/tests/sctp/sctp_asconf_params_server.c
index 18e2cb2..ded782e 100644
--- a/tests/sctp/sctp_asconf_params_server.c
+++ b/tests/sctp/sctp_asconf_params_server.c
@@ -225,6 +225,13 @@  int main(int argc, char **argv)
 		       ((struct sockaddr_in6 *)
 			new_pri_addr_res->ai_addr)->sin6_scope_id);
 
+	/*
+	 * We can't do the sctp_bindx() calls too fast, otherwise the test
+	 * that checks if these are denied would fail. Therefore, sleep for
+	 * a bit to allow the client to catch up.
+	 */
+	sleep(1);
+
 	/*
 	 * Now call sctp_bindx(3) to add 'new_pri_addr'. This uses Dynamic
 	 * Address Reconfiguration by sending an asconf chunk with