From patchwork Wed Apr 24 22:14:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13642558 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB42D1607A2; Wed, 24 Apr 2024 22:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996891; cv=none; b=BVrd4whN7efM+3p5rxLtqFQkcHv98G2G14/JqS+t9pXeAILf6dgJ9iFaYQz979sToquzJu0xPNE1ChjU8uz+znamntiE2L/iXwaSeGktsORuJvYv7PlUSAu1+dTTgWZgDZHUCXSkyC6TtesR3Nw4wtBSWtGbMWdnaX1HTiKAssg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996891; c=relaxed/simple; bh=d133gvW+7UN3UO7wVGaiUVGARPF1yuYlLI+me49dJRw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yrc7rMTO4YLLmCluOUI2jvf9SP88jvcqc+xE3IOkecCH4gho9ciNN7V7z2j7ied8YAwWAOvxydoChwduXkPslRBZyWHKrOh6gaMfkd/HOZhBVVnnc4Ck59ZxhsXg4Y1/YaLJkPgoVIqhN0lFor01mbZ6p31TSukElUzAfVtgfM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XStIbT7A; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XStIbT7A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13380C2BD11; Wed, 24 Apr 2024 22:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713996891; bh=d133gvW+7UN3UO7wVGaiUVGARPF1yuYlLI+me49dJRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XStIbT7AVplOlW2HjbSHqNweFrj1bwHaXq6MFdQZzpbPlV0nRw7iWPdo9c+S9DOXe AhTroAT6J8Ne6IOTvADR0zGzKBCX0cu1l8XXywMRw6eWooiXaya88UW8TD3swpRSML dTtXuSOtYyCCpKcOB1BcXnQbszZR4sFP9KK9TRfj2yckHVgm8ToVZW95T2KNvmMU3l n0/JHXkm5WeAyHR43/olCP2oOQPXnyYdAKHR+wiaTBT8KGODB6Y6T7+qVFCgG+9177 srXh633I/XZbnElc7LwXyvNQ7xmSOdZqi17OukreEaeR/3gECHqC2GQIFNSI/+NIk9 mX+urfg+zERqA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, willemdebruijn.kernel@gmail.com, Jakub Kicinski Subject: [PATCH net-next 1/4] selftests: drv-net: force pseudo-terminal allocation in ssh Date: Wed, 24 Apr 2024 15:14:41 -0700 Message-ID: <20240424221444.4194069-2-kuba@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240424221444.4194069-1-kuba@kernel.org> References: <20240424221444.4194069-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This is not yet needed, because we don't terminate remote background commands. But once we do, if we run ssh without -t the ssh session may close and the program may carry on happily running. I have hit this problem experimenting with mausezahn, let's fix it already to avoid someone else wasting time debugging it. Signed-off-by: Jakub Kicinski --- tools/testing/selftests/drivers/net/lib/py/remote_ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/lib/py/remote_ssh.py b/tools/testing/selftests/drivers/net/lib/py/remote_ssh.py index 924addde19a3..294a4ed8284e 100644 --- a/tools/testing/selftests/drivers/net/lib/py/remote_ssh.py +++ b/tools/testing/selftests/drivers/net/lib/py/remote_ssh.py @@ -20,7 +20,7 @@ from lib.py import cmd self._tmpdir = None def cmd(self, comm): - return subprocess.Popen(["ssh", "-q", self.name, comm], + return subprocess.Popen(["ssh", "-t", "-q", self.name, comm], stdout=subprocess.PIPE, stderr=subprocess.PIPE) def _mktmp(self): From patchwork Wed Apr 24 22:14:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13642559 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06912165FB3; Wed, 24 Apr 2024 22:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996892; cv=none; b=McAPZwFVHlTbkj9NuA5m8I8ey7z0tER8DEzvRm123Yjr++bXzywtz9emVh/sCUPizbk2FIbIlAziW2lGvEZn86vSAJ0kNoJ2N4cUxIUNbv6MFuNfCbIVuFXTlAq4f6JI+140ndolz7Swcn4tMCPjJ1IjUysSf1qHQSBwc0My2AI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996892; c=relaxed/simple; bh=mLF7JiYV3aL5gRVzXWPg4mgGT5YCnXvtblk/EeSsU2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h/ctaDyWUrjxhVAqPdniXryDMBtqczAQXSKnOGZxMAXp5Xrq6yLH/tshFboT8cZQLFrHfK85FECo2uRe6WFCvJi4q9wDHJbNyvodaXz2HVPWgQYSciDC4ZCQKFU4ZwtibH1kvmWkBk5Kr7pJXlIWYxDkkLPiRSx7YwyNcPh9ZSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GUK/rBrT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GUK/rBrT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ED7BC113CE; Wed, 24 Apr 2024 22:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713996891; bh=mLF7JiYV3aL5gRVzXWPg4mgGT5YCnXvtblk/EeSsU2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GUK/rBrTA0SlRvjCJLNmlKSsxjI5Al8WXWOjCgQndqY0ICe6+QpbO0nmxKC38h3O8 inesWIm5+i+xR+/TfaGC9xjLYaSUgPFCF/p0IH8xAaQ8XkoMTP4G5NFMyav2DY2wXW 84BnufNmI4sFpIq8cSdCbPlAjcoqiNSrQvvD0ai7YQVbd8OHmsOIeemvEXKVKjSNdE Q0YjN3/HfBUmQCgAEJb/5QGD0WiN/qUHfx6E+pSD5+vN13EqOZT8pb6GMjCF1iv5yN AQucUBrkmE5izdmAPTOQUemoaMch6rKnLfLUy9Q/5X2SFA8gXkruyIPNp2syOdeOtT 8dkweKLc54bJA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, willemdebruijn.kernel@gmail.com, Jakub Kicinski Subject: [PATCH net-next 2/4] selftests: drv-net: extend the README with more info and example Date: Wed, 24 Apr 2024 15:14:42 -0700 Message-ID: <20240424221444.4194069-3-kuba@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240424221444.4194069-1-kuba@kernel.org> References: <20240424221444.4194069-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add more info to the README. It's also now copied to GitHub for increased visibility: https://github.com/linux-netdev/nipa/wiki/Running-driver-tests Signed-off-by: Jakub Kicinski --- .../testing/selftests/drivers/net/README.rst | 97 ++++++++++++++++--- 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/drivers/net/README.rst b/tools/testing/selftests/drivers/net/README.rst index 0cbab33dad1f..3b6a29e6564b 100644 --- a/tools/testing/selftests/drivers/net/README.rst +++ b/tools/testing/selftests/drivers/net/README.rst @@ -1,18 +1,42 @@ -Running tests -============= +.. SPDX-License-Identifier: GPL-2.0 -Tests are executed within kselftest framework like any other tests. -By default tests execute against software drivers such as netdevsim. -All tests must support running against a real device (SW-only tests -should instead be placed in net/ or drivers/net/netdevsim, HW-only -tests in drivers/net/hw). +Running driver tests +==================== -Set appropriate variables to point the tests at a real device. +Networking driver tests are executed within kselftest framework like any +other tests. They support testing both real device drivers and emulated / +software drivers (latter mostly to test the core parts of the stack). + +SW mode +~~~~~~~ + +By default, when no extra parameters are set or exported, tests execute +against software drivers such as netdevsim. No extra preparation is required +the software devices are created and destroyed as part of the test. +In this mode the tests are indistinguishable from other selftests and +(for example) can be run under ``virtme-ng`` like the core networking selftests. + +HW mode +~~~~~~~ + +Executing tests against a real device requires external preparation. +The netdevice against which tests will be run must exist, be running +(in UP state) and be configured with an IP address. + +Refer to list of :ref:`Variables` later in this file to set up running +the tests against a real device. + +Both modes required +~~~~~~~~~~~~~~~~~~~ + +All tests in drivers/net must support running both against a software device +and a real device. SW-only tests should instead be placed in net/ or +drivers/net/netdevsim, HW-only tests in drivers/net/hw. Variables ========= -Variables can be set in the environment or by creating a net.config +The variables can be set in the environment or by creating a net.config file in the same directory as this README file. Example:: $ NETIF=eth0 ./some_test.sh @@ -23,9 +47,9 @@ Variables can be set in the environment or by creating a net.config # Variable set in a file NETIF=eth0 -Please note that the config parser is very simple, if there are -any non-alphanumeric characters in the value it needs to be in -double quotes. +Local test (which don't require endpoint for sending / receiving traffic) +need only the ``NETIF`` variable. Remaining variables define the endpoint +and communication method. NETIF ~~~~~ @@ -61,3 +85,52 @@ Arguments used to construct the communication channel. for netns - name of the "remote" namespace for ssh - name/address of the remote host + +Example +======= + +Build the selftests:: + + # make -C tools/testing/selftests/ TARGETS="drivers/net drivers/net/hw" + +"Install" the tests and copy them over to the target machine:: + + # make -C tools/testing/selftests/ TARGETS="drivers/net drivers/net/hw" \ + install INSTALL_PATH=/tmp/ksft-net-drv + + # rsync -ra --delete /tmp/ksft-net-drv root@192.168.1.1:/root/ + +On the target machine, running the tests will use netdevsim by default:: + + [/root] # ./ksft-net-drv/run_kselftest.sh -t drivers/net:ping.py + TAP version 13 + 1..1 + # timeout set to 45 + # selftests: drivers/net: ping.py + # KTAP version 1 + # 1..3 + # ok 1 ping.test_v4 + # ok 2 ping.test_v6 + # ok 3 ping.test_tcp + # # Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0 + ok 1 selftests: drivers/net: ping.py + +Create a config with remote info:: + + [/root] # cat > ./ksft-net-drv/drivers/net/net.config < X-Patchwork-Id: 13642560 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86CAC16D32A; Wed, 24 Apr 2024 22:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996892; cv=none; b=uN6U07zdKGxI/PYajtxOd5EhyST9IG/4oJ8kkU/u2qDxKfhLV/ZGfYYyKAIvnm+KwwwtXS7M1h/KHNIItEy5RgI7VEX4faADmHYt6UdFT+UIAJ2E2S9iM64Qj6JGi54oKGSfDvmaEgpGCP3YoYVDUJh8oWhh1Aqdu37qUOuurFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996892; c=relaxed/simple; bh=fhHMUm9DEAJsvgFZ3Tc+NqLDyywCnTct5uhYXaxImII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qloceMJ/AilGvrfmNR1o+CLsy8/AV6DgSgZa+K/f//7gbCTGTk5/yc8WK51juln7UWfH2WdO++vwEjM3PX2Jjg8IesIKesoxCIejJfYnYvCOtPqwza2l1tw7qin1YbJEtSF4qrmOGAjA/vNe2EYRQYBitYZdWx4cXIwtlCQUN9w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qq74QV7Q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qq74QV7Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDF6BC32782; Wed, 24 Apr 2024 22:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713996892; bh=fhHMUm9DEAJsvgFZ3Tc+NqLDyywCnTct5uhYXaxImII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qq74QV7QaA+P7VH6kTfIQVYF0WNg3MLBBNunDrv18CAfhcATu+w/PzKJj59gtCuqn 8mJyJvafW2jK0HENKiuFseRHejBYYll3J23E8nj5GGQZRRibbqkLM9vPAn2Jv1N+so xaV7AoSQCrjbJ9co1o0J5+blYS54N/7v1MGjdD5t0AA+BW5ccR0LnHukKMclEqa1QZ 0y32U3G5YcyZec7/Z3MUMCrP/kX0vV1z85SnrXfCDO6S/FVHYLd+PLMQSp4N9Ck99F U6K0HCLM+YR8xR5jRZZ2PQh3Muqr6XbJjUPcMTEwdqxT+kCbUxqRGT0HHErqYgRkMv i1M+VRMpsx8GA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, willemdebruijn.kernel@gmail.com, Jakub Kicinski Subject: [PATCH net-next 3/4] selftests: drv-net: reimplement the config parser Date: Wed, 24 Apr 2024 15:14:43 -0700 Message-ID: <20240424221444.4194069-4-kuba@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240424221444.4194069-1-kuba@kernel.org> References: <20240424221444.4194069-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The shell lexer is not helping much, do very basic parsing manually. Signed-off-by: Jakub Kicinski --- .../selftests/drivers/net/lib/py/env.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py index a3db1bb1afeb..a6a5a5f9c6db 100644 --- a/tools/testing/selftests/drivers/net/lib/py/env.py +++ b/tools/testing/selftests/drivers/net/lib/py/env.py @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 import os -import shlex from pathlib import Path from lib.py import KsftSkipEx from lib.py import cmd, ip @@ -16,17 +15,20 @@ from .remote import Remote if not (src_dir / "net.config").exists(): return env - lexer = shlex.shlex(open((src_dir / "net.config").as_posix(), 'r').read()) - k = None - for token in lexer: - if k is None: - k = token - env[k] = "" - elif token == "=": - pass - else: - env[k] = token - k = None + with open((src_dir / "net.config").as_posix(), 'r') as fp: + for line in fp.readlines(): + full_file = line + # Strip comments + pos = line.find("#") + if pos >= 0: + line = line[:pos] + line = line.strip() + if not line: + continue + pos = line.find("=") + if pos <= 0: + raise Exception("Can't parse configuration line:", full_file) + env[line[:pos]] = line[pos+1:] return env From patchwork Wed Apr 24 22:14:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13642561 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9730716D33A; Wed, 24 Apr 2024 22:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996892; cv=none; b=dLds/XdUtPexruKawYjEcuN/jCx7PrnbVbiJBOMY09uoLZW1XcrD/IZgeYrYFfs2Brr0u0wv7O4XJYKoUozhy7WwwcF5Nz0HkHd6MitemdRd7p7/g31Swxeq3ANDrILesqImcR2Q1TsZxtsxX8/6x6CHd4lm25ssuT3tEPMi43U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713996892; c=relaxed/simple; bh=Gt09BVyguHHicNRP+AvdpMng623ntjFEP5+/KWehRuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZUatWPUhtZOrcToZO7kewUpIhcxBG+zOmiOv87fRQoBI+HrlKTPwyResiHffQdi4/Q4VbU35n9SEY06EcavU4POarvhlPCgtLaCHEMAwN2QHvK//kroGvGwZZP+PyFIE1cSyj2DGHGyisiZl4mPusRcCDqlia+rFq1azT9TU0qE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZE9CTOJC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZE9CTOJC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AB4EC113CD; Wed, 24 Apr 2024 22:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713996892; bh=Gt09BVyguHHicNRP+AvdpMng623ntjFEP5+/KWehRuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZE9CTOJCpnvjynAgGIuZNq9o0VNLPoDQylrgP4TDW808ojSCBiJmZWlVar6BA0SmF /SctLwApHgWXUe+PGL/JvcjwKfVeAPi1F7+W5wBQttglbmjekfdJ0QcZ5CVgqvIHx1 xG2bfNmrnctZSldZ17tu4pKks6S4mwVOMKDZHFR3NyIpUQnBpRHw9KyeiWQTF8kXJe Xqlvc/tQmMTR+jsg3qHWnnBrW6sV7kOU2Rxxhlp2BUB+CLxJCB6pe1DFA2Au0rittY xoernGQBOTloczQrqBSMAYVION7JlEdVcv2oARMg1Zmn8W3jKUcZTE7GNl7JEtQ6r1 mTT62Pe8zTKkA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, willemdebruijn.kernel@gmail.com, Jakub Kicinski Subject: [PATCH net-next 4/4] selftests: drv-net: validate the environment Date: Wed, 24 Apr 2024 15:14:44 -0700 Message-ID: <20240424221444.4194069-5-kuba@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240424221444.4194069-1-kuba@kernel.org> References: <20240424221444.4194069-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Throw a slightly more helpful exception when env variables are partially populated. Prior to this change we'd get a dictionary key exception somewhere later on. Signed-off-by: Jakub Kicinski --- .../selftests/drivers/net/lib/py/env.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py index a6a5a5f9c6db..fda4967503de 100644 --- a/tools/testing/selftests/drivers/net/lib/py/env.py +++ b/tools/testing/selftests/drivers/net/lib/py/env.py @@ -88,6 +88,7 @@ from .remote import Remote self._ns_peer = None if "NETIF" in self.env: + self._check_env() self.dev = ip("link show dev " + self.env['NETIF'], json=True)[0] self.v4 = self.env.get("LOCAL_V4") @@ -143,6 +144,25 @@ from .remote import Remote ip(f"-6 addr add dev {self._ns_peer.nsims[0].ifname} {self.nsim_v6_pfx}2/64 nodad", ns=self._netns) ip(f" link set dev {self._ns_peer.nsims[0].ifname} up", ns=self._netns) + def _check_env(self): + vars_needed = [ + ["LOCAL_V4", "LOCAL_V6"], + ["REMOTE_V4", "REMOTE_V6"], + ["REMOTE_TYPE"], + ["REMOTE_ARGS"] + ] + missing = [] + + for choice in vars_needed: + for entry in choice: + if entry in self.env: + break + else: + missing.append(choice) + if missing: + raise Exception("Invalid environment, missing configuration:", missing, + "Please see tools/testing/selftests/drivers/net/README.rst") + def __enter__(self): return self