| 1839 | } |
| 1840 | |
| 1841 | void TestAuthentication(bool single_server, |
| 1842 | bool async, bool short_connection) { |
| 1843 | std::cout << " *** single=" << single_server |
| 1844 | << " async=" << async |
| 1845 | << " short=" << short_connection << std::endl; |
| 1846 | |
| 1847 | ASSERT_EQ(0, StartAccept(_ep)); |
| 1848 | MyAuthenticator auth; |
| 1849 | brpc::Channel channel; |
| 1850 | SetUpChannel(&channel, single_server, short_connection, &auth); |
| 1851 | |
| 1852 | const int NUM = 10; |
| 1853 | pthread_t tids[NUM]; |
| 1854 | for (int i = 0; i < NUM; ++i) { |
| 1855 | google::protobuf::Closure* thrd_func = |
| 1856 | brpc::NewCallback( |
| 1857 | this, &ChannelTest::RPCThread, (brpc::ChannelBase*)&channel, async); |
| 1858 | EXPECT_EQ(0, pthread_create(&tids[i], NULL, |
| 1859 | RunClosure, thrd_func)); |
| 1860 | } |
| 1861 | for (int i = 0; i < NUM; ++i) { |
| 1862 | pthread_join(tids[i], NULL); |
| 1863 | } |
| 1864 | |
| 1865 | if (short_connection) { |
| 1866 | EXPECT_EQ(NUM, auth.count.load()); |
| 1867 | } else { |
| 1868 | EXPECT_EQ(1, auth.count.load()); |
| 1869 | } |
| 1870 | StopAndJoin(); |
| 1871 | } |
| 1872 | |
| 1873 | void TestAuthenticationParallel(bool single_server, |
| 1874 | bool async, bool short_connection) { |
nothing calls this directly
no test coverage detected