[rtems commit] libtests/syscall01: Explicitly request close
Sebastian Huber
sebh at rtems.org
Mon Mar 7 14:25:27 UTC 2016
Module: rtems
Branch: master
Commit: 354064b92a3c8ea199b82dd00c5de33e842ccbe8
Changeset: http://git.rtems.org/rtems/commit/?id=354064b92a3c8ea199b82dd00c5de33e842ccbe8
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Mar 7 15:24:19 2016 +0100
libtests/syscall01: Explicitly request close
This makes the test more reliable in case an interrupt driven console
driver is used.
---
testsuites/libtests/syscall01/init.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/testsuites/libtests/syscall01/init.c b/testsuites/libtests/syscall01/init.c
index ec5e5b2..07f0dc1 100644
--- a/testsuites/libtests/syscall01/init.c
+++ b/testsuites/libtests/syscall01/init.c
@@ -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);
More information about the vc
mailing list