test/unittests/ipc/echoserver.cpp
// Spawn a server and hammer it with concurrent requests. See if communication fails somewhere.

Spawn a server and hammer it with concurrent requests. See if communication fails somewhere.
Spawn a server and hammer it with concurrent requests . See if communication fails somewhere .
TEST(NonblockingServer, EchoServer) {
	Log::off();
	all_clients_successful = true;
	server_thread_failed = false;
	unix_socket_path = concat("/tmp/gtest_nonblocking_echoserver.", getpid(), ".socket");
	std::thread server_thread(run_server);
	bool server_is_running = false;
	while (!server_is_running) {
		std::this_thread::sleep_for(std::chrono::milliseconds(5));
		if (server_thread_failed) {
			ADD_FAILURE() << "Problem when initializing or running the server";
			server_thread.join();
			return;
		}
		server_initialization_mutex.lock();
		if (server != nullptr)
			server_is_running = true;
		server_initialization_mutex.unlock();
	}
	std::thread client_threads[NUM_CLIENTS];
	for (int i=0;i<NUM_CLIENTS;i++)
		client_threads[i] = std::thread(run_client, i);
	for (int i=0;i<NUM_CLIENTS;i++)
		client_threads[i].join();
	server->stop();
	server_thread.join();
	unlink(unix_socket_path.c_str());
	EXPECT_EQ(true, all_clients_successful);
}
TEST ( NonblockingServer , EchoServer ) { Log :: off ( ) ; all_clients_successful = true ; server_thread_failed = false ; unix_socket_path = concat ( " " , getpid ( ) , " " ) ; std :: thread server_thread ( run_server ) ; bool server_is_running = false ; while ( ! server_is_running ) { std :: this_thread :: sleep_for ( std :: chrono :: milliseconds ( 5 ) ) ; if ( server_thread_failed ) { ADD_FAILURE ( ) << " " ; server_thread . join ( ) ; return ; } server_initialization_mutex . lock ( ) ; if ( server != nullptr ) server_is_running = true ; server_initialization_mutex . unlock ( ) ; } std :: thread client_threads [ NUM_CLIENTS ] ; for ( int i = 0 ; i < NUM_CLIENTS ; i ++ ) client_threads [ i ] = std :: thread ( run_client , i ) ; for ( int i = 0 ; i < NUM_CLIENTS ; i ++ ) client_threads [ i ] . join ( ) ; server -> stop ( ) ; server_thread . join ( ) ; unlink ( unix_socket_path . c_str ( ) ) ; EXPECT_EQ ( true , all_clients_successful ) ; }
Spawn a server and hammer it with concurrent requests.
Spawn a server and hammer it with concurrent requests .
// wait for the listening socket to exist
 // run all clients
 // wait until all clients are done
 // stop the server
