@@ -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 ()
@@ -78,13 +77,24 @@ void test_rc_flow_control::init()
7877 }
7978 test_rc::init ();
8079
80+ ucs_assert (rc_iface (m_e1)->config .fc_enabled );
81+ ucs_assert (rc_iface (m_e2)->config .fc_enabled );
82+
8183 uct_iface_set_am_handler (m_e1->iface (), FLUSH_AM_ID, am_handler,
8284 NULL , UCT_CB_FLAG_SYNC);
8385 uct_iface_set_am_handler (m_e2->iface (), FLUSH_AM_ID, am_handler,
8486 NULL , UCT_CB_FLAG_SYNC);
8587
8688}
8789
90+ void test_rc_flow_control::cleanup ()
91+ {
92+ /* Restore FC state to enabled, so iface cleanup will destroy the grant mpool */
93+ rc_iface (m_e1)->config .fc_enabled = 1 ;
94+ rc_iface (m_e2)->config .fc_enabled = 1 ;
95+ test_rc::cleanup ();
96+ }
97+
8898void test_rc_flow_control::send_am_and_flush (entity *e, int num_msg)
8999{
90100 m_am_rx_count = 0 ;
@@ -147,24 +157,48 @@ void test_rc_flow_control::test_pending_grant(int wnd)
147157 send_am_messages (m_e1, 1 , UCS_OK);
148158}
149159
160+ void test_rc_flow_control::test_flush_fc_disabled ()
161+ {
162+ set_fc_disabled (m_e1);
163+ ucs_status_t status;
164+
165+ /* If FC is disabled, wnd=0 should not prevent the flush */
166+ get_fc_ptr (m_e1)->fc_wnd = 0 ;
167+ status = uct_ep_flush (m_e1->ep (0 ), 0 , NULL );
168+ EXPECT_EQ (UCS_OK, status);
169+
170+ /* send active message should be OK */
171+ get_fc_ptr (m_e1)->fc_wnd = 1 ;
172+ status = uct_ep_am_short (m_e1->ep (0 ), 0 , 0 , NULL , 0 );
173+ EXPECT_EQ (UCS_OK, status);
174+ EXPECT_EQ (0 , get_fc_ptr (m_e1)->fc_wnd );
175+
176+ /* flush must have resources */
177+ status = uct_ep_flush (m_e1->ep (0 ), 0 , NULL );
178+ EXPECT_FALSE (UCS_STATUS_IS_ERR (status)) << ucs_status_string (status);
179+ }
180+
150181void test_rc_flow_control::test_pending_purge (int wnd, int num_pend_sends)
151182{
152- uct_pending_req_t reqs[num_pend_sends];
183+ pending_send_request_t reqs[num_pend_sends];
153184
154185 disable_entity (m_e2);
155186 set_fc_attributes (m_e1, true , wnd, wnd, 1 );
156187
157- m_req_count = 0 ;
158188 send_am_and_flush (m_e1, wnd);
159189
160190 /* Now m2 ep should have FC grant message in the pending queue.
161191 * 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);
192+ for (int i = 0 ; i < num_pend_sends; i++) {
193+ reqs[i].uct .func = NULL ; /* make valgrind happy */
194+ reqs[i].purge_count = 0 ;
195+ EXPECT_EQ (uct_ep_pending_add (m_e2->ep (0 ), &reqs[i].uct ), UCS_OK);
165196 }
166197 uct_ep_pending_purge (m_e2->ep (0 ), purge_cb, NULL );
167- EXPECT_EQ (num_pend_sends, m_req_count);
198+
199+ for (int i = 0 ; i < num_pend_sends; i++) {
200+ EXPECT_EQ (1 , reqs[i].purge_count );
201+ }
168202}
169203
170204
@@ -206,6 +240,11 @@ UCS_TEST_P(test_rc_flow_control, pending_grant)
206240 test_pending_grant (5 );
207241}
208242
243+ UCS_TEST_P (test_rc_flow_control, fc_disabled_flush)
244+ {
245+ test_flush_fc_disabled ();
246+ }
247+
209248UCT_RC_INSTANTIATE_TEST_CASE (test_rc_flow_control)
210249
211250
0 commit comments