[ntcore] Match standard handle layout, only allow 16 instances (#3577)

Now that there are only 16 instances, store them all statically.

Make tests more reliable by using different ports for each connection in listener tests.
This commit is contained in:
Peter Johnson
2021-09-17 12:11:00 -07:00
committed by GitHub
parent 263a248119
commit 161e211734
7 changed files with 44 additions and 75 deletions

View File

@@ -22,17 +22,16 @@ class ConnectionListenerTest : public ::testing::Test {
nt::DestroyInstance(client_inst);
}
void Connect();
void Connect(unsigned int port);
protected:
NT_Inst server_inst;
NT_Inst client_inst;
};
void ConnectionListenerTest::Connect() {
nt::StartServer(server_inst, "connectionlistenertest.ini", "127.0.0.1",
10000);
nt::StartClient(client_inst, "127.0.0.1", 10000);
void ConnectionListenerTest::Connect(unsigned int port) {
nt::StartServer(server_inst, "connectionlistenertest.ini", "127.0.0.1", port);
nt::StartClient(client_inst, "127.0.0.1", port);
// wait for client to report it's started, then wait another 0.1 sec
while ((nt::GetNetworkMode(client_inst) & NT_NET_MODE_STARTING) != 0) {
@@ -50,7 +49,7 @@ TEST_F(ConnectionListenerTest, Polled) {
ASSERT_NE(handle, 0u);
// trigger a connect event
Connect();
Connect(10000);
// get the event
ASSERT_TRUE(nt::WaitForConnectionListenerQueue(server_inst, 1.0));
@@ -85,7 +84,7 @@ TEST_F(ConnectionListenerTest, Threaded) {
false);
// trigger a connect event
Connect();
Connect(10001);
ASSERT_TRUE(nt::WaitForConnectionListenerQueue(server_inst, 1.0));

View File

@@ -35,16 +35,16 @@ class EntryListenerTest : public ::testing::Test {
nt::DestroyInstance(client_inst);
}
void Connect();
void Connect(unsigned int port);
protected:
NT_Inst server_inst;
NT_Inst client_inst;
};
void EntryListenerTest::Connect() {
nt::StartServer(server_inst, "entrylistenertest.ini", "127.0.0.1", 10000);
nt::StartClient(client_inst, "127.0.0.1", 10000);
void EntryListenerTest::Connect(unsigned int port) {
nt::StartServer(server_inst, "entrylistenertest.ini", "127.0.0.1", port);
nt::StartClient(client_inst, "127.0.0.1", port);
// Use connection listener to ensure we've connected
NT_ConnectionListenerPoller poller =
@@ -81,7 +81,7 @@ TEST_F(EntryListenerTest, EntryNewLocal) {
}
TEST_F(EntryListenerTest, DISABLED_EntryNewRemote) {
Connect();
Connect(10010);
if (HasFatalFailure()) {
return;
}
@@ -135,7 +135,7 @@ TEST_F(EntryListenerTest, PrefixNewLocal) {
}
TEST_F(EntryListenerTest, DISABLED_PrefixNewRemote) {
Connect();
Connect(10011);
if (HasFatalFailure()) {
return;
}