diff --git a/libkirk/ltp.py b/libkirk/ltp.py index a4c85de..626e219 100644 --- a/libkirk/ltp.py +++ b/libkirk/ltp.py @@ -69,12 +69,52 @@ class LTPFramework(Framework): } ) - # Environment variables without the `LTP_` prefix that are still forwarded. + # Environment variables without the `LTP_` or `TST_` prefix that are still forwarded. SUPPORTED_ENV: frozenset = frozenset( { "PATH", "KCONFIG_PATH", "KCONFIG_SKIP_CHECK", + # LTP network test variables + "RHOST", + "RUSER", + "PASSWD", + "IPV4_LHOST", + "IPV4_RHOST", + "IPV6_LHOST", + "IPV6_RHOST", + "LHOST_IFACES", + "RHOST_IFACES", + # Stress test parameters + "NS_DURATION", + "NS_TIMES", + "CONNECTION_TOTAL", + "IP_TOTAL", + "IP_TOTAL_FOR_TCPIP", + "ROUTE_TOTAL", + "ROUTE_CHANGE_IP", + "ROUTE_CHANGE_NETLINK", + "MTU_CHANGE_TIMES", + "IF_UPDOWN_TIMES", + "PING_MAX", + # ICMP / multicast + "NS_ICMPV4_SENDER_DATA_MAXSIZE", + "NS_ICMPV6_SENDER_DATA_MAXSIZE", + "MCASTNUM_NORMAL", + "MCASTNUM_HEAVY", + # File transfer / services + "DOWNLOAD_BIGFILESIZE", + "DOWNLOAD_REGFILESIZE", + "UPLOAD_BIGFILESIZE", + "UPLOAD_REGFILESIZE", + "HTTP_DOWNLOAD_DIR", + "FTP_DOWNLOAD_DIR", + "FTP_UPLOAD_DIR", + "FTP_UPLOAD_URLDIR", + # IPsec / virtual interfaces + "IPSEC_MODE", + "IPSEC_PROTO", + "VIRT_PERF_THRESHOLD", } ) @@ -126,7 +166,7 @@ def _update_env_vars(self, timeout: float) -> None: if key in self._PRESET_ENV: continue - if key in self.SUPPORTED_ENV or key.startswith("LTP_"): + if key in self.SUPPORTED_ENV or key.startswith("LTP_") or key.startswith("TST_"): self._env[key] = val async def _read_path(self, channel: ComChannel) -> Dict[str, str]: diff --git a/libkirk/tests/test_ltp.py b/libkirk/tests/test_ltp.py index 25d4468..9969810 100644 --- a/libkirk/tests/test_ltp.py +++ b/libkirk/tests/test_ltp.py @@ -134,6 +134,34 @@ async def test_find_suite(self, framework, sut, tmpdir): assert "TMPDIR" in test.env assert "LTP_COLORIZE_OUTPUT" in test.env + async def test_find_suite_network_vars(self, sut, monkeypatch): + """ + Test that all SUPPORTED_ENV variables and TST_/LTP_ prefixed variables + are forwarded to tests. + """ + # Build a mapping of every variable that should be forwarded: + # all entries in SUPPORTED_ENV (skipping PATH which is always present) + # plus representative TST_ and LTP_ prefixed variables. + net_vars = { + key: f"test_value_{key}" + for key in LTPFramework.SUPPORTED_ENV + if key != "PATH" + } + # One representative per prefix is enough to verify prefix-based forwarding. + net_vars["TST_USE_NETNS"] = "yes" + net_vars["LTP_RSH"] = "ssh -nq" + + for key, val in net_vars.items(): + monkeypatch.setenv(key, val) + + framework = LTPFramework() + suite = await framework.find_suite(sut, "suite0") + + for test in suite.tests: + for key, val in net_vars.items(): + assert key in test.env, f"{key} not found in test env" + assert test.env[key] == val + async def test_find_suite_max_runtime(self, sut): """ Test find_suite method when max_runtime is defined.