net: convert standalone IsSelectableSocket() to Sock::IsSelectable()

This makes the callers mockable.
This commit is contained in:
Vasil Dimov
2021-04-13 14:29:14 +02:00
parent 5db7d2ca0a
commit b4bac55679
7 changed files with 30 additions and 10 deletions

View File

@@ -48,6 +48,13 @@ class FuzzedSock : public Sock
*/
mutable std::optional<uint8_t> m_peek_data;
/**
* Whether to pretend that the socket is select(2)-able. This is randomly set in the
* constructor. It should remain constant so that repeated calls to `IsSelectable()`
* return the same value.
*/
const bool m_selectable;
public:
explicit FuzzedSock(FuzzedDataProvider& fuzzed_data_provider);
@@ -73,6 +80,8 @@ public:
int GetSockName(sockaddr* name, socklen_t* name_len) const override;
bool IsSelectable() const override;
bool Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred = nullptr) const override;
bool WaitMany(std::chrono::milliseconds timeout, EventsPerSock& events_per_sock) const override;