void SocketConnectorAcceptorTest::testSpawnedAcceptor () { #ifdef VPR_OS_Windows long rand_num(rand()); #else long rand_num(random()); #endif mRendevousPort = 47000 + (rand_num % 71); // Get a partially random port mNumItersA = 5; mMessageValue = std::string("The Data"); mMessageLen = mMessageValue.length(); mState = NOT_READY; // Initialize // Spawn acceptor thread vpr::Thread acceptor_thread( boost::bind(&SocketConnectorAcceptorTest::testSpawnedAcceptor_acceptor, this) ); // Spawn connector thread vpr::Thread connector_thread( boost::bind(&SocketConnectorAcceptorTest::testSpawnedAcceptor_connector, this) ); CPPUNIT_ASSERT( acceptor_thread.valid() && "Invalid acceptor thread"); CPPUNIT_ASSERT( connector_thread.valid() && "Invalid connector thread"); if(!acceptor_thread.valid()) std::cerr << "Invalid acceptor thread\n"; if(!connector_thread.valid()) std::cerr << "Invalid connector_thread\n"; // Wait for threads acceptor_thread.join(); connector_thread.join(); }
void SocketBandwidthIOStatsTest::testBandwidth() { #ifdef VPR_OS_Windows long rand_num(rand()); #else long rand_num(random()); #endif mRendevousPort = 47000 + (rand_num % 71); // Get a partially random port mNumItersA = 1; mNumItersB = 5000; mMessageValue = std::vector<vpr::Uint8>(1000, 21); // 10000 bytes of data mMessageLen = mMessageValue.size(); mState = NOT_READY; // Initialize // Spawn acceptor thread vpr::Thread acceptor_thread( boost::bind(&SocketBandwidthIOStatsTest::testBandwidth_acceptor, this) ); // Spawn connector thread vpr::Thread connector_thread( boost::bind(&SocketBandwidthIOStatsTest::testBandwidth_connector, this) ); CPPUNIT_ASSERT( acceptor_thread.valid() && "Invalid acceptor thread"); CPPUNIT_ASSERT( connector_thread.valid() && "Invalid connector thread"); if(!acceptor_thread.valid()) std::cerr << "Invalid acceptor thread\n"; if(!connector_thread.valid()) std::cerr << "Invalid connector_thread\n"; // Wait for threads acceptor_thread.join(); connector_thread.join(); }