mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-17 05:36:46 +08:00
Another fix to window scaling: support queueing more than 64 KByte in ooseq data
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
#if LWIP_DNS
|
||||
#error "This test needs DNS turned off (as it mallocs on init)"
|
||||
#endif
|
||||
#if !LWIP_TCP || !TCP_QUEUE_OOSEQ || !LWIP_WND_SCALE
|
||||
#error "This test needs TCP OOSEQ queueing and window scaling enabled"
|
||||
#endif
|
||||
|
||||
/* Setups/teardown functions */
|
||||
|
||||
@@ -23,6 +26,16 @@ pbuf_teardown(void)
|
||||
}
|
||||
|
||||
|
||||
#define TESTBUFSIZE_1 65535
|
||||
#define TESTBUFSIZE_2 65530
|
||||
#define TESTBUFSIZE_3 50050
|
||||
static u8_t testbuf_1[TESTBUFSIZE_1];
|
||||
static u8_t testbuf_1a[TESTBUFSIZE_1];
|
||||
static u8_t testbuf_2[TESTBUFSIZE_2];
|
||||
static u8_t testbuf_2a[TESTBUFSIZE_2];
|
||||
static u8_t testbuf_3[TESTBUFSIZE_3];
|
||||
static u8_t testbuf_3a[TESTBUFSIZE_3];
|
||||
|
||||
/* Test functions */
|
||||
|
||||
/** Call pbuf_copy on a pbuf with zero length */
|
||||
@@ -61,13 +74,79 @@ START_TEST(test_pbuf_copy_zero_pbuf)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_pbuf_split_64k_on_small_pbufs)
|
||||
{
|
||||
struct pbuf *p, *rest=NULL;
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, 1, PBUF_POOL);
|
||||
pbuf_split_64k(p, &rest);
|
||||
fail_unless(p->tot_len == 1);
|
||||
pbuf_free(p);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_pbuf_queueing_bigger_than_64k)
|
||||
{
|
||||
int i;
|
||||
err_t err;
|
||||
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();
|
||||
|
||||
p1 = pbuf_alloc(PBUF_RAW, TESTBUFSIZE_1, PBUF_POOL);
|
||||
fail_unless(p1 != NULL);
|
||||
p2 = pbuf_alloc(PBUF_RAW, TESTBUFSIZE_2, PBUF_POOL);
|
||||
fail_unless(p2 != NULL);
|
||||
p3 = pbuf_alloc(PBUF_RAW, TESTBUFSIZE_3, PBUF_POOL);
|
||||
fail_unless(p3 != NULL);
|
||||
err = pbuf_take(p1, testbuf_1, TESTBUFSIZE_1);
|
||||
fail_unless(err == ERR_OK);
|
||||
err = pbuf_take(p2, testbuf_2, TESTBUFSIZE_2);
|
||||
fail_unless(err == ERR_OK);
|
||||
err = pbuf_take(p3, testbuf_3, TESTBUFSIZE_3);
|
||||
fail_unless(err == ERR_OK);
|
||||
|
||||
pbuf_cat(p1, p2);
|
||||
pbuf_cat(p1, p3);
|
||||
|
||||
pbuf_split_64k(p1, &rest2);
|
||||
fail_unless(p1->tot_len == TESTBUFSIZE_1);
|
||||
fail_unless(rest2->tot_len == (u16_t)((TESTBUFSIZE_2+TESTBUFSIZE_3) & 0xFFFF));
|
||||
pbuf_split_64k(rest2, &rest3);
|
||||
fail_unless(rest2->tot_len == TESTBUFSIZE_2);
|
||||
fail_unless(rest3->tot_len == TESTBUFSIZE_3);
|
||||
|
||||
pbuf_copy_partial(p1, testbuf_1a, TESTBUFSIZE_1, 0);
|
||||
pbuf_copy_partial(rest2, testbuf_2a, TESTBUFSIZE_2, 0);
|
||||
pbuf_copy_partial(rest3, testbuf_3a, TESTBUFSIZE_3, 0);
|
||||
for(i = 0; i < TESTBUFSIZE_1; i++)
|
||||
fail_unless(testbuf_1[i] == testbuf_1a[i]);
|
||||
for(i = 0; i < TESTBUFSIZE_2; i++)
|
||||
fail_unless(testbuf_2[i] == testbuf_2a[i]);
|
||||
for(i = 0; i < TESTBUFSIZE_3; i++)
|
||||
fail_unless(testbuf_3[i] == testbuf_3a[i]);
|
||||
|
||||
pbuf_free(p1);
|
||||
pbuf_free(rest2);
|
||||
pbuf_free(rest3);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/** Create the suite including all tests for this module */
|
||||
Suite *
|
||||
pbuf_suite(void)
|
||||
{
|
||||
TFun tests[] = {
|
||||
test_pbuf_copy_zero_pbuf
|
||||
test_pbuf_copy_zero_pbuf,
|
||||
test_pbuf_split_64k_on_small_pbufs,
|
||||
test_pbuf_queueing_bigger_than_64k
|
||||
};
|
||||
return create_suite("PBUF", tests, sizeof(tests)/sizeof(TFun), pbuf_setup, pbuf_teardown);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
#define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
|
||||
#define TCP_SND_BUF (12 * TCP_MSS)
|
||||
#define TCP_WND (10 * TCP_MSS)
|
||||
#define LWIP_WND_SCALE 1
|
||||
#define TCP_RCV_SCALE 0
|
||||
#define PBUF_POOL_SIZE 400 // pbuf tests need ~200KByte
|
||||
|
||||
/* Minimal changes to opt.h required for etharp unit tests: */
|
||||
#define ETHARP_SUPPORT_STATIC_ENTRIES 1
|
||||
|
||||
Reference in New Issue
Block a user