summaryrefslogtreecommitdiffstats
path: root/src/plugins/unittest/tcp_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/unittest/tcp_test.c')
-rw-r--r--src/plugins/unittest/tcp_test.c29
1 files changed, 21 insertions, 8 deletions
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");