Skip to content

Commit

Permalink
[infra] Enforce core_dump_and_config_check run order
Browse files Browse the repository at this point in the history
Let's enforce `core_dump_and_config_check` run order:
1. runs before any other module level fixtures in setup.
2. runs after any other module level fixtures in teardown.

Signed-off-by: Longxiang Lyu <[email protected]>
  • Loading branch information
lolyu committed Jan 10, 2025
1 parent 5f66027 commit 0efece8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,7 @@ def pfc_pause_delay_test_params(request):

_frontend_hosts_per_hwsku_per_module = {}
_hosts_per_hwsku_per_module = {}
@pytest.hookimpl(wrapper=True)
def pytest_generate_tests(metafunc): # noqa E302
# The topology always has atleast 1 dut
dut_fixture_name = None
Expand Down Expand Up @@ -1786,6 +1787,26 @@ def format_portautoneg_test_id(param):
else:
metafunc.parametrize('vlan_name', ['no_vlan'], scope='module')

# HACK: ensure fixture core_dump_and_config_check runs before any
# other module level fixtures in setup to collect configurations
# without modification from test fixtures.
for fixturedef in metafunc._arg2fixturedefs.values():
fixturedef = fixturedef[0]
if fixturedef.argname == "core_dump_and_config_check":
metafunc.fixturenames.remove(fixturedef.argname)
metafunc.fixturenames.insert(0, fixturedef.argname)

yield

# HACK: ensure fixture core_dump_and_config_check runs after any
# other module level fixtures in teardown, so other fixtures could
# restore the configruation before running core_dump_and_config_check.
for fixturedef in metafunc._arg2fixturedefs.values():
fixturedef = fixturedef[0]
if fixturedef.argname == "core_dump_and_config_check":
metafunc.fixturenames.remove(fixturedef.argname)
metafunc.fixturenames.append(fixturedef.argname)


def get_autoneg_tests_data():
folder = 'metadata'
Expand Down

0 comments on commit 0efece8

Please sign in to comment.