Skip to content

Commit 7662ed3

Browse files
committed
refactored pfc.py
1 parent e568baa commit 7662ed3

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

tests/pfc/files/configs/pfc.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def calculate_priority_vector(v) :
4242
print(i)
4343
return "%x"%(s)
4444

45+
def lossless_iteration_list (lst) :
46+
retval = [[x] for x in lst]
47+
if (len(lst) > 1):
48+
retval.append(lst)
49+
return retval
50+
4551
def base_configs(conn_graph_facts,
4652
duthost,
4753
lossless_prio_dscp_map,
@@ -352,17 +358,18 @@ def lossy_configs(conn_graph_facts,
352358
frame_size,
353359
serializer) :
354360

355-
return(base_configs(conn_graph_facts=conn_graph_facts,
356-
duthost=duthost,
357-
lossless_prio_dscp_map=lossless_prio_dscp_map,
358-
one_hundred_gbe=one_hundred_gbe,
359-
traffic_duration=traffic_duration,
360-
start_delay=start_delay,
361-
pause_line_rate=pause_line_rate,
362-
traffic_line_rate=traffic_line_rate,
363-
pause_frame_type='priority',
364-
frame_size=frame_size,
365-
serializer=serializer))
361+
for p in lossless_iteration_list(lossless_prio_dscp_map) :
362+
yield (base_configs(conn_graph_facts=conn_graph_facts,
363+
duthost=duthost,
364+
lossless_prio_dscp_map = p,
365+
one_hundred_gbe=one_hundred_gbe,
366+
traffic_duration=traffic_duration,
367+
start_delay=start_delay,
368+
pause_line_rate=pause_line_rate,
369+
traffic_line_rate=traffic_line_rate,
370+
pause_frame_type='priority',
371+
frame_size=frame_size,
372+
serializer=serializer))
366373

367374

368375
@pytest.fixture
@@ -377,15 +384,16 @@ def global_pause(conn_graph_facts,
377384
frame_size,
378385
serializer) :
379386

380-
return(base_configs(conn_graph_facts=conn_graph_facts,
381-
duthost=duthost,
382-
lossless_prio_dscp_map=lossless_prio_dscp_map,
383-
one_hundred_gbe=one_hundred_gbe,
384-
traffic_duration=traffic_duration,
385-
start_delay=start_delay,
386-
pause_line_rate=pause_line_rate,
387-
traffic_line_rate=traffic_line_rate,
388-
pause_frame_type='global',
389-
frame_size=frame_size,
390-
serializer=serializer))
387+
for p in lossless_iteration_list(lossless_prio_dscp_map) :
388+
yield (base_configs(conn_graph_facts=conn_graph_facts,
389+
duthost=duthost,
390+
lossless_prio_dscp_map=p,
391+
one_hundred_gbe=one_hundred_gbe,
392+
traffic_duration=traffic_duration,
393+
start_delay=start_delay,
394+
pause_line_rate=pause_line_rate,
395+
traffic_line_rate=traffic_line_rate,
396+
pause_frame_type='global',
397+
frame_size=frame_size,
398+
serializer=serializer))
391399

0 commit comments

Comments
 (0)