network

low level network subjects
Log | Files | Refs | Submodules | README | git clone https://git.ne02ptzero.me/git/network

commit e398ccb1a18ae0a01ce8af9b8a7c2e62da328a99
parent a9d59dbd3a70f0b0fa222b26daff10da6b0cf491
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 17 Mar 2017 18:05:36 +0100

Fix(Tests)

Diffstat:
Msrc/client_test.c | 10++++++++--
Msrc/read_package.c | 1-
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/client_test.c b/src/client_test.c @@ -34,14 +34,20 @@ TEST(pkg_auth_1_write) { } TEST(pkg_auth_1_read) { - void *ret; + void *ret, *expect; package_t *pkg; + size_t r_n = 0, size; TEST_ASSERT(sockfd, "Server is not responding"); + expect = pkg_build_auth(&size, 1, 0); ret = malloc(2048); - read(sockfd, ret, 2048); + r_n = read(sockfd, ret, 2048); + + TEST_ASSERT(r_n == size, "Package returned size is wrong"); + TEST_ASSERT(memcmp(ret, expect, size) == 0, "Expected package is wrong"); pkg = read_pkg(ret); TEST_ASSERT(pkg, "Can't read package"); + TEST_ASSERT(pkg->type == PKG_TYPE_AUTH_ACK, "Package type is wrong"); return TEST_SUCCESS; } diff --git a/src/read_package.c b/src/read_package.c @@ -4,7 +4,6 @@ static size_t read_header(package_t *pkg, void *data) { size_t count = 0; read_member(pkg->type); - printf("%d\n", pkg->type); read_member(pkg->size); read_member(pkg->next_pkg_len);