atf_python: allow test scripts to pass jail options

Test scripts based on atf_python can now pass jail command options via the
'opts' key in the 'vnetX' key of TOPOLOGY.

Reviewed by:	melifaro
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D52761
This commit is contained in:
Kristof Provost
2025-09-27 16:38:19 +02:00
parent 5e4e12ae64
commit 2213e15888
+8 -4
View File
@@ -283,14 +283,15 @@ def _wait_interfaces(vnet_name: str, ifaces: List[str]) -> List[str]:
time.sleep(0.1)
return not_matched
def create_vnet(self, vnet_alias: str, ifaces: List[VnetInterface]):
def create_vnet(self, vnet_alias: str, ifaces: List[VnetInterface], opts: List[str]):
vnet_name = "pytest:{}".format(convert_test_name(self.topology_id))
if self._vnets:
# add number to distinguish jails
vnet_name = "{}_{}".format(vnet_name, len(self._vnets) + 1)
iface_cmds = " ".join(["vnet.interface={}".format(i.name) for i in ifaces])
cmd = "/usr/sbin/jail -i -c name={} persist vnet {}".format(
vnet_name, iface_cmds
opt_cmds = " ".join(["{}".format(i) for i in opts])
cmd = "/usr/sbin/jail -i -c name={} persist vnet {} {}".format(
vnet_name, iface_cmds, opt_cmds
)
jid = 0
try:
@@ -421,7 +422,10 @@ def setup_topology(self, topo: Dict, topology_id: str):
idx = len(iface_map[iface_alias].vnet_aliases)
iface_map[iface_alias].vnet_aliases.append(obj_name)
vnet_ifaces.append(iface_map[iface_alias].ifaces[idx])
vnet = vnet_factory.create_vnet(obj_name, vnet_ifaces)
opts = []
if "opts" in obj_data:
opts = obj_data["opts"]
vnet = vnet_factory.create_vnet(obj_name, vnet_ifaces, opts)
vnet_map[obj_name] = vnet
# Allow reference to VNETs as attributes
setattr(self, obj_name, vnet)