diff options
Diffstat (limited to 'tests/accel-pppd/pppoe/conftest.py')
-rw-r--r-- | tests/accel-pppd/pppoe/conftest.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/accel-pppd/pppoe/conftest.py b/tests/accel-pppd/pppoe/conftest.py index 8ebaaed3..b3893200 100644 --- a/tests/accel-pppd/pppoe/conftest.py +++ b/tests/accel-pppd/pppoe/conftest.py @@ -1,5 +1,6 @@ -import pytest +import pytest, subprocess, re from common import pppd_process +from packaging.version import Version # pppd executable file name @pytest.fixture() @@ -13,11 +14,21 @@ def pppd(pytestconfig): def pppd_config(): return "" +# determines which plugin is required - pppoe.so (pppd 2.5.0+) or rp-pppoe.so (pppd <2.5.0) +def pppd_plugin_so(pppd): + command = [pppd, "--version"] + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + pppd_version = Version(re.search(r'\d+\.\d+\.\d+', result.stdout + result.stderr).group()) + ref_version = Version("2.5.0") + if pppd_version >= ref_version: + return "pppoe.so" + else: + return "rp-pppoe.so" # pppd configuration as command line args @pytest.fixture() -def pppd_args(pppd_config): - return pppd_config.split() +def pppd_args(pppd_config, pppd): + return ("plugin " + pppd_plugin_so(pppd) + "\n" + pppd_config).split() # setup and teardown for tests that required running pppd (after accel-pppd) |