Skip to content

Commit

Permalink
Merge pull request #1635 from yosefe/topic/test-ud-timer-wait-for-rx
Browse files Browse the repository at this point in the history
TEST/UD: Wait for a packet up to 10 sec.
  • Loading branch information
yosefe authored Jun 28, 2017
2 parents 596c4a1 + 74aac9a commit db81bbe
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/gtest/uct/test_ud_slow_timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class test_ud_slow_timer : public ud_base_test {
{
return UCS_ERR_INVALID_PARAM;
}

void wait_for_rx_sn(unsigned sn)
{
ucs_time_t deadline = ucs_get_time() +
ucs_time_from_sec(10) * ucs::test_time_multiplier();
while ((ucs_get_time() < deadline) && (ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts) < sn)) {
usleep(1000);
}
}
};

int test_ud_slow_timer::rx_limit = 10;
Expand All @@ -69,7 +78,7 @@ UCS_TEST_P(test_ud_slow_timer, txn) {
for (i = 0; i < N; i++) {
EXPECT_UCS_OK(tx(m_e1));
}
twait(200);
wait_for_rx_sn(N);
EXPECT_EQ(N+1, ep(m_e1)->tx.psn);
EXPECT_EQ(N, ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts));
}
Expand Down Expand Up @@ -105,7 +114,7 @@ UCS_TEST_P(test_ud_slow_timer, retransmit1) {
ep(m_e2)->rx.rx_hook = uct_ud_ep_null_hook;
EXPECT_EQ(2, ep(m_e1)->tx.psn);
EXPECT_EQ(0, ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts));
twait(500);
wait_for_rx_sn(1);
EXPECT_EQ(2, ep(m_e1)->tx.psn);
EXPECT_EQ(1, ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts));
}
Expand All @@ -125,9 +134,7 @@ UCS_TEST_P(test_ud_slow_timer, retransmitn) {
ep(m_e2)->rx.rx_hook = uct_ud_ep_null_hook;
EXPECT_EQ(N+1, ep(m_e1)->tx.psn);
EXPECT_EQ(0, ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts));
twait(500*ucs::test_time_multiplier());
//short_progress_loop();

wait_for_rx_sn(N);
EXPECT_EQ(N+1, ep(m_e1)->tx.psn);
EXPECT_EQ(N, ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts));
}
Expand Down Expand Up @@ -160,9 +167,7 @@ UCS_TEST_P(test_ud_slow_timer, partial_drop) {
short_progress_loop();

EXPECT_EQ(N+1, ep(m_e1)->tx.psn);
while (ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts) < N) {
progress();
}
wait_for_rx_sn(N);
EXPECT_EQ(N, ucs_frag_list_sn(&ep(m_e2)->rx.ooo_pkts));
}
#endif
Expand Down

0 comments on commit db81bbe

Please sign in to comment.