From 896f068b71bd1e38654eff24817e4381623f4e25 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 10 Nov 2017 11:53:07 +0100 Subject: 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(-) (limited to 'testsuite') diff --git a/testsuite/syscalls01/test_main.c b/testsuite/syscalls01/test_main.c index 397e0586..f2af2ac8 100644 --- a/testsuite/syscalls01/test_main.c +++ b/testsuite/syscalls01/test_main.c @@ -53,6 +53,7 @@ #include #include +#include #include #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); } -- cgit v1.2.3