@@ -67,7 +67,6 @@ UCS_TEST_P(test_rc_max_wr, send_limit)
6767UCT_RC_INSTANTIATE_TEST_CASE (test_rc_max_wr)
6868
6969
70- int test_rc_flow_control::m_req_count = 0;
7170uint32_t test_rc_flow_control::m_am_rx_count = 0;
7271
7372void test_rc_flow_control::init ()
@@ -147,24 +146,48 @@ void test_rc_flow_control::test_pending_grant(int wnd)
147146 send_am_messages (m_e1, 1 , UCS_OK);
148147}
149148
149+ void test_rc_flow_control::test_flush_fc_disabled ()
150+ {
151+ set_fc_disabled (m_e1);
152+ ucs_status_t status;
153+
154+ /* If FC is disabled, wnd=0 should not prevent the flush */
155+ get_fc_ptr (m_e1)->fc_wnd = 0 ;
156+ status = uct_ep_flush (m_e1->ep (0 ), 0 , NULL );
157+ EXPECT_EQ (UCS_OK, status);
158+
159+ /* send active message should be OK */
160+ get_fc_ptr (m_e1)->fc_wnd = 1 ;
161+ status = uct_ep_am_short (m_e1->ep (0 ), 0 , 0 , NULL , 0 );
162+ EXPECT_EQ (UCS_OK, status);
163+ EXPECT_EQ (0 , get_fc_ptr (m_e1)->fc_wnd );
164+
165+ /* flush must have resources */
166+ status = uct_ep_flush (m_e1->ep (0 ), 0 , NULL );
167+ EXPECT_FALSE (UCS_STATUS_IS_ERR (status)) << ucs_status_string (status);
168+ }
169+
150170void test_rc_flow_control::test_pending_purge (int wnd, int num_pend_sends)
151171{
152- uct_pending_req_t reqs[num_pend_sends];
172+ pending_send_request_t reqs[num_pend_sends];
153173
154174 disable_entity (m_e2);
155175 set_fc_attributes (m_e1, true , wnd, wnd, 1 );
156176
157- m_req_count = 0 ;
158177 send_am_and_flush (m_e1, wnd);
159178
160179 /* Now m2 ep should have FC grant message in the pending queue.
161180 * Add some user pending requests as well */
162- for (int i = 0 ; i < num_pend_sends; i ++) {
163- reqs[i].func = NULL ; /* make valgrind happy */
164- EXPECT_EQ (uct_ep_pending_add (m_e2->ep (0 ), &reqs[i]), UCS_OK);
181+ for (int i = 0 ; i < num_pend_sends; i++) {
182+ reqs[i].uct .func = NULL ; /* make valgrind happy */
183+ reqs[i].purge_count = 0 ;
184+ EXPECT_EQ (uct_ep_pending_add (m_e2->ep (0 ), &reqs[i].uct ), UCS_OK);
165185 }
166186 uct_ep_pending_purge (m_e2->ep (0 ), purge_cb, NULL );
167- EXPECT_EQ (num_pend_sends, m_req_count);
187+
188+ for (int i = 0 ; i < num_pend_sends; i++) {
189+ EXPECT_EQ (1 , reqs[i].purge_count );
190+ }
168191}
169192
170193
@@ -206,6 +229,11 @@ UCS_TEST_P(test_rc_flow_control, pending_grant)
206229 test_pending_grant (5 );
207230}
208231
232+ UCS_TEST_P (test_rc_flow_control, fc_disabled_flush)
233+ {
234+ test_flush_fc_disabled ();
235+ }
236+
209237UCT_RC_INSTANTIATE_TEST_CASE (test_rc_flow_control)
210238
211239
0 commit comments