mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 18:41:59 +08:00
rtemsbsd/syscalls: Remove pipe()
- This call is provided by RTEMS and that is preferred Closes #4518
This commit is contained in:
@@ -1095,156 +1095,6 @@ test_kqueue_user(test_context *ctx)
|
||||
assert(rv == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_pipe_timeout(test_context *ctx)
|
||||
{
|
||||
struct pipe_poll_events
|
||||
{
|
||||
short event;
|
||||
int rv;
|
||||
};
|
||||
const struct pipe_poll_events events[] = {
|
||||
{ POLLIN, 0 },
|
||||
{ POLLPRI, 0 },
|
||||
{ POLLOUT, 1 },
|
||||
{ POLLRDNORM, 0 },
|
||||
{ POLLWRNORM, 1 },
|
||||
{ POLLRDBAND, 0 },
|
||||
{ POLLWRBAND, 0 },
|
||||
{ POLLINIGNEOF, 0 }
|
||||
};
|
||||
|
||||
int timeout = 100;
|
||||
struct pollfd pfd;
|
||||
size_t i;
|
||||
int rv;
|
||||
|
||||
puts("test pipe timeout");
|
||||
|
||||
rv = pipe(ctx->pfd);
|
||||
assert(rv == 0);
|
||||
|
||||
pfd.fd = ctx->pfd[1];
|
||||
|
||||
for (i = 0; i < nitems(events); ++i) {
|
||||
int rv;
|
||||
|
||||
pfd.events = events[i].event;
|
||||
pfd.revents = 0;
|
||||
|
||||
rv = poll(&pfd, 1, timeout);
|
||||
assert(rv == events[i].rv);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_pipe_read(test_context *ctx)
|
||||
{
|
||||
int rfd = ctx->pfd[0];
|
||||
int wfd = ctx->pfd[1];
|
||||
struct pollfd pfd = {
|
||||
.fd = rfd,
|
||||
.events = POLLIN
|
||||
};
|
||||
int timeout = -1;
|
||||
int rv;
|
||||
ssize_t n;
|
||||
|
||||
puts("test pipe read");
|
||||
|
||||
assert(rfd >= 0);
|
||||
assert(wfd >= 0);
|
||||
|
||||
ctx->wfd = wfd;
|
||||
ctx->wbuf = &msg[0];
|
||||
ctx->wn = sizeof(msg);
|
||||
send_events(ctx, EVENT_WRITE);
|
||||
|
||||
set_non_blocking(rfd, 1);
|
||||
|
||||
errno = 0;
|
||||
n = read(rfd, &ctx->buf[0], sizeof(ctx->buf));
|
||||
assert(n == -1);
|
||||
assert(errno == EAGAIN);
|
||||
|
||||
rv = poll(&pfd, 1, timeout);
|
||||
assert(rv == 1);
|
||||
assert(pfd.revents == POLLIN);
|
||||
|
||||
n = read(rfd, &ctx->buf[0], sizeof(ctx->buf));
|
||||
assert(n == (ssize_t) sizeof(msg));
|
||||
assert(memcmp(&msg[0], &ctx->buf[0], sizeof(msg)) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_pipe_write(test_context *ctx)
|
||||
{
|
||||
int rfd = ctx->pfd[0];
|
||||
int wfd = ctx->pfd[1];
|
||||
struct pollfd pfd = {
|
||||
.fd = wfd,
|
||||
.events = POLLOUT
|
||||
};
|
||||
int timeout = -1;
|
||||
int rv;
|
||||
ssize_t n;
|
||||
|
||||
puts("test pipe write");
|
||||
|
||||
assert(rfd >= 0);
|
||||
assert(wfd >= 0);
|
||||
|
||||
ctx->rfd = rfd;
|
||||
ctx->rbuf = &ctx->buf[0];
|
||||
ctx->rn = sizeof(ctx->buf);
|
||||
send_events(ctx, EVENT_READ);
|
||||
|
||||
set_non_blocking(wfd, 1);
|
||||
|
||||
do {
|
||||
errno = 0;
|
||||
n = write(wfd, &ctx->buf[0], sizeof(ctx->buf));
|
||||
if (n == -1) {
|
||||
assert(errno == EAGAIN);
|
||||
}
|
||||
} while (n > 0);
|
||||
|
||||
rv = poll(&pfd, 1, timeout);
|
||||
assert(rv == 1);
|
||||
assert(pfd.revents == POLLOUT);
|
||||
}
|
||||
|
||||
static void
|
||||
test_pipe_close(test_context *ctx)
|
||||
{
|
||||
int rfd = ctx->pfd[0];
|
||||
struct pollfd pfd = {
|
||||
.fd = rfd,
|
||||
.events = POLLIN
|
||||
};
|
||||
int timeout = -1;
|
||||
int rv;
|
||||
|
||||
puts("test pipe close");
|
||||
|
||||
assert(ctx->pfd[0] >= 0);
|
||||
assert(ctx->pfd[1] >= 0);
|
||||
|
||||
send_events(ctx, EVENT_CLOSE_PIPE);
|
||||
|
||||
set_non_blocking(rfd, 0);
|
||||
|
||||
assert(ctx->pfd[0] >= 0);
|
||||
assert(ctx->pfd[1] >= 0);
|
||||
|
||||
rv = poll(&pfd, 1, timeout);
|
||||
assert(rv == 1);
|
||||
assert(pfd.revents == (POLLIN | POLLHUP));
|
||||
|
||||
assert(ctx->pfd[0] == -1);
|
||||
assert(ctx->pfd[1] == -1);
|
||||
}
|
||||
|
||||
static void
|
||||
test_main(void)
|
||||
{
|
||||
@@ -1279,11 +1129,6 @@ test_main(void)
|
||||
test_kqueue_close(ctx);
|
||||
test_kqueue_user(ctx);
|
||||
|
||||
test_pipe_timeout(ctx);
|
||||
test_pipe_read(ctx);
|
||||
test_pipe_write(ctx);
|
||||
test_pipe_close(ctx);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user