Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions libkirk/ltp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)

Expand Down Expand Up @@ -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]:
Expand Down
28 changes: 28 additions & 0 deletions libkirk/tests/test_ltp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI This is not needed, it's a default.

net_vars["LTP_RSH"] = "ssh -nq"
Copy link
Member

@pevik pevik Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also the default. Having the definition on 2 places only ask for problems if tst_net.sh changes it, it will be overwritten in kirk.
Instead of definition of these two which is not needed it'd be great to evaluate what user sets and support 2 host setup (if user defines it).


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.
Expand Down
Loading