summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-11-10 11:53:07 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-11-10 11:53:07 +0100
commit896f068b71bd1e38654eff24817e4381623f4e25 (patch)
tree295c233ac5b2b1f11fdae939c293b41e1b9b5019 /testsuite
parentAdd rtems_bsd_ifconfig_lo0() (diff)
downloadrtems-libbsd-896f068b71bd1e38654eff24817e4381623f4e25.tar.bz2
tests/syscalls01: Fix shutdown() test
The socket must be connected for a shutdown().
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/syscalls01/test_main.c15
1 files changed, 14 insertions, 1 deletions
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 <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);
}