Fixed unit tests (compiler errors/warnings, coding style)

This commit is contained in:
sg 2015-08-03 20:41:49 +02:00
parent 145efb1a33
commit 767d0d9046
4 changed files with 21 additions and 13 deletions

View File

@ -61,9 +61,10 @@ static void malloc_keep_x(int x, int num, int size, int freestep)
{
int i;
void* p[16];
LWIP_ASSERT("invalid size", size >= 0 && size < (mem_size_t)-1);
memset(p, 0, sizeof(p));
for(i = 0; i < num && i < 16; i++) {
p[i] = mem_malloc(size);
p[i] = mem_malloc((mem_size_t)size);
fail_unless(p[i] != NULL);
}
for(i = 0; i < num && i < 16; i += freestep) {

View File

@ -93,12 +93,15 @@ START_TEST(test_pbuf_queueing_bigger_than_64k)
struct pbuf *p1, *p2, *p3, *rest2=NULL, *rest3=NULL;
LWIP_UNUSED_ARG(_i);
for(i = 0; i < TESTBUFSIZE_1; i++)
testbuf_1[i] = rand();
for(i = 0; i < TESTBUFSIZE_2; i++)
testbuf_2[i] = rand();
for(i = 0; i < TESTBUFSIZE_3; i++)
testbuf_3[i] = rand();
for(i = 0; i < TESTBUFSIZE_1; i++) {
testbuf_1[i] = (u8_t)rand();
}
for(i = 0; i < TESTBUFSIZE_2; i++) {
testbuf_2[i] = (u8_t)rand();
}
for(i = 0; i < TESTBUFSIZE_3; i++) {
testbuf_3[i] = (u8_t)rand();
}
p1 = pbuf_alloc(PBUF_RAW, TESTBUFSIZE_1, PBUF_POOL);
fail_unless(p1 != NULL);
@ -151,6 +154,7 @@ START_TEST(test_pbuf_take_at_edge)
u8_t testdata[] = { 0x01, 0x08, 0x82, 0x02 };
struct pbuf *p = pbuf_alloc(PBUF_RAW, 1024, PBUF_POOL);
struct pbuf *q = p->next;
LWIP_UNUSED_ARG(_i);
/* alloc big enough to get a chain of pbufs */
fail_if(p->tot_len == p->len);
memset(p->payload, 0, p->len);
@ -201,6 +205,7 @@ START_TEST(test_pbuf_get_put_at_edge)
u8_t getdata;
struct pbuf *p = pbuf_alloc(PBUF_RAW, 1024, PBUF_POOL);
struct pbuf *q = p->next;
LWIP_UNUSED_ARG(_i);
/* alloc big enough to get a chain of pbufs */
fail_if(p->tot_len == p->len);
memset(p->payload, 0, p->len);

View File

@ -136,10 +136,11 @@ static void tick_lwip(void)
}
}
static void send_pkt(struct netif *netif, const u8_t *data, u32_t len)
static void send_pkt(struct netif *netif, const u8_t *data, size_t len)
{
struct pbuf *p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
struct pbuf *q;
struct pbuf *p, *q;
LWIP_ASSERT("pkt too big", len <= 0xFFFF);
p = pbuf_alloc(PBUF_RAW, (u16_t)len, PBUF_POOL);
if (debug) {
/* Dump data */
@ -879,7 +880,7 @@ START_TEST(test_dhcp_nak_no_endmarker)
memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */
send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));
fail_unless(net_test.dhcp->state == DHCP_REQUESTING);
fail_unless(net_test.dhcp->state == DHCP_STATE_REQUESTING);
fail_unless(txpacket == 2); /* No more sent */
xid = htonl(net_test.dhcp->xid); /* xid updated */
@ -887,7 +888,7 @@ START_TEST(test_dhcp_nak_no_endmarker)
send_pkt(&net_test, dhcp_nack_no_endmarker, sizeof(dhcp_nack_no_endmarker));
/* NAK should put us in another state for a while, no other way detecting it */
fail_unless(net_test.dhcp->state != DHCP_REQUESTING);
fail_unless(net_test.dhcp->state != DHCP_STATE_REQUESTING);
netif_remove(&net_test);
}

View File

@ -47,6 +47,7 @@ tcp_create_segment_wnd(ip_addr_t* src_ip, ip_addr_t* dst_ip,
struct ip_hdr* iphdr;
struct tcp_hdr* tcphdr;
u16_t pbuf_len = (u16_t)(sizeof(struct ip_hdr) + sizeof(struct tcp_hdr) + data_len);
LWIP_ASSERT("data_len too big", data_len <= 0xFFFF);
p = pbuf_alloc(PBUF_RAW, pbuf_len, PBUF_POOL);
EXPECT_RETNULL(p != NULL);
@ -86,7 +87,7 @@ tcp_create_segment_wnd(ip_addr_t* src_ip, ip_addr_t* dst_ip,
/* let p point to TCP data */
pbuf_header(p, -(s16_t)sizeof(struct tcp_hdr));
/* copy data */
pbuf_take(p, data, data_len);
pbuf_take(p, data, (u16_t)data_len);
/* let p point to TCP header again */
pbuf_header(p, sizeof(struct tcp_hdr));
}