net: encapsulate fdwatch backend metadata
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user