From 531f77f70ef69abb410e288f075d10eb3609f90a Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 23 Nov 2016 10:53:56 +0100 Subject: tests,dbus: append pid to abstract socket name So that different concurrent runs of this same test don't clash with each other: TEST: test-service-generic... (pid=11124) /MM/Service/Generic/enable-disable: Activating service name='org.freedesktop.ModemManager1' Successfully activated service 'org.freedesktop.ModemManager1' ** (plugins/.libs/lt-test-service-generic>:11124): ERROR **: Cannot bind socket: Error binding to address: Address already in use cleaning up pid 11144 FAIL (cherry picked from commit 944e34ecdb9028b68b2144dd2c6d698d508f1808) --- plugins/generic/tests/test-service-generic.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/generic/tests/test-service-generic.c b/plugins/generic/tests/test-service-generic.c index 37fb7cec5..8c21cd05d 100644 --- a/plugins/generic/tests/test-service-generic.c +++ b/plugins/generic/tests/test-service-generic.c @@ -10,10 +10,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * - * Copyright (C) 2013 Aleksander Morgado + * Copyright (C) 2016 Aleksander Morgado */ +#include #include + #include #include @@ -31,10 +33,12 @@ test_enable_disable (TestFixture *fixture) MMObject *obj; MMModem *modem; TestPortContext *port0; - const gchar *ports [] = { - "abstract:port0", - NULL - }; + gchar *ports [] = { NULL, NULL }; + + /* Create port name, and add process ID so that multiple runs of this test + * in the same system don't clash with each other */ + ports[0] = g_strdup_printf ("abstract:port0:%ld", (glong) getpid ()); + g_debug ("test service generic: using abstract port at '%s'", ports[0]); /* Setup new port context */ port0 = test_port_context_new (ports[0]); @@ -69,6 +73,8 @@ test_enable_disable (TestFixture *fixture) /* Stop port context */ test_port_context_stop (port0); test_port_context_free (port0); + + g_free (ports[0]); } /*****************************************************************************/ -- cgit v1.2.1