All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets
@ 2017-03-31 12:36 Peter Maydell
  2017-03-31 13:32 ` Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Peter Maydell @ 2017-03-31 12:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches, Eric Blake, Markus Armbruster

Occasionally if a test crashes or is interrupted by the user
at the wrong moment it could leave behind a stale UNIX
socket in /tmp/. This will then cause a subsequent test
run to fail spuriously with
 tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
if it happens to reuse the same PID.

Defend against this by deleting any stray stale socket before
trying to open the new ones for this test.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This seems like an easy way to shut up this infrequent but irritating
error case...

 tests/libqtest.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index a5c3d2b..99b1195 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -167,6 +167,14 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
     qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
 
+    /* It's possible that if an earlier test run crashed it might
+     * have left a stale unix socket lying around. Delete any
+     * stale old socket to avoid spurious test failures with
+     * tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
+     */
+    unlink(socket_path);
+    unlink(qmp_socket_path);
+
     sock = init_socket(socket_path);
     qmpsock = init_socket(qmp_socket_path);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets
  2017-03-31 12:36 [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets Peter Maydell
@ 2017-03-31 13:32 ` Philippe Mathieu-Daudé
  2017-03-31 14:04 ` Eric Blake
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-03-31 13:32 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Markus Armbruster, patches

On 03/31/2017 09:36 AM, Peter Maydell wrote:
> Occasionally if a test crashes or is interrupted by the user
> at the wrong moment it could leave behind a stale UNIX
> socket in /tmp/. This will then cause a subsequent test
> run to fail spuriously with
>  tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
> if it happens to reuse the same PID.
>
> Defend against this by deleting any stray stale socket before
> trying to open the new ones for this test.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
> This seems like an easy way to shut up this infrequent but irritating
> error case...
>
>  tests/libqtest.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index a5c3d2b..99b1195 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -167,6 +167,14 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>      socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
>      qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
>
> +    /* It's possible that if an earlier test run crashed it might
> +     * have left a stale unix socket lying around. Delete any
> +     * stale old socket to avoid spurious test failures with
> +     * tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
> +     */
> +    unlink(socket_path);
> +    unlink(qmp_socket_path);
> +
>      sock = init_socket(socket_path);
>      qmpsock = init_socket(qmp_socket_path);
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets
  2017-03-31 12:36 [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets Peter Maydell
  2017-03-31 13:32 ` Philippe Mathieu-Daudé
@ 2017-03-31 14:04 ` Eric Blake
  2017-04-03 18:01 ` Stefan Hajnoczi
  2017-04-11 15:14 ` Markus Armbruster
  3 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2017-03-31 14:04 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]

On 03/31/2017 07:36 AM, Peter Maydell wrote:
> Occasionally if a test crashes or is interrupted by the user
> at the wrong moment it could leave behind a stale UNIX
> socket in /tmp/. This will then cause a subsequent test
> run to fail spuriously with
>  tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
> if it happens to reuse the same PID.
> 
> Defend against this by deleting any stray stale socket before
> trying to open the new ones for this test.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This seems like an easy way to shut up this infrequent but irritating
> error case...

There is a related failure in qemu-iotests that I hit yesterday:

+mkfifo: cannot create fifo
'/home/eblake/qemu/tests/qemu-iotests/scratch/qmp-out-3812_0': File exists

that is probably also worth addressing, but that can be a separate patch.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets
  2017-03-31 12:36 [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets Peter Maydell
  2017-03-31 13:32 ` Philippe Mathieu-Daudé
  2017-03-31 14:04 ` Eric Blake
@ 2017-04-03 18:01 ` Stefan Hajnoczi
  2017-04-11 15:14 ` Markus Armbruster
  3 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2017-04-03 18:01 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Markus Armbruster, patches

[-- Attachment #1: Type: text/plain, Size: 797 bytes --]

On Fri, Mar 31, 2017 at 01:36:41PM +0100, Peter Maydell wrote:
> Occasionally if a test crashes or is interrupted by the user
> at the wrong moment it could leave behind a stale UNIX
> socket in /tmp/. This will then cause a subsequent test
> run to fail spuriously with
>  tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
> if it happens to reuse the same PID.
> 
> Defend against this by deleting any stray stale socket before
> trying to open the new ones for this test.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This seems like an easy way to shut up this infrequent but irritating
> error case...
> 
>  tests/libqtest.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets
  2017-03-31 12:36 [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets Peter Maydell
                   ` (2 preceding siblings ...)
  2017-04-03 18:01 ` Stefan Hajnoczi
@ 2017-04-11 15:14 ` Markus Armbruster
  2017-04-11 15:34   ` Peter Maydell
  3 siblings, 1 reply; 6+ messages in thread
From: Markus Armbruster @ 2017-04-11 15:14 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, patches

Peter Maydell <peter.maydell@linaro.org> writes:

> Occasionally if a test crashes or is interrupted by the user
> at the wrong moment it could leave behind a stale UNIX
> socket in /tmp/. This will then cause a subsequent test
> run to fail spuriously with
>  tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
> if it happens to reuse the same PID.
>
> Defend against this by deleting any stray stale socket before
> trying to open the new ones for this test.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This seems like an easy way to shut up this infrequent but irritating
> error case...
>
>  tests/libqtest.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index a5c3d2b..99b1195 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -167,6 +167,14 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
>      socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
>      qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
>  
> +    /* It's possible that if an earlier test run crashed it might
> +     * have left a stale unix socket lying around. Delete any
> +     * stale old socket to avoid spurious test failures with
> +     * tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
> +     */
> +    unlink(socket_path);
> +    unlink(qmp_socket_path);
> +
>      sock = init_socket(socket_path);
>      qmpsock = init_socket(qmp_socket_path);

No objection to this work-around for tests leaving crap behind, but I
think we should also try harder not to leave crap behind.  Say give each
test its own scratch directory, make sure no test writes outside it, and
have the harness remove it afterwards.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets
  2017-04-11 15:14 ` Markus Armbruster
@ 2017-04-11 15:34   ` Peter Maydell
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2017-04-11 15:34 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers, patches

On 11 April 2017 at 16:14, Markus Armbruster <armbru@redhat.com> wrote:
> No objection to this work-around for tests leaving crap behind, but I
> think we should also try harder not to leave crap behind.  Say give each
> test its own scratch directory, make sure no test writes outside it, and
> have the harness remove it afterwards.

That would all be nice, yes :-)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-11 15:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-31 12:36 [Qemu-devel] [PATCH] tests/libqtest.c: Delete possible stale unix sockets Peter Maydell
2017-03-31 13:32 ` Philippe Mathieu-Daudé
2017-03-31 14:04 ` Eric Blake
2017-04-03 18:01 ` Stefan Hajnoczi
2017-04-11 15:14 ` Markus Armbruster
2017-04-11 15:34   ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.