@@ -193,7 +193,8 @@ class test_ucp_net_devices_config : public ucp_test {
193193 }
194194
195195 /* Test that a device config triggers duplicate device warning */
196- void test_duplicate_device_warning (const std::string &devices_config,
196+ void test_duplicate_device_warning (const std::string &required_dev_name,
197+ const std::string &devices_config,
197198 const std::string &duplicate_dev_name)
198199 {
199200 entity *e = create_entity ();
@@ -203,8 +204,8 @@ class test_ucp_net_devices_config : public ucp_test {
203204 UCS_TEST_SKIP_R (" No mlx5 network device available" );
204205 }
205206
206- if (!has_device (mlx5_devices, duplicate_dev_name )) {
207- UCS_TEST_SKIP_R (duplicate_dev_name + " device not available" );
207+ if (!has_device (mlx5_devices, required_dev_name )) {
208+ UCS_TEST_SKIP_R (required_dev_name + " device not available" );
208209 }
209210
210211 m_entities.clear ();
@@ -221,14 +222,9 @@ class test_ucp_net_devices_config : public ucp_test {
221222 EXPECT_EQ (m_warnings.size () - warn_count, 1 )
222223 << " Expected exactly one warning" ;
223224
224- // print all warnings
225- for (const std::string &warn : m_warnings) {
226- std::cout << warn << std::endl;
227- }
228-
229225 /* Check that a warning about duplicate device was printed */
230226 std::string expected_warn = " device '" + duplicate_dev_name +
231- " ' was selected multiple times" ;
227+ " ' is specified multiple times" ;
232228 bool found_warning = false ;
233229 for (size_t i = warn_count; i < m_warnings.size (); ++i) {
234230 if (m_warnings[i].find (expected_warn) != std::string::npos) {
@@ -311,100 +307,22 @@ UCS_TEST_P(test_ucp_net_devices_config, explicit_port_suffix)
311307 << " Device '" << test_dev_name << " ' should be selected" ;
312308}
313309
314- /*
315- * Test that device name range specification works with base names.
316- * E.g., "mlx5_[0-1]" should match mlx5_0:1 and mlx5_1:1
317- */
318- UCS_TEST_P (test_ucp_net_devices_config, range_with_base_names)
319- {
320- entity *e = create_entity ();
321-
322- std::set<std::string> mlx5_devices = get_mlx5_device_names (*e);
323- if (mlx5_devices.empty ()) {
324- UCS_TEST_SKIP_R (" No mlx5 network device available" );
325- }
326-
327- size_t num_mlx5_devices = mlx5_devices.size ();
328- if (num_mlx5_devices < 2 ) {
329- UCS_TEST_SKIP_R (" Need at least 2 mlx5 devices for range test" );
330- }
331-
332- m_entities.clear ();
333-
334- /* Use a range that should match all mlx devices */
335- modify_config (" NET_DEVICES" , " mlx5_[0-99]" );
336- e = create_entity ();
337-
338- /* Verify that mlx5 devices were selected */
339- std::set<std::string> selected_devices = get_mlx5_device_names (*e);
340- EXPECT_EQ (selected_devices.size (), num_mlx5_devices)
341- << " Expected " << num_mlx5_devices
342- << " mlx5 devices to be selected with range" ;
343- }
344-
345- /*
346- * Test that a range not covering all devices only selects matching devices.
347- * E.g., "mlx5_[1-2]" should match mlx5_1 and mlx5_2, but not mlx5_0.
348- */
349- UCS_TEST_P (test_ucp_net_devices_config, partial_range_selection)
350- {
351- entity *e = create_entity ();
352-
353- std::set<std::string> mlx5_devices = get_mlx5_device_names (*e);
354- if (mlx5_devices.empty ()) {
355- UCS_TEST_SKIP_R (" No mlx5 network device available" );
356- }
357-
358- std::set<std::string> base_names = get_mlx5_base_names (mlx5_devices);
359-
360- if (!has_device (base_names, " mlx5_0" ) ||
361- !has_device (base_names, " mlx5_1" ) ||
362- !has_device (base_names, " mlx5_2" )) {
363- UCS_TEST_SKIP_R (
364- " Need mlx5_0, mlx5_1, and mlx5_2 devices for this test" );
365- }
366-
367- m_entities.clear ();
368-
369- modify_config (" NET_DEVICES" , " mlx5_[1-2]" );
370- e = create_entity ();
371-
372- std::set<std::string> selected_devices = get_mlx5_device_names (*e);
373-
374- std::set<std::string> selected_base_names = get_mlx5_base_names (
375- selected_devices);
376-
377- std::set<std::string> expected_base_names = {" mlx5_1" , " mlx5_2" };
378- EXPECT_EQ (selected_base_names, expected_base_names);
379- }
380-
381310/*
382311 * Test that specifying a device multiple times produces a warning
383312 */
384313UCS_TEST_P (test_ucp_net_devices_config, duplicate_device_warning_simple)
385314{
386- test_duplicate_device_warning (" mlx5_0:1,mlx5_0:1" , " mlx5_0:1" );
315+ test_duplicate_device_warning (" mlx5_0:1" , " mlx5_0:1 ,mlx5_0:1" , " mlx5_0:1" );
387316}
388317
389318UCS_TEST_P (test_ucp_net_devices_config, duplicate_device_warning_base_name)
390319{
391- test_duplicate_device_warning (" mlx5_0:1,mlx5_0 " , " mlx5_0:1" );
320+ test_duplicate_device_warning (" mlx5_0:1" , " mlx5_0:1,mlx5_0 " , " mlx5_0 " );
392321}
393322
394323UCS_TEST_P (test_ucp_net_devices_config, duplicate_device_warning_two_base_name)
395324{
396- test_duplicate_device_warning (" mlx5_0,mlx5_0" , " mlx5_0:1" );
397- }
398-
399- UCS_TEST_P (test_ucp_net_devices_config, duplicate_device_warning_range)
400- {
401- test_duplicate_device_warning (" mlx5_[0-99],mlx5_0" , " mlx5_0:1" );
402- }
403-
404- UCS_TEST_P (test_ucp_net_devices_config, duplicate_device_warning_two_ranges)
405- {
406- test_duplicate_device_warning (" mlx5_[0-1],mlx5_[1-2]" , " mlx5_1:1" );
325+ test_duplicate_device_warning (" mlx5_0:1" , " mlx5_0,mlx5_0" , " mlx5_0" );
407326}
408327
409-
410328UCP_INSTANTIATE_TEST_CASE_TLS (test_ucp_net_devices_config, ib, " ib" )
0 commit comments