aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/unittest/session_test.c12
-rw-r--r--src/plugins/unittest/tcp_test.c29
2 files changed, 29 insertions, 12 deletions
diff --git a/src/plugins/unittest/session_test.c b/src/plugins/unittest/session_test.c
index 0d9da537ef0..00a70b878dc 100644
--- a/src/plugins/unittest/session_test.c
+++ b/src/plugins/unittest/session_test.c
@@ -158,12 +158,14 @@ session_delete_loopback (u32 sw_if_index)
{
/* fails spectacularly */
/* vnet_delete_loopback_interface (sw_if_index); */
+
+ vnet_sw_interface_set_flags (vnet_get_main (), sw_if_index, 0);
}
static int
session_test_basic (vlib_main_t * vm, unformat_input_t * input)
{
- session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
+ session_endpoint_cfg_t server_sep = SESSION_ENDPOINT_CFG_NULL;
u64 options[APP_OPTIONS_N_OPTIONS], bind4_handle, bind6_handle;
u32 server_index;
int error = 0;
@@ -187,8 +189,9 @@ session_test_basic (vlib_main_t * vm, unformat_input_t * input)
server_sep.is_ip4 = 1;
vnet_listen_args_t bind_args = {
- .sep = server_sep,
+ .sep_ext = server_sep,
.app_index = 0,
+ .wrk_map_index = 0,
};
bind_args.app_index = server_index;
@@ -277,7 +280,7 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input)
u32 server_index, client_index, sw_if_index[2], tries = 0;
u64 options[APP_OPTIONS_N_OPTIONS], dummy_secret = 1234;
u16 dummy_server_port = 1234, dummy_client_port = 5678;
- session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
+ session_endpoint_cfg_t server_sep = SESSION_ENDPOINT_CFG_NULL;
ip4_address_t intf_addr[3];
transport_connection_t *tc;
session_t *s;
@@ -344,7 +347,7 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input)
server_sep.is_ip4 = 1;
server_sep.port = dummy_server_port;
vnet_listen_args_t bind_args = {
- .sep = server_sep,
+ .sep_ext = server_sep,
.app_index = server_index,
};
error = vnet_listen (&bind_args);
@@ -1693,6 +1696,7 @@ session_test_proxy (vlib_main_t * vm, unformat_input_t * input)
if (verbose)
unformat_free (&tmp_input);
vec_free (attach_args.name);
+ session_delete_loopback (sw_if_index);
return 0;
}
diff --git a/src/plugins/unittest/tcp_test.c b/src/plugins/unittest/tcp_test.c
index e604884d107..7d0d229f3ca 100644
--- a/src/plugins/unittest/tcp_test.c
+++ b/src/plugins/unittest/tcp_test.c
@@ -786,6 +786,14 @@ tbt_seq_lt (u32 a, u32 b)
return seq_lt (a, b);
}
+static inline int
+approx_equal (u32 a, u32 b)
+{
+ if (b > 0.99 * a && b < 1.01 * a)
+ return 1;
+ return 0;
+}
+
static int
tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
{
@@ -794,7 +802,7 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
tcp_connection_t _tc, *tc = &_tc;
sack_scoreboard_t *sb = &tc->sack_sb;
int __clib_unused verbose = 0, i;
- u64 rate = 100, burst = 100;
+ u64 rate = 1000, burst = 100;
sack_block_t *sacks = 0;
tcp_byte_tracker_t *bt;
rb_node_t *root, *rbn;
@@ -852,7 +860,8 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (rs->ack_time == 1, "ack time should be 1");
TCP_TEST (rs->delivered == burst, "delivered should be 100");
TCP_TEST (rs->sample_delivered == 0, "sample delivered should be 0");
- TCP_TEST (rs->tx_rate == rate, "delivered should be %u", rate);
+ TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
+ rs->tx_rate);
TCP_TEST (!(rs->flags & TCP_BTS_IS_RXT), "not retransmitted");
/* 3) track second burst at time 2 */
@@ -891,7 +900,8 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (rs->ack_time == 2, "ack time should be 2");
TCP_TEST (rs->delivered == 2 * burst, "delivered should be 200");
TCP_TEST (rs->sample_delivered == burst, "delivered should be 100");
- TCP_TEST (rs->tx_rate == rate, "delivered should be %u", rate);
+ TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
+ rs->tx_rate);
TCP_TEST (!(rs->flags & TCP_BTS_IS_RXT), "not retransmitted");
TCP_TEST (!(bts->flags & TCP_BTS_IS_APP_LIMITED), "not app limited");
@@ -958,7 +968,8 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
TCP_TEST (rs->delivered == 30, "delivered should be 30");
TCP_TEST (rs->sample_delivered == 3 * burst,
"sample delivered should be %u", 3 * burst);
- TCP_TEST (rs->tx_rate == rate, "delivered should be %u", rate);
+ TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
+ rs->tx_rate);
TCP_TEST (!(rs->flags & TCP_BTS_IS_RXT), "not retransmitted");
TCP_TEST (!(rs->flags & TCP_BTS_IS_APP_LIMITED), "not app limited");
@@ -1040,7 +1051,8 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
rs->delivered);
TCP_TEST (rs->sample_delivered == 3 * burst + 30,
"sample delivered should be %u", 3 * burst + 30);
- TCP_TEST (rs->tx_rate == rate, "delivered should be %u", rate);
+ TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
+ rs->tx_rate);
TCP_TEST (rs->flags & TCP_BTS_IS_RXT, "is retransmitted");
/* Sample is app limited because of the retransmits */
TCP_TEST (rs->flags & TCP_BTS_IS_APP_LIMITED, "is app limited");
@@ -1059,9 +1071,9 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
tcp_bt_sample_delivery_rate (tc, rs);
TCP_TEST (tcp_bt_is_sane (bt), "tracker should be sane");
- TCP_TEST (pool_elts (bt->samples) == 0, "num samples should be 3 is %u",
+ TCP_TEST (pool_elts (bt->samples) == 0, "num samples should be 0 is %u",
pool_elts (bt->samples));
- TCP_TEST (tc->delivered_time == 11, "delivered time should be 10");
+ TCP_TEST (tc->delivered_time == 11, "delivered time should be 11");
TCP_TEST (tc->delivered == 7 * burst, "delivered should be %u is %u",
7 * burst, tc->delivered);
/* Last rxt was at time 8 */
@@ -1072,7 +1084,8 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input)
rs->delivered);
TCP_TEST (rs->sample_delivered == 3 * burst + 30,
"sample delivered should be %u", 3 * burst + 30);
- TCP_TEST (rs->tx_rate == rate, "delivered should be %u", rate);
+ TCP_TEST (approx_equal (rate, rs->tx_rate), "rate should be %u is %u", rate,
+ rs->tx_rate);
TCP_TEST (rs->flags & TCP_BTS_IS_RXT, "is retransmitted");
TCP_TEST (rs->flags & TCP_BTS_IS_APP_LIMITED, "is app limited");
TCP_TEST (tc->app_limited == 0, "app limited should be cleared");