mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-14 00:59:17 +08:00
tests/syscalls01: Fix shutdown() test
The socket must be connected for a shutdown().
This commit is contained in:
parent
23cd284af0
commit
896f068b71
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user