mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[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:
@@ -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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user