net: encapsulate fdwatch backend metadata
Some checks failed
build / Linux asan (push) Has been cancelled
build / Linux release (push) Has been cancelled
build / FreeBSD build (push) Has been cancelled

This commit is contained in:
server
2026-04-14 07:03:44 +02:00
parent abed660256
commit 4f1e7b0e9c
5 changed files with 700 additions and 478 deletions

View File

@@ -1,3 +1,4 @@
#include <algorithm>
#include <array>
#include <cstdint>
#include <cstring>
@@ -289,6 +290,24 @@ void TestFdwatchReadAndOneshotWrite()
close(sockets[0]);
close(sockets[1]);
}
void TestFdwatchBackendMetadata()
{
LPFDWATCH fdw = fdwatch_new(4096);
Expect(fdw != nullptr, "fdwatch_new for backend metadata failed");
#ifdef __USE_SELECT__
Expect(fdwatch_get_backend(fdw) == FDWATCH_BACKEND_SELECT, "Expected select backend");
Expect(std::strcmp(fdwatch_backend_name(fdwatch_get_backend(fdw)), "select") == 0, "Unexpected select backend name");
Expect(fdwatch_get_descriptor_limit(fdw) == std::min(4096, static_cast<int>(FD_SETSIZE)), "Unexpected select descriptor limit");
#else
Expect(fdwatch_get_backend(fdw) == FDWATCH_BACKEND_KQUEUE, "Expected kqueue backend");
Expect(std::strcmp(fdwatch_backend_name(fdwatch_get_backend(fdw)), "kqueue") == 0, "Unexpected kqueue backend name");
Expect(fdwatch_get_descriptor_limit(fdw) == 4096, "Unexpected kqueue descriptor limit");
#endif
fdwatch_delete(fdw);
}
}
int main()
@@ -298,6 +317,7 @@ int main()
TestPacketLayouts();
TestSecureCipherRoundTrip();
TestSocketAuthWireFlow();
TestFdwatchBackendMetadata();
TestFdwatchReadAndOneshotWrite();
std::cout << "metin smoke tests passed\n";
return 0;