[rtems-libbsd commit] tests/syscalls01: Fix shutdown() test

Sebastian Huber sebh at rtems.org
Fri Nov 10 12:00:20 UTC 2017


Module:    rtems-libbsd
Branch:    master
Commit:    896f068b71bd1e38654eff24817e4381623f4e25
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=896f068b71bd1e38654eff24817e4381623f4e25

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Nov 10 11:53:07 2017 +0100

tests/syscalls01: Fix shutdown() test

The socket must be connected for a shutdown().

---

 testsuite/syscalls01/test_main.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/testsuite/syscalls01/test_main.c b/testsuite/syscalls01/test_main.c
index 397e058..f2af2ac 100644
--- a/testsuite/syscalls01/test_main.c
+++ b/testsuite/syscalls01/test_main.c
@@ -53,6 +53,7 @@
 #include <syslog.h>
 
 #include <rtems.h>
+#include <rtems/bsd/bsd.h>
 #include <rtems/libcsupport.h>
 
 #define TEST_NAME "LIBBSD SYSCALLS 1"
@@ -422,6 +423,7 @@ test_socket_fstat_and_shutdown(void)
 	mode_t canrecv = S_IRUSR | S_IRGRP | S_IROTH;
 	mode_t cansend = S_IWUSR | S_IWGRP | S_IWOTH;
 	rtems_resource_snapshot snapshot;
+	struct sockaddr_in addr;
 	struct stat st;
 	int sd;
 	int rv;
@@ -430,6 +432,8 @@ test_socket_fstat_and_shutdown(void)
 
 	rtems_resource_snapshot_take(&snapshot);
 
+	init_addr(&addr);
+
 	sd = socket(PF_INET, SOCK_DGRAM, 0);
 	assert(sd >= 0);
 
@@ -439,6 +443,9 @@ test_socket_fstat_and_shutdown(void)
 	assert(rv == 0);
 	assert(st.st_mode == (S_IFSOCK | canrecv | cansend));
 
+	rv = connect(sd, (struct sockaddr *) &addr, sizeof(addr));
+	assert(rv == 0);
+
 	rv = shutdown(sd, SHUT_RD);
 	assert(rv == 0);
 
@@ -464,6 +471,9 @@ test_socket_fstat_and_shutdown(void)
 	sd = socket(PF_INET, SOCK_DGRAM, 0);
 	assert(sd >= 0);
 
+	rv = connect(sd, (struct sockaddr *) &addr, sizeof(addr));
+	assert(rv == 0);
+
 	do_no_mem_test(no_mem_socket_shutdown, sd);
 
 	rv = close(sd);
@@ -1592,11 +1602,11 @@ test_setgethostname(void)
 static void
 test_main(void)
 {
+
 	/* Must be first test to ensure resource checks work */
 	test_sockets();
 
 	test_socket_unsupported_ops();
-	test_socket_fstat_and_shutdown();
 	test_socket_ioctl();
 	test_socket_bind();
 	test_socket_connect();
@@ -1619,6 +1629,9 @@ test_main(void)
 	test_syslog();
 	test_setgethostname();
 
+	rtems_bsd_ifconfig_lo0();
+	test_socket_fstat_and_shutdown();
+
 	exit(0);
 }
 



More information about the vc mailing list