Implement (un)register_observer for TCP/UDP

This commit is contained in:
Ruihan Li
2024-01-08 23:35:29 +08:00
committed by Tate, Hongliang Tian
parent 29ebf8e60c
commit 8628543067
8 changed files with 82 additions and 108 deletions

View File

@ -3,6 +3,7 @@
#include <unistd.h>
#include <sys/signal.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -170,3 +171,22 @@ FN_TEST(accept)
TEST_ERRNO(accept(sk_connected, psaddr, &addrlen), EOPNOTSUPP);
}
END_TEST()
FN_TEST(poll)
{
struct pollfd pfd = { .events = POLLIN | POLLOUT };
pfd.fd = sk_unbound;
// FIXME: Uncomment this
// TEST_RES(poll(&pfd, 1, 0),
// (pfd.revents & (POLLIN | POLLOUT)) == POLLOUT);
pfd.fd = sk_bound;
TEST_RES(poll(&pfd, 1, 0),
(pfd.revents & (POLLIN | POLLOUT)) == POLLOUT);
pfd.fd = sk_connected;
TEST_RES(poll(&pfd, 1, 0),
(pfd.revents & (POLLIN | POLLOUT)) == POLLOUT);
}
END_TEST()