From patchwork Fri Aug 2 00:03:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13750937 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 961FC17FE; Fri, 2 Aug 2024 00:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722556993; cv=none; b=rvGtXzGbhsMBz4oBmAGC4KCSexpg7Hxs4epOfCHGl5X9VgZLrsNhK4Bzz+jTVyVQVt/4KWxrmLCHyAJfbuRX6Fi0AP3CqgqQl3qvRisKkvFJWHmPDa51WipaQv3GuynPoORfGLxY8cyvhK7km2ROWY0Cv8OrnaTNrL0TTBjCMUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722556993; c=relaxed/simple; bh=3qQU1VgjbNk7XLc0TFKS0yeKm8lp0WuhwZgPjg6zWdI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iBXv+f+nbJ795/+J9sGqJTT0h7bSJ/NcT+A2C2/d5qrKrwZvLOW8jY0sp493aked7gmb406pGQGUE60HGtN/Vb4oNkwstnmzYI+ROR2owxSJdS9eNd0RHH2cdp/KNFWQ+flwPi8z3jgVZ/9uo14BvcVEmInjnPwyMPGCYOpRv78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-710439ad77dso2796554b3a.2; Thu, 01 Aug 2024 17:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722556990; x=1723161790; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vmKA0jXkGsl8kspNfQ7BmOezp0qmpOf0Ot67lZV8ipU=; b=dN9CWzEOYoYIXinvkefzmaiminQ1yUol2R8twFhuSZGHx0LJx9I6XKHtxLh77eF9da 1Vw2cdZgLL2JfSV7QnfsAV9bkLCdD4BjXbRhvANyqaz1XKuz4xd4d7mqiG1GTE2BYEJu 6QhXV5L9lpXBu6BBhBum7LBMYYNV0HiFYOYhISprUuomup7COz718P7zZ75Bo5kLuKD7 UNmtGD8UeP/UFRQDUv5K26qHfFCXF+GkKd0cTJaCDbaDfpRgSWe4Bw8HhcL+3ehearzO fmD7a+lzEy1rYymF6XesF8kvDlSskgCGWhFUKaFIH78H4CfDsKqEawN0jUusxZ4G5C3N QW3g== X-Forwarded-Encrypted: i=1; AJvYcCVxhSmeu5oTwtd070PDcMbX06BMs8KKppn2OS3vqmSV42wx0HZoUX4xWOUkB7hm3ej3LirAwed+97yGKGbZs4ZijFe5csFTlWx3cWpFcHwy X-Gm-Message-State: AOJu0YxvyyrRCziFQsx6XUZ1411ctA+LE6YGhfRHflgjv33IORGpj9Lb FjpppnUbLBk9F7XOEsFa93E7ZbL0jFRLCJKez4KzFxp5yXty+5eyuikv5Qc= X-Google-Smtp-Source: AGHT+IGVgXT/hjWZy2PwLKF61YM2KQZlF8k8gY5DTXE8q3zUsdMARtlg1KfLz2NL1J6jp2VaEcqGcg== X-Received: by 2002:a05:6a00:13aa:b0:70d:2b1b:a37f with SMTP id d2e1a72fcca58-7106d02f8c6mr2206305b3a.24.1722556990440; Thu, 01 Aug 2024 17:03:10 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:73b6:7410:eb24:cba4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7106ec00e66sm372073b3a.37.2024.08.01.17.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 17:03:10 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Shuah Khan , Joe Damato , Petr Machata , linux-kselftest@vger.kernel.org Subject: [PATCH net-next v3 1/3] selftests: net-drv: exercise queue stats when the device is down Date: Thu, 1 Aug 2024 17:03:07 -0700 Message-ID: <20240802000309.2368-1-sdf@fomichev.me> X-Mailer: git-send-email 2.45.2 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 Verify that total device stats don't decrease after it has been turned down. Also make sure the device doesn't crash when we access per-queue stats when it's down (in case it tries to access some pointers that are NULL). KTAP version 1 1..5 ok 1 stats.check_pause ok 2 stats.check_fec ok 3 stats.pkt_byte_sum ok 4 stats.qstat_by_ifindex ok 5 stats.check_down # Totals: pass:5 fail:0 xfail:0 xpass:0 skip:0 error:0 v3: - use errno.EOPNOTSUPP (Petr) - move qstat[0] under try (Petr) v2: - KTAP output formatting (Jakub) - defer instead of try/finally (Jakub) - disappearing stats is an error (Jakub) - ksft_ge instead of open coding (Jakub) Signed-off-by: Stanislav Fomichev --- Cc: Shuah Khan Cc: Joe Damato Cc: Petr Machata Cc: linux-kselftest@vger.kernel.org --- tools/testing/selftests/drivers/net/stats.py | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py index 820b8e0a22c6..2fdde8cf0307 100755 --- a/tools/testing/selftests/drivers/net/stats.py +++ b/tools/testing/selftests/drivers/net/stats.py @@ -1,10 +1,12 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0 +import errno from lib.py import ksft_run, ksft_exit, ksft_pr from lib.py import ksft_ge, ksft_eq, ksft_in, ksft_true, ksft_raises, KsftSkipEx, KsftXfailEx from lib.py import EthtoolFamily, NetdevFamily, RtnlFamily, NlError from lib.py import NetDrvEnv +from lib.py import ip, defer ethnl = EthtoolFamily() netfam = NetdevFamily() @@ -133,9 +135,30 @@ rtnl = RtnlFamily() ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex') +def check_down(cfg) -> None: + try: + qstat = netfam.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0] + except NlError as e: + if e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("qstats not supported by the device") + raise + + ip(f"link set dev {cfg.dev['ifname']} down") + defer(ip, f"link set dev {cfg.dev['ifname']} up") + + qstat2 = netfam.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0] + for k, v in qstat.items(): + ksft_ge(qstat2[k], qstat[k], comment=f"{k} went backwards on device down") + + # exercise per-queue API to make sure that "device down" state + # is handled correctly and doesn't crash + netfam.qstats_get({"ifindex": cfg.ifindex, "scope": "queue"}, dump=True) + + def main() -> None: with NetDrvEnv(__file__) as cfg: - ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex], + ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex, + check_down], args=(cfg, )) ksft_exit() From patchwork Fri Aug 2 00:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13750938 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B61A211C; Fri, 2 Aug 2024 00:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722556995; cv=none; b=u6Ch5BNyw+J2aLJus+XWtRx/KYHedI2ZyCEqtVir2lO49I6gA2oNKrd+lJrJq3y8ZU7BD3/OwnHxDpABkM7821lMsPIqQ8K+5uX/oHZ7IyMR90vxrnIiAFYyQV4pMMQVCNiQCatPqlxdOnLsWjJJSnAgVyMqgdl7RW8h+FQEAB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722556995; c=relaxed/simple; bh=QcAvIHWMBzWxGBJ2Vi6pxtBbNp1IdHzgY8X0Nsct7M8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pK2V04EX4DhVzQoToXuyOzT8GlhKUa929rg+v0TjX4yYWZN+jtSGKLACPtp1AF7LVzA5StW4LK22C3gT1XauCB+FpaUtISaDR+diEXpyazfBSCrxxcJitZjhfQh/pOjJQ5NNpNjFKE8lXI9PiiOpksHkN5e5Xod4Wev0XDSazQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-264545214efso4176900fac.3; Thu, 01 Aug 2024 17:03:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722556992; x=1723161792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZnCk0SvEhVwQqWO65jWfKFlVg+4G4vLteypuoGCHAVw=; b=rN0M5iQHvlVt9756/EMgkgwOpAgvBi5gmQHK+xDPNMCWOwHIULR11R6lFYUxBGNQt/ 0HizOEvBPO7S43YMshfDhO/rPlIp80Ht/LUMeuxhu8zyreRlajwyBY6QEdqetogiMpbY 7XtO9wm4MQLqzrtlENUhvdNukUKy48s6/d36lqavkOhBFeFuM8rfvnVvHUfohek3Kj84 9pFMeER9ngxgasRHeVfE52nSHc44oa3MErtUkZNApnFsu4yW+5OqCuMjsNizFAX2Gjfu 5zwwd7yRUiyNJrQdprpyC5/mmJvrDBPndiV1wAkq4XqYx2337U9PlznaGFAHWITqhfsi P1Ng== X-Forwarded-Encrypted: i=1; AJvYcCX0gdJRYgn2DzbPkBfhlIkncd1DlD0rEab3eUjyaE4Y4zQvwpDR5pISm/ycXupzTkAFw9f9iJ/to438QyicQxPQmyR9hP2zoUIEIpwBnLaD X-Gm-Message-State: AOJu0Yz+Wr/NYZVHQKI5k8OEMo0HHQLjkBCgYFKL4S5xKy45UWZwFnJL 1dGmM43zNCdv4TQHqKjc/fK2eWHz/rkJKi/SENTqfWiEkycbC19SXocfJl4= X-Google-Smtp-Source: AGHT+IENjZPlqB/SxZn2B7pZUNBxeiTO6cdgcP9ONNV5IK9CkDwX2ZP5uXA4KSVOwwsEGfG3BLhZsg== X-Received: by 2002:a05:6870:a99d:b0:260:8f6d:f01f with SMTP id 586e51a60fabf-26891e93234mr1976666fac.39.1722556991621; Thu, 01 Aug 2024 17:03:11 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:73b6:7410:eb24:cba4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7b763a3fa2asm403346a12.50.2024.08.01.17.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 17:03:11 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Shuah Khan , Joe Damato , Petr Machata , linux-kselftest@vger.kernel.org Subject: [PATCH net-next v3 2/3] selftests: net: ksft: support marking tests as disruptive Date: Thu, 1 Aug 2024 17:03:08 -0700 Message-ID: <20240802000309.2368-2-sdf@fomichev.me> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802000309.2368-1-sdf@fomichev.me> References: <20240802000309.2368-1-sdf@fomichev.me> 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 new @ksft_disruptive decorator to mark the tests that might be disruptive to the system. Depending on how well the previous test works in the CI we might want to disable disruptive tests by default and only let the developers run them manually. KSFT framework runs disruptive tests by default. DISRUPTIVE=False environment (or config file) can be used to disable these tests. ksft_setup should be called by the test cases that want to use new decorator (ksft_setup is only called via NetDrvEnv/NetDrvEpEnv for now). In the future we can add similar decorators to, for example, avoid running slow tests all the time. And/or have some option to run only 'fast' tests for some sort of smoke test scenario. $ DISRUPTIVE=False ./stats.py KTAP version 1 1..5 ok 1 stats.check_pause ok 2 stats.check_fec ok 3 stats.pkt_byte_sum ok 4 stats.qstat_by_ifindex ok 5 stats.check_down # SKIP marked as disruptive # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:1 error:0 v3: - parse yes and properly treat non-zero nums as true (Petr) v2: - convert from cli argument to env variable (Jakub) Signed-off-by: Stanislav Fomichev --- Cc: Shuah Khan Cc: Joe Damato Cc: Petr Machata Cc: linux-kselftest@vger.kernel.org --- .../selftests/drivers/net/lib/py/env.py | 5 ++- tools/testing/selftests/drivers/net/stats.py | 2 + tools/testing/selftests/net/lib/py/ksft.py | 40 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py index a5e800b8f103..1ea9bb695e94 100644 --- a/tools/testing/selftests/drivers/net/lib/py/env.py +++ b/tools/testing/selftests/drivers/net/lib/py/env.py @@ -4,6 +4,7 @@ import os import time from pathlib import Path from lib.py import KsftSkipEx, KsftXfailEx +from lib.py import ksft_setup from lib.py import cmd, ethtool, ip from lib.py import NetNS, NetdevSimDev from .remote import Remote @@ -14,7 +15,7 @@ from .remote import Remote src_dir = Path(src_path).parent.resolve() if not (src_dir / "net.config").exists(): - return env + return ksft_setup(env) with open((src_dir / "net.config").as_posix(), 'r') as fp: for line in fp.readlines(): @@ -30,7 +31,7 @@ from .remote import Remote if len(pair) != 2: raise Exception("Can't parse configuration line:", full_file) env[pair[0]] = pair[1] - return env + return ksft_setup(env) class NetDrvEnv: diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py index 2fdde8cf0307..d17dfed2788f 100755 --- a/tools/testing/selftests/drivers/net/stats.py +++ b/tools/testing/selftests/drivers/net/stats.py @@ -4,6 +4,7 @@ import errno from lib.py import ksft_run, ksft_exit, ksft_pr from lib.py import ksft_ge, ksft_eq, ksft_in, ksft_true, ksft_raises, KsftSkipEx, KsftXfailEx +from lib.py import ksft_disruptive from lib.py import EthtoolFamily, NetdevFamily, RtnlFamily, NlError from lib.py import NetDrvEnv from lib.py import ip, defer @@ -135,6 +136,7 @@ rtnl = RtnlFamily() ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex') +@ksft_disruptive def check_down(cfg) -> None: try: qstat = netfam.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0] diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py index f26c20df9db4..353860fe6223 100644 --- a/tools/testing/selftests/net/lib/py/ksft.py +++ b/tools/testing/selftests/net/lib/py/ksft.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 import builtins +import functools import inspect import sys import time @@ -10,6 +11,7 @@ from .utils import global_defer_queue KSFT_RESULT = None KSFT_RESULT_ALL = True +KSFT_DISRUPTIVE = True class KsftFailEx(Exception): @@ -127,6 +129,44 @@ KSFT_RESULT_ALL = True KSFT_RESULT = False +def ksft_disruptive(func): + """ + Decorator that marks the test as disruptive (e.g. the test + that can down the interface). Disruptive tests can be skipped + by passing DISRUPTIVE=False environment variable. + """ + + @functools.wraps(func) + def wrapper(*args, **kwargs): + if not KSFT_DISRUPTIVE: + raise KsftSkipEx(f"marked as disruptive") + return func(*args, **kwargs) + return wrapper + + +def ksft_setup(env): + """ + Setup test framework global state from the environment. + """ + + def get_bool(env, name): + value = env.get(name, "").lower() + if value in ["yes", "true"]: + return True + if value in ["no", "false"]: + return False + try: + return bool(int(value)) + except: + raise Exception(f"failed to parse {name}") + + if "DISRUPTIVE" in env: + global KSFT_DISRUPTIVE + KSFT_DISRUPTIVE = get_bool(env, "DISRUPTIVE") + + return env + + def ksft_run(cases=None, globs=None, case_pfx=None, args=()): cases = cases or [] From patchwork Fri Aug 2 00:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13750939 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18BC53D6A; Fri, 2 Aug 2024 00:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722556995; cv=none; b=iPhAvQgaC/g3AJ58Nqon+7YB1pIch1lZ94B5tRG2TkrlmyiIKiNmycTpUTMANuBF2YNl0cqg+m5c3Mr5hMabS9IBFmaDJsakNGvHyYazB+q68OrSw3spKpkcohHlX9P3D4+Kn9mtU5jPZ9+9BPbWC5T+/SYrVxVeMqg0bdGM8aI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722556995; c=relaxed/simple; bh=RcywlS9M/hFj5VJKUlMqVbugewDyUm46O05Cv0Xushs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IbFEwu4D02fFiGEfdmnl0MxUMW7YgDW+4gBx7dh20og0aX3duGmiJCgBjLt2OK/mPpukD3UYz+i/UoD6gLTF/xl+T6PZTZ2t+cNVjwd4dk7eb1jLMfp3Xm+9bvleYjSyj3MDZ9AAeBvyvJK0697Fav6GcHUslO2siDkxCXSdWEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-75a6c290528so5214774a12.1; Thu, 01 Aug 2024 17:03:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722556993; x=1723161793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QuRWDwhsI9vl4snYs8u4lKbNw41VC2AyoXgyodw+BFY=; b=UINUmK6gwT0q2radiZtFh/p3uNauTPJyPvfI8rsLCRMQ63eYR+0QrekcfENRN9Mpq2 AcjUptYJRb8sVoesLMHIdbL0EDFCxTIlJ6D9+cb3UkcNv2a9V2wkGnqrOslwzlBQbrQa jANrlKeWb9QJIOVpc4ik3DDIE8PT1BN5rzg0/5I46Y5BGbg/BmHfHECwcMpHFnsAKNVJ IPK1DRsLSAEdhYQksb4SLmz1qdEE9zGt12VooAyZ2aeQjiW0tKKK4PzwA7c9wFVSXSDN O4Eo03KzDRaJB3PAXgEHKGivbV3ds8szqP6ZA8xu4/KSRVgJiaLs+kQvZhruDPGB32cF mA7Q== X-Forwarded-Encrypted: i=1; AJvYcCXEmP3qrmwVzMkxYY23cPUHdwPMmerh28+jfSQ9kinmil1QrrxSFEqotwfCrihQ1FPWd2kcPWiLFyLJsZAQ/hmp6YrCiaAWWUXzo0pTO5tG X-Gm-Message-State: AOJu0YyaBpVOPPJE+MKAuidb+mnt8KdtbSWz3hJRVqfN56rEVFt1UyU0 XPJmlTa3hmAFWkaZ/YA+9ks6+wuQL4ZpUy6WZe6dI0cmC6NRJVboVoo9Fog= X-Google-Smtp-Source: AGHT+IFNdb4BfLqhkqH4b+ahMmBcRCVgkV/Jf74fmn3jdwcOhV+XQWHN5l4Gf5C4hAd8HF9ktpbmOw== X-Received: by 2002:a17:902:d505:b0:1fd:7c8a:be24 with SMTP id d9443c01a7336-1ff57281ad4mr26568905ad.16.1722556992938; Thu, 01 Aug 2024 17:03:12 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:73b6:7410:eb24:cba4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff59058c44sm4733245ad.139.2024.08.01.17.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 17:03:12 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Shuah Khan , Joe Damato , Petr Machata , linux-kselftest@vger.kernel.org Subject: [PATCH net-next v3 3/3] selftests: net: ksft: replace 95 with errno.EOPNOTSUPP Date: Thu, 1 Aug 2024 17:03:09 -0700 Message-ID: <20240802000309.2368-3-sdf@fomichev.me> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802000309.2368-1-sdf@fomichev.me> References: <20240802000309.2368-1-sdf@fomichev.me> 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 Petr suggested to use errno.EOPNOTSUPP instead of hard-coded 95 in the new test case. Adjust existing ones to match this style. Signed-off-by: Stanislav Fomichev --- Cc: Shuah Khan Cc: Joe Damato Cc: Petr Machata Cc: linux-kselftest@vger.kernel.org --- tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py | 3 ++- tools/testing/selftests/drivers/net/stats.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py b/tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py index 026d98976c35..05b6fbb3fcdd 100755 --- a/tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py +++ b/tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0 +import errno import time import os from lib.py import ksft_run, ksft_exit, ksft_pr @@ -61,7 +62,7 @@ from lib.py import cmd, tool, GenerateTraffic try: stats = get_stats() except NlError as e: - if e.nl_msg.error == -95: + if e.nl_msg.error == -errno.EOPNOTSUPP: stats = {} else: raise diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py index d17dfed2788f..63e3c045a3b2 100755 --- a/tools/testing/selftests/drivers/net/stats.py +++ b/tools/testing/selftests/drivers/net/stats.py @@ -20,7 +20,7 @@ rtnl = RtnlFamily() try: ethnl.pause_get({"header": {"dev-index": cfg.ifindex}}) except NlError as e: - if e.error == 95: + if e.error == errno.EOPNOTSUPP: raise KsftXfailEx("pause not supported by the device") raise @@ -35,7 +35,7 @@ rtnl = RtnlFamily() try: ethnl.fec_get({"header": {"dev-index": cfg.ifindex}}) except NlError as e: - if e.error == 95: + if e.error == errno.EOPNOTSUPP: raise KsftXfailEx("FEC not supported by the device") raise @@ -120,7 +120,7 @@ rtnl = RtnlFamily() # loopback has no stats with ksft_raises(NlError) as cm: netfam.qstats_get({"ifindex": 1}, dump=True) - ksft_eq(cm.exception.nl_msg.error, -95) + ksft_eq(cm.exception.nl_msg.error, -errno.EOPNOTSUPP) ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex') # Try to get stats for lowest unused ifindex but not 0