socket unit tests: improve basic tests a bit

This commit is contained in:
goldsimon 2017-11-17 21:22:00 +01:00
parent fa73f130f1
commit 2b309bd1ae

View File

@ -109,6 +109,7 @@ static void test_sockets_allfunctions_basic_domain(int domain)
int s, s2, s3, ret;
struct sockaddr_storage addr, addr2;
socklen_t addrlen, addr2len;
char buf[4];
/* listen socket */
s = lwip_socket(domain, SOCK_STREAM, 0);
fail_unless(s >= 0);
@ -151,10 +152,45 @@ static void test_sockets_allfunctions_basic_domain(int domain)
fail_unless(ret == -1);
fail_unless(errno == EISCONN);
ret = lwip_close(s);
/* write from server to client */
ret = write(s3, "test", 4);
fail_unless(ret == 4);
ret = lwip_shutdown(s3, SHUT_WR);
fail_unless(ret == 0);
while(tcpip_thread_poll_one());
ret = lwip_read(s2, buf, 4);
fail_unless(ret == 4);
ret = lwip_read(s2, buf, 1);
fail_unless(ret == 0);
ret = lwip_read(s2, buf, 1);
fail_unless(ret == -1);
ret = lwip_write(s2, "foo", 3);
fail_unless(ret == 3);
ret = lwip_close(s2);
fail_unless(ret == 0);
while(tcpip_thread_poll_one());
ret = lwip_read(s3, buf, 3);
fail_unless(ret == 3);
ret = lwip_read(s3, buf, 1);
fail_unless(ret == 0);
ret = lwip_read(s3, buf, 1);
fail_unless(ret == -1);
while(tcpip_thread_poll_one());
ret = lwip_close(s);
fail_unless(ret == 0);
ret = lwip_close(s3);
fail_unless(ret == 0);
}