|
|
6b94ce |
From c6c9a9ed6feb47bd357ce56c00f80cc6985390e1 Mon Sep 17 00:00:00 2001
|
|
|
6b94ce |
From: David Vossel <dvossel@redhat.com>
|
|
|
6b94ce |
Date: Tue, 14 Apr 2015 15:10:28 -0400
|
|
|
6b94ce |
Subject: [PATCH 2/4] Low: tests: regression tests for stress testing loop_poll
|
|
|
6b94ce |
ipc create/destroy
|
|
|
6b94ce |
|
|
|
6b94ce |
---
|
|
|
6b94ce |
tests/check_ipc.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
6b94ce |
1 file changed, 96 insertions(+)
|
|
|
6b94ce |
|
|
|
6b94ce |
diff --git a/tests/check_ipc.c b/tests/check_ipc.c
|
|
|
6b94ce |
index ce9a7c0..79faa16 100644
|
|
|
6b94ce |
--- a/tests/check_ipc.c
|
|
|
6b94ce |
+++ b/tests/check_ipc.c
|
|
|
6b94ce |
@@ -94,6 +94,7 @@ static int32_t disconnect_after_created = QB_FALSE;
|
|
|
6b94ce |
static int32_t num_bulk_events = 10;
|
|
|
6b94ce |
static int32_t num_stress_events = 30000;
|
|
|
6b94ce |
static int32_t reference_count_test = QB_FALSE;
|
|
|
6b94ce |
+static int32_t multiple_connections = QB_FALSE;
|
|
|
6b94ce |
|
|
|
6b94ce |
|
|
|
6b94ce |
static int32_t
|
|
|
6b94ce |
@@ -227,6 +228,7 @@ s1_msg_process_fn(qb_ipcs_connection_t *c,
|
|
|
6b94ce |
} else if (req_pt->id == IPC_MSG_REQ_SERVER_FAIL) {
|
|
|
6b94ce |
exit(0);
|
|
|
6b94ce |
} else if (req_pt->id == IPC_MSG_REQ_SERVER_DISCONNECT) {
|
|
|
6b94ce |
+ multiple_connections = QB_FALSE;
|
|
|
6b94ce |
qb_ipcs_disconnect(c);
|
|
|
6b94ce |
}
|
|
|
6b94ce |
return 0;
|
|
|
6b94ce |
@@ -263,6 +265,9 @@ my_dispatch_del(int32_t fd)
|
|
|
6b94ce |
static int32_t
|
|
|
6b94ce |
s1_connection_closed(qb_ipcs_connection_t *c)
|
|
|
6b94ce |
{
|
|
|
6b94ce |
+ if (multiple_connections) {
|
|
|
6b94ce |
+ return 0;
|
|
|
6b94ce |
+ }
|
|
|
6b94ce |
qb_enter();
|
|
|
6b94ce |
qb_leave();
|
|
|
6b94ce |
return 0;
|
|
|
6b94ce |
@@ -301,6 +306,10 @@ outq_flush (void *data)
|
|
|
6b94ce |
static void
|
|
|
6b94ce |
s1_connection_destroyed(qb_ipcs_connection_t *c)
|
|
|
6b94ce |
{
|
|
|
6b94ce |
+ if (multiple_connections) {
|
|
|
6b94ce |
+ return;
|
|
|
6b94ce |
+ }
|
|
|
6b94ce |
+
|
|
|
6b94ce |
qb_enter();
|
|
|
6b94ce |
if (reference_count_test) {
|
|
|
6b94ce |
struct cs_ipcs_conn_context *cnx;
|
|
|
6b94ce |
@@ -316,6 +325,9 @@ static void
|
|
|
6b94ce |
s1_connection_created(qb_ipcs_connection_t *c)
|
|
|
6b94ce |
{
|
|
|
6b94ce |
uint32_t max = MAX_MSG_SIZE;
|
|
|
6b94ce |
+ if (multiple_connections) {
|
|
|
6b94ce |
+ return;
|
|
|
6b94ce |
+ }
|
|
|
6b94ce |
|
|
|
6b94ce |
if (send_event_on_created) {
|
|
|
6b94ce |
struct qb_ipc_response_header response;
|
|
|
6b94ce |
@@ -934,6 +946,60 @@ count_bulk_events(int32_t fd, int32_t revents, void *data)
|
|
|
6b94ce |
}
|
|
|
6b94ce |
|
|
|
6b94ce |
static void
|
|
|
6b94ce |
+test_ipc_stress_connections(void)
|
|
|
6b94ce |
+{
|
|
|
6b94ce |
+ int32_t c = 0;
|
|
|
6b94ce |
+ int32_t j = 0;
|
|
|
6b94ce |
+ uint32_t max_size = MAX_MSG_SIZE;
|
|
|
6b94ce |
+ int32_t connections = 0;
|
|
|
6b94ce |
+ pid_t pid;
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+ multiple_connections = QB_TRUE;
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+ qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_CLEAR_ALL,
|
|
|
6b94ce |
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
|
|
|
6b94ce |
+ qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
|
|
|
6b94ce |
+ QB_LOG_FILTER_FILE, "*", LOG_INFO);
|
|
|
6b94ce |
+ qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE);
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+ pid = run_function_in_new_process(run_ipc_server);
|
|
|
6b94ce |
+ fail_if(pid == -1);
|
|
|
6b94ce |
+ sleep(1);
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+ for (connections = 1; connections < 70000; connections++) {
|
|
|
6b94ce |
+ if (conn) {
|
|
|
6b94ce |
+ qb_ipcc_disconnect(conn);
|
|
|
6b94ce |
+ conn = NULL;
|
|
|
6b94ce |
+ }
|
|
|
6b94ce |
+ do {
|
|
|
6b94ce |
+ conn = qb_ipcc_connect(ipc_name, max_size);
|
|
|
6b94ce |
+ if (conn == NULL) {
|
|
|
6b94ce |
+ j = waitpid(pid, NULL, WNOHANG);
|
|
|
6b94ce |
+ ck_assert_int_eq(j, 0);
|
|
|
6b94ce |
+ sleep(1);
|
|
|
6b94ce |
+ c++;
|
|
|
6b94ce |
+ }
|
|
|
6b94ce |
+ } while (conn == NULL && c < 5);
|
|
|
6b94ce |
+ fail_if(conn == NULL);
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+ if (((connections+1) % 1000) == 0) {
|
|
|
6b94ce |
+ qb_log(LOG_INFO, "%d ipc connections made", connections+1);
|
|
|
6b94ce |
+ }
|
|
|
6b94ce |
+ }
|
|
|
6b94ce |
+ multiple_connections = QB_FALSE;
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+ request_server_exit();
|
|
|
6b94ce |
+ verify_graceful_stop(pid);
|
|
|
6b94ce |
+ qb_ipcc_disconnect(conn);
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+ qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_CLEAR_ALL,
|
|
|
6b94ce |
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
|
|
|
6b94ce |
+ qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
|
|
|
6b94ce |
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
|
|
|
6b94ce |
+ qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE);
|
|
|
6b94ce |
+}
|
|
|
6b94ce |
+
|
|
|
6b94ce |
+static void
|
|
|
6b94ce |
test_ipc_bulk_events(void)
|
|
|
6b94ce |
{
|
|
|
6b94ce |
int32_t c = 0;
|
|
|
6b94ce |
@@ -1076,6 +1142,16 @@ START_TEST(test_ipc_stress_test_us)
|
|
|
6b94ce |
}
|
|
|
6b94ce |
END_TEST
|
|
|
6b94ce |
|
|
|
6b94ce |
+START_TEST(test_ipc_stress_connections_us)
|
|
|
6b94ce |
+{
|
|
|
6b94ce |
+ qb_enter();
|
|
|
6b94ce |
+ ipc_type = QB_IPC_SOCKET;
|
|
|
6b94ce |
+ ipc_name = __func__;
|
|
|
6b94ce |
+ test_ipc_stress_connections();
|
|
|
6b94ce |
+ qb_leave();
|
|
|
6b94ce |
+}
|
|
|
6b94ce |
+END_TEST
|
|
|
6b94ce |
+
|
|
|
6b94ce |
START_TEST(test_ipc_bulk_events_us)
|
|
|
6b94ce |
{
|
|
|
6b94ce |
qb_enter();
|
|
|
6b94ce |
@@ -1265,6 +1341,16 @@ START_TEST(test_ipc_stress_test_shm)
|
|
|
6b94ce |
}
|
|
|
6b94ce |
END_TEST
|
|
|
6b94ce |
|
|
|
6b94ce |
+START_TEST(test_ipc_stress_connections_shm)
|
|
|
6b94ce |
+{
|
|
|
6b94ce |
+ qb_enter();
|
|
|
6b94ce |
+ ipc_type = QB_IPC_SHM;
|
|
|
6b94ce |
+ ipc_name = __func__;
|
|
|
6b94ce |
+ test_ipc_stress_connections();
|
|
|
6b94ce |
+ qb_leave();
|
|
|
6b94ce |
+}
|
|
|
6b94ce |
+END_TEST
|
|
|
6b94ce |
+
|
|
|
6b94ce |
START_TEST(test_ipc_bulk_events_shm)
|
|
|
6b94ce |
{
|
|
|
6b94ce |
qb_enter();
|
|
|
6b94ce |
@@ -1439,6 +1525,11 @@ make_shm_suite(void)
|
|
|
6b94ce |
tcase_set_timeout(tc, 10);
|
|
|
6b94ce |
suite_add_tcase(s, tc);
|
|
|
6b94ce |
|
|
|
6b94ce |
+ tc = tcase_create("ipc_stress_connections");
|
|
|
6b94ce |
+ tcase_add_test(tc, test_ipc_stress_connections_shm);
|
|
|
6b94ce |
+ tcase_set_timeout(tc, 200);
|
|
|
6b94ce |
+ suite_add_tcase(s, tc);
|
|
|
6b94ce |
+
|
|
|
6b94ce |
return s;
|
|
|
6b94ce |
}
|
|
|
6b94ce |
|
|
|
6b94ce |
@@ -1513,6 +1604,11 @@ make_soc_suite(void)
|
|
|
6b94ce |
tcase_set_timeout(tc, 10);
|
|
|
6b94ce |
suite_add_tcase(s, tc);
|
|
|
6b94ce |
|
|
|
6b94ce |
+ tc = tcase_create("ipc_stress_connections");
|
|
|
6b94ce |
+ tcase_add_test(tc, test_ipc_stress_connections_us);
|
|
|
6b94ce |
+ tcase_set_timeout(tc, 200);
|
|
|
6b94ce |
+ suite_add_tcase(s, tc);
|
|
|
6b94ce |
+
|
|
|
6b94ce |
return s;
|
|
|
6b94ce |
}
|
|
|
6b94ce |
|
|
|
6b94ce |
--
|
|
|
6b94ce |
1.8.4.2
|
|
|
6b94ce |
|