increase timeout and remove sleep

This commit is contained in:
2026-03-18 15:01:17 +03:00
parent 99c99c39c2
commit a1be5be5a1

View File

@@ -33,7 +33,7 @@ TEST(ClientServer, OneClient) {
auto const loop_timeout = 1000_ms;
auto s = createServer<false, true>();
piMinSleep();
auto c = createAndConnectClient<TestClient<false, false>>();
auto c = createAndConnectClient<TestClient<false, false>>();
waitLoop([s]() { return s->clientsCount() > 0; }, loop_timeout);
EXPECT_EQ(1, s->clientsCount());
@@ -103,7 +103,7 @@ int getClientsPings(const PIVector<ClientSendThread *> & clients) {
TEST(ClientServer, ManyClients) {
auto const loop_timeout = 100_ms;
auto const loop_timeout = 1_s;
constexpr int clients_count = 20;
PIVector<ClientSendThread *> clients;
auto s = createServer<false, false, 100_KiB>();
@@ -139,8 +139,9 @@ TEST(ClientServer, ManyClients) {
for (const auto c: clients) {
c->startSend();
}
loop_timeout.sleep();
waitLoop([&clients]() { return getClientsPings(clients) > clients_count * 2; }, loop_timeout);
EXPECT_TRUE(getClientsPings(clients) > clients_count * 2);
waitLoop([s]() { return getServerPongs(s) > clients_count * 2; }, loop_timeout);
EXPECT_TRUE(getServerPongs(s) > clients_count * 2);
piDeleteAllAndClear(clients);
waitLoop([s]() { return s->clientsCount() == 0; }, loop_timeout);
@@ -149,7 +150,7 @@ TEST(ClientServer, ManyClients) {
}
TEST(ClientServer, DynamicClients) {
auto const loop_timeout = 10_ms;
auto const loop_timeout = 3_s;
constexpr int clients_count = 20;
PIVector<ClientSendThread *> clients;
PIMutex clients_mutex;
@@ -199,15 +200,14 @@ TEST(ClientServer, DynamicClients) {
},
130_Hz);
(loop_timeout * clients_count).sleep();
waitLoop([s]() { return s->clientsCount() >= 10; }, loop_timeout);
EXPECT_GE(s->clientsCount(), 10);
deleteThread.stopAndWait();
spawnThread.stopAndWait();
piDeleteAllAndClear(clients);
waitLoop([s]() { return s->clientsCount() == 0; }, loop_timeout * clients_count);
waitLoop([s]() { return s->clientsCount() == 0; }, loop_timeout);
EXPECT_EQ(0, s->clientsCount());
delete s;