Blame SOURCES/bz1211375-ipc-test-update3.patch

6b94ce
From 378be495e888fc9b5c1adeef078c06b662cf5a54 Mon Sep 17 00:00:00 2001
6b94ce
From: David Vossel <dvossel@redhat.com>
6b94ce
Date: Thu, 16 Apr 2015 09:53:12 -0500
6b94ce
Subject: [PATCH 4/4] Low: check_ipc: generate unique server names for tests
6b94ce
6b94ce
Package builders that run multiple builds of libqb in parallel
6b94ce
will fail because the IPC unit tests stomp on each other's namespace.
6b94ce
We have to give each IPC server a randomized unique name during
6b94ce
'make check' to avoid this.
6b94ce
---
6b94ce
 tests/check_ipc.c | 65 +++++++++++++++++++++++++++++++++----------------------
6b94ce
 1 file changed, 39 insertions(+), 26 deletions(-)
6b94ce
6b94ce
diff --git a/tests/check_ipc.c b/tests/check_ipc.c
6b94ce
index b69d9fb..4397963 100644
6b94ce
--- a/tests/check_ipc.c
6b94ce
+++ b/tests/check_ipc.c
6b94ce
@@ -32,7 +32,7 @@
6b94ce
 #include <qb/qbipcs.h>
6b94ce
 #include <qb/qbloop.h>
6b94ce
 
6b94ce
-static const char *ipc_name = "ipc_test";
6b94ce
+static char ipc_name[256];
6b94ce
 
6b94ce
 #define DEFAULT_MAX_MSG_SIZE (8192*16)
6b94ce
 static int CALCULATED_DGRAM_MAX_MSG_SIZE = 0;
6b94ce
@@ -105,6 +105,18 @@ exit_handler(int32_t rsignal, void *data)
6b94ce
 	return -1;
6b94ce
 }
6b94ce
 
6b94ce
+static void
6b94ce
+set_ipc_name(const char *prefix)
6b94ce
+{
6b94ce
+	/* We have to give the server name a random postfix because
6b94ce
+	 * some build systems attempt to generate packages for libqb
6b94ce
+	 * in parallel. These unit tests are run during the package
6b94ce
+	 * build process. Two builds executing on the same machine
6b94ce
+	 * can stomp on each other's unit tests if the ipc server
6b94ce
+	 * names aren't unique... This was very confusing to debug */
6b94ce
+	snprintf(ipc_name, 256, "%s-%d", prefix, (int32_t)random());
6b94ce
+}
6b94ce
+
6b94ce
 static int32_t
6b94ce
 s1_msg_process_fn(qb_ipcs_connection_t *c,
6b94ce
 		void *data, size_t size)
6b94ce
@@ -710,7 +722,7 @@ START_TEST(test_ipc_exit_us)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	recv_timeout = 5000;
6b94ce
 	test_ipc_exit();
6b94ce
 	qb_leave();
6b94ce
@@ -721,7 +733,7 @@ START_TEST(test_ipc_exit_shm)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	recv_timeout = 1000;
6b94ce
 	test_ipc_exit();
6b94ce
 	qb_leave();
6b94ce
@@ -732,7 +744,7 @@ START_TEST(test_ipc_txrx_shm_timeout)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_txrx_timeout();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -742,7 +754,7 @@ START_TEST(test_ipc_txrx_us_timeout)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_txrx_timeout();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -753,7 +765,7 @@ START_TEST(test_ipc_txrx_shm_tmo)
6b94ce
 	qb_enter();
6b94ce
 	turn_on_fc = QB_FALSE;
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	recv_timeout = 1000;
6b94ce
 	test_ipc_txrx();
6b94ce
 	qb_leave();
6b94ce
@@ -765,7 +777,7 @@ START_TEST(test_ipc_txrx_shm_block)
6b94ce
 	qb_enter();
6b94ce
 	turn_on_fc = QB_FALSE;
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	recv_timeout = -1;
6b94ce
 	test_ipc_txrx();
6b94ce
 	qb_leave();
6b94ce
@@ -778,7 +790,7 @@ START_TEST(test_ipc_fc_shm)
6b94ce
 	turn_on_fc = QB_TRUE;
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
 	recv_timeout = 500;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_txrx();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -789,7 +801,7 @@ START_TEST(test_ipc_txrx_us_block)
6b94ce
 	qb_enter();
6b94ce
 	turn_on_fc = QB_FALSE;
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	recv_timeout = -1;
6b94ce
 	test_ipc_txrx();
6b94ce
 	qb_leave();
6b94ce
@@ -801,7 +813,7 @@ START_TEST(test_ipc_txrx_us_tmo)
6b94ce
 	qb_enter();
6b94ce
 	turn_on_fc = QB_FALSE;
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	recv_timeout = 1000;
6b94ce
 	test_ipc_txrx();
6b94ce
 	qb_leave();
6b94ce
@@ -814,7 +826,7 @@ START_TEST(test_ipc_fc_us)
6b94ce
 	turn_on_fc = QB_TRUE;
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
 	recv_timeout = 500;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_txrx();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -869,7 +881,7 @@ START_TEST(test_ipc_disp_us)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_dispatch();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1136,7 +1148,7 @@ START_TEST(test_ipc_stress_test_us)
6b94ce
 	qb_enter();
6b94ce
 	send_event_on_created = QB_FALSE;
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_stress_test();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1146,7 +1158,7 @@ START_TEST(test_ipc_stress_connections_us)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_stress_connections();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1157,7 +1169,7 @@ START_TEST(test_ipc_bulk_events_us)
6b94ce
 	qb_enter();
6b94ce
 	send_event_on_created = QB_FALSE;
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_bulk_events();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1213,7 +1225,7 @@ START_TEST(test_ipc_event_on_created_us)
6b94ce
 	qb_enter();
6b94ce
 	send_event_on_created = QB_TRUE;
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_event_on_created();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1275,7 +1287,7 @@ START_TEST(test_ipc_disconnect_after_created_us)
6b94ce
 	qb_enter();
6b94ce
 	disconnect_after_created = QB_TRUE;
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_disconnect_after_created();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1314,7 +1326,7 @@ START_TEST(test_ipc_server_fail_soc)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_server_fail();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1324,7 +1336,7 @@ START_TEST(test_ipc_disp_shm)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_dispatch();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1335,7 +1347,7 @@ START_TEST(test_ipc_stress_test_shm)
6b94ce
 	qb_enter();
6b94ce
 	send_event_on_created = QB_FALSE;
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_stress_test();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1345,7 +1357,7 @@ START_TEST(test_ipc_stress_connections_shm)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_stress_connections();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1355,7 +1367,7 @@ START_TEST(test_ipc_bulk_events_shm)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_bulk_events();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1366,7 +1378,7 @@ START_TEST(test_ipc_event_on_created_shm)
6b94ce
 	qb_enter();
6b94ce
 	send_event_on_created = QB_TRUE;
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_event_on_created();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1376,7 +1388,7 @@ START_TEST(test_ipc_server_fail_shm)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_server_fail();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1417,7 +1429,7 @@ START_TEST(test_ipc_service_ref_count_shm)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SHM;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_service_ref_count();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1427,7 +1439,7 @@ START_TEST(test_ipc_service_ref_count_us)
6b94ce
 {
6b94ce
 	qb_enter();
6b94ce
 	ipc_type = QB_IPC_SOCKET;
6b94ce
-	ipc_name = __func__;
6b94ce
+	set_ipc_name(__func__);
6b94ce
 	test_ipc_service_ref_count();
6b94ce
 	qb_leave();
6b94ce
 }
6b94ce
@@ -1620,6 +1632,7 @@ main(void)
6b94ce
 	Suite *s;
6b94ce
 	int32_t do_shm_tests = QB_TRUE;
6b94ce
 
6b94ce
+	set_ipc_name("ipc_test");
6b94ce
 #ifdef DISABLE_IPC_SHM
6b94ce
 	do_shm_tests = QB_FALSE;
6b94ce
 #endif /* DISABLE_IPC_SHM */
6b94ce
-- 
6b94ce
1.8.4.2
6b94ce