forked from Imagelibrary/rtems
libtests/syscall01: Explicitly request close
This makes the test more reliable in case an interrupt driven console driver is used.
This commit is contained in:
@@ -91,6 +91,9 @@ static void close_task(rtems_task_argument arg)
|
||||
rtems_status_code sc;
|
||||
int rv;
|
||||
|
||||
sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
rv = close(ctx->fd);
|
||||
rtems_test_assert(rv == 0);
|
||||
|
||||
@@ -99,6 +102,14 @@ static void close_task(rtems_task_argument arg)
|
||||
}
|
||||
}
|
||||
|
||||
static void request_close(test_context *ctx)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
sc = rtems_event_transient_send(ctx->close_task);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
}
|
||||
|
||||
static void wait_for_close_task(void)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
@@ -120,6 +131,8 @@ static void test_accept_and_close(test_context *ctx)
|
||||
rv = listen(ctx->fd, 1);
|
||||
rtems_test_assert(rv == 0);
|
||||
|
||||
request_close(ctx);
|
||||
|
||||
errno = 0;
|
||||
fd = accept(ctx->fd, (struct sockaddr *) &addr, &addrlen);
|
||||
rtems_test_assert(fd == -1);
|
||||
@@ -147,6 +160,8 @@ static void test_connect_and_close(test_context *ctx)
|
||||
addr.sin_port = htons(1234);
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
request_close(ctx);
|
||||
|
||||
errno = 0;
|
||||
rv = connect(ctx->fd, (struct sockaddr *) &addr, addrlen);
|
||||
rtems_test_assert(rv == -1);
|
||||
@@ -179,6 +194,8 @@ static void test_recv_and_close(test_context *ctx)
|
||||
rv = bind(ctx->fd, (struct sockaddr *) &addr, addrlen);
|
||||
rtems_test_assert(rv == 0);
|
||||
|
||||
request_close(ctx);
|
||||
|
||||
errno = 0;
|
||||
n = recv(ctx->fd, &buf[0], sizeof(buf), 0);
|
||||
rtems_test_assert(n == -1);
|
||||
@@ -215,6 +232,8 @@ static void test_select_and_close(test_context *ctx)
|
||||
FD_ZERO(&set);
|
||||
FD_SET(ctx->fd, &set);
|
||||
|
||||
request_close(ctx);
|
||||
|
||||
errno = 0;
|
||||
rv = select(nfds, &set, NULL, NULL, NULL);
|
||||
rtems_test_assert(rv == -1);
|
||||
|
||||
Reference in New Issue
Block a user