From nobody Mon May 15 10:53:37 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QKbns5rBZz4BTB4; Mon, 15 May 2023 10:53:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QKbns5MBlz429R; Mon, 15 May 2023 10:53:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684148017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a5nwIX9YWcJ+CY0QVqljVjJ7eMWkB3dSOOIdH4YpLhU=; b=hZV/OJgHL2lILC9wVBaOa2BkpT6xjTeutEtp69RZN/nQXQzw7bPz6KX49me+Uo4wBESSs0 WtifEG/HDwEoYJIDeAGwVy7UYaXaKyc7GsaFsvAcyL48zCv43JrXr6rLtF3Y+q2ZLizvf1 t/+Vx0ZpykKBFm99Am4dfNQFGPKL7mGpXD0H5fXzfYjgdScBDrcT/OmxF5oeWhTjmGMRl7 6qP1H8RUxSbX/dL4eARS7Ml7snlS7QM8x6ryOkN2fOjY3F3WWHwlQ0+Jw+BUvVhFOwHmRI W9gVjfDWgn6LgWiX3a/fKsCbIrmJqsY0c6Qrqo1lu+OaZXsGikPPtoklAcFgVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684148017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a5nwIX9YWcJ+CY0QVqljVjJ7eMWkB3dSOOIdH4YpLhU=; b=Ybi3EG9TmC7YH734G/hllxQn4IupEGRcYJlTdD8kmT6t+Q5oT8G3rUIjXkVYfC0z5dMqqX Qm0HqCIKgivUEg3eZ4bKoTIx/+W99wYdxlzKn3J+rUJdLM/QPaQVPh7dmvrsmC9qgKtU/s kLXXmRlrb2ffM3cCSuJlL6QtIM1f7eL4DlFVaYBil0GHTTFZJ9k8dzWRTcYeinSjrplUSB 5es+MLEr8aK5VS4R1Vg53oXZdh6zzbYGExI689CanaL89a/jIPjCXMk+iZVlANTC/ETUof egkyobJHwAHzH+3DgX6FfywZP2+nQQ9Hom4WkWiN96C2iZ2EmaNH1Ty6IbKVWA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684148017; a=rsa-sha256; cv=none; b=QYtbLJ85yfiD7PPfpuMamOnK+w1JobtaR6EDsvVZcSYnMeVNA0eru9kbXi0q1KXfpFiVgO H62DRH6fp4DzbblMaAb/hEM9zrKnxSDJJ6b6rweiHHS/MMNZhm0QocnUGtOcwthK//YkgL EeT8bWsQcxVW62N67Xgjx9PTjy/c+cAItyGgy523J42yCTRNPUbcs8A/Aw7YJG8qEtgQ0B XTD7dQxG0M9/VZok9zs6HPBcAx0DN6FIWQW8SG1IjOfRMftamu/VvYmr6umWPbWA0Ty2AG P2GEytCwUKS2vEYVES3vRzFLXiTo2QpeJDeQJ77yVQzMo1uuXJT8CN85aIEorQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QKbns4SXXzdPY; Mon, 15 May 2023 10:53:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34FArbgP095595; Mon, 15 May 2023 10:53:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34FArb6W095594; Mon, 15 May 2023 10:53:37 GMT (envelope-from git) Date: Mon, 15 May 2023 10:53:37 GMT Message-Id: <202305151053.34FArb6W095594@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: f3065e767def - main - testing: add support for using custom interfaces in pytest framework. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f3065e767def62d9b593dd7528c0eb121a7e1439 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=f3065e767def62d9b593dd7528c0eb121a7e1439 commit f3065e767def62d9b593dd7528c0eb121a7e1439 Author: Alexander V. Chernikov AuthorDate: 2023-05-15 10:44:20 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-05-15 10:44:20 +0000 testing: add support for using custom interfaces in pytest framework. MFC after: 2 weeks --- tests/atf_python/sys/net/vnet.py | 21 +++++++++++++++------ tests/atf_python/sys/netlink/netlink.py | 9 ++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/atf_python/sys/net/vnet.py b/tests/atf_python/sys/net/vnet.py index c0e0a24f6687..a2884b0d7ce2 100644 --- a/tests/atf_python/sys/net/vnet.py +++ b/tests/atf_python/sys/net/vnet.py @@ -151,7 +151,7 @@ class VnetInterface(object): class IfaceFactory(object): INTERFACES_FNAME = "created_ifaces.lst" - AUTODELETE_TYPES = ("epair", "lo", "tap", "tun") + AUTODELETE_TYPES = ("epair", "gif", "gre", "lo", "tap", "tun") def __init__(self): self.file_name = self.INTERFACES_FNAME @@ -386,8 +386,9 @@ class VnetTestTemplate(BaseTest): vnet_factory = VnetFactory(topology_id) for obj_name, obj_data in topo.items(): if obj_name.startswith("if"): - epair_ifaces = iface_factory.create_iface(obj_name, "epair") - smap = SingleInterfaceMap(epair_ifaces, []) + iface_type = obj_data.get("type", "epair") + ifaces = iface_factory.create_iface(obj_name, iface_type) + smap = SingleInterfaceMap(ifaces, []) iface_map[obj_name] = smap for obj_name, obj_data in topo.items(): if obj_name.startswith("vnet"): @@ -494,17 +495,25 @@ class VnetTestTemplate(BaseTest): class SingleVnetTestTemplate(VnetTestTemplate): IPV6_PREFIXES: List[str] = [] IPV4_PREFIXES: List[str] = [] + IFTYPE = "epair" - def setup_method(self, method): + def _setup_default_topology(self): topology = copy.deepcopy( { "vnet1": {"ifaces": ["if1"]}, - "if1": {"prefixes4": [], "prefixes6": []}, + "if1": {"type": self.IFTYPE, "prefixes4": [], "prefixes6": []}, } ) for prefix in self.IPV6_PREFIXES: topology["if1"]["prefixes6"].append((prefix,)) for prefix in self.IPV4_PREFIXES: topology["if1"]["prefixes4"].append((prefix,)) - self.TOPOLOGY = topology + return topology + + def setup_method(self, method): + if not getattr(self, "TOPOLOGY", None): + self.TOPOLOGY = self._setup_default_topology() + else: + names = self.TOPOLOGY.keys() + assert len([n for n in names if n.startswith("vnet")]) == 1 super().setup_method(method) diff --git a/tests/atf_python/sys/netlink/netlink.py b/tests/atf_python/sys/netlink/netlink.py index 4bdefc2d5014..9b5906815489 100644 --- a/tests/atf_python/sys/netlink/netlink.py +++ b/tests/atf_python/sys/netlink/netlink.py @@ -302,7 +302,7 @@ class Nlsock: hdr = Nlmsghdr( nlmsg_type=NlConst.GENL_ID_CTRL, nlmsg_flags=NlmBaseFlags.NLM_F_REQUEST.value, - nlmsg_seq = self.helper.get_seq(), + nlmsg_seq=self.helper.get_seq(), ) ghdr = GenlMsgHdr(cmd=GenlCtrlMsgType.CTRL_CMD_GETFAMILY.value) nla = NlAttrStr(GenlCtrlAttrType.CTRL_ATTR_FAMILY_NAME, family_name) @@ -342,6 +342,13 @@ class Nlsock: self._data = self._data[hdr.nlmsg_len:] return self.parse_message(raw_msg) + def get_reply(self, tx_msg): + self.write_message(tx_msg) + while True: + rx_msg = self.read_message() + if tx_msg.nl_hdr.nlmsg_seq == rx_msg.nl_hdr.nlmsg_seq: + return rx_msg + class NetlinkMultipartIterator(object): def __init__(self, obj, seq_number: int, msg_type):