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
This commit is contained in:
Aleksander Morgado
2016-11-23 10:53:56 +01:00
parent 20074c5574
commit 944e34ecdb

View File

@@ -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 <aleksander@gnu.org>
* Copyright (C) 2016 Aleksander Morgado <aleksander@gnu.org>
*/
#include <sys/types.h>
#include <unistd.h>
#include <glib.h>
#include <glib-object.h>
@@ -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]);
}
/*****************************************************************************/