OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v5 1/1] selftests: drv-net-hw: skip the tests that need a real interface
Date: Fri, 23 Oct 2026 22:20:10 +0300	[thread overview]
Message-ID: <20261023192121.356062-2-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261023192121.356062-1-eva.kurchatova@virtuozzo.com>

ethtool, ethtool_extended_state, ethtool_rmon, hw_stats_l3 and
hw_stats_l3_gre need hardware: link speed, extended link state, rmon
counters, L3 statistics offload. With no interfaces configured lib.sh
substitutes a veth pair, and every case fails on what veth does not
have.

Upstream runs these tests on real hardware only and dropped the veth
check in commit 0c499a351777 ("selftests: forwarding: Ditch
skip_on_veth()"), so this patch is not for upstream.

Skip when the first interface the test would use is a veth, or does
not exist and lib.sh would create one. Real interfaces, named in
forwarding.config or on the command line, run as before, and so does a
run that picks its interfaces by driver with NETIF_FIND_DRIVER. The
check runs before lib.sh is sourced, since lib.sh creates the pair as
it is sourced and would leave it behind.

https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 .../testing/selftests/drivers/net/hw/Makefile |  1 +
 .../selftests/drivers/net/hw/ethtool.sh       |  5 +++
 .../drivers/net/hw/ethtool_extended_state.sh  |  5 +++
 .../selftests/drivers/net/hw/ethtool_rmon.sh  |  5 +++
 .../selftests/drivers/net/hw/hw_stats_l3.sh   |  5 +++
 .../drivers/net/hw/hw_stats_l3_gre.sh         |  5 +++
 .../selftests/drivers/net/hw/skip_on_veth.sh  | 38 +++++++++++++++++++
 7 files changed, 64 insertions(+)
 create mode 100644 tools/testing/selftests/drivers/net/hw/skip_on_veth.sh

diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
index e556b5150a51..39aece5e2776 100644
--- a/tools/testing/selftests/drivers/net/hw/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/Makefile
@@ -19,6 +19,7 @@ TEST_PROGS = \
 
 TEST_FILES := \
 	ethtool_lib.sh \
+	skip_on_veth.sh \
 	#
 
 TEST_INCLUDES := \
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool.sh b/tools/testing/selftests/drivers/net/hw/ethtool.sh
index fa6953de6b6d..e1fbe37a71fc 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool.sh
@@ -11,6 +11,11 @@ ALL_TESTS="
 "
 NUM_NETIFS=2
 lib_dir=$(dirname "$0")
+
+# Needs a device that can set link speed and autonegotiation
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source ethtool_lib.sh
 
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh b/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
index a7584448416e..1201130cae67 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
@@ -9,6 +9,11 @@ ALL_TESTS="
 
 NUM_NETIFS=2
 lib_dir=$(dirname "$0")
+
+# Needs a device that reports an extended link state
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source ethtool_lib.sh
 
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh b/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
index 8f60c1685ad4..1745afe671d4 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
@@ -8,6 +8,11 @@ ALL_TESTS="
 
 NUM_NETIFS=2
 lib_dir=$(dirname "$0")
+
+# Needs a device with rmon histogram counters
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 
 ETH_FCS_LEN=4
diff --git a/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh b/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh
index 67fafefc80be..460633f27f40 100755
--- a/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh
+++ b/tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh
@@ -49,6 +49,11 @@ ALL_TESTS="
 "
 NUM_NETIFS=4
 lib_dir=$(dirname "$0")
+
+# Needs a device that offloads L3 statistics
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source "$lib_dir"/../../../net/forwarding/tc_common.sh
 
diff --git a/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh b/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh
index a94d92e1abce..abe8c09700b4 100755
--- a/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh
+++ b/tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh
@@ -13,6 +13,11 @@ ALL_TESTS="
 "
 NUM_NETIFS=6
 lib_dir=$(dirname "$0")
+
+# Needs a device that offloads L3 statistics
+source "$lib_dir"/skip_on_veth.sh
+skip_on_veth "$@"
+
 source "$lib_dir"/../../../net/forwarding/lib.sh
 source "$lib_dir"/../../../net/forwarding/ipip_lib.sh
 source "$lib_dir"/../../../net/forwarding/tc_common.sh
diff --git a/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
new file mode 100644
index 000000000000..b65d474ac7b2
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+# Source with lib_dir set, ahead of lib.sh, which creates the interfaces.
+
+forwarding_dir="$lib_dir"/../../../net/forwarding
+
+# forwarding.config assigns by name into the array lib.sh declares
+declare -A NETIFS
+
+if [[ -f $forwarding_dir/forwarding.config ]]; then
+	source "$forwarding_dir/forwarding.config"
+fi
+
+: "${NETIF_CREATE:=yes}"
+: "${NETIF_TYPE:=veth}"
+
+# Call before sourcing lib.sh, exiting after it leaves the veth pair behind.
+# Judges by the first interface, the one lib.sh creates the pair from,
+# found the way lib.sh finds it: keep in step with lib.sh.
+skip_on_veth()
+{
+	# lib.sh takes the command line, then forwarding.config, then the driver
+	local p1=${1:-${NETIFS[p1]-}}
+	local kind
+
+	# lib.sh skips by itself when the driver has no interfaces
+	[[ -z $p1 && -n $NETIF_FIND_DRIVER ]] && return
+	p1=${p1:-veth0}
+	if ip link show dev "$p1" &> /dev/null; then
+		kind=$(ip -j -d link show dev "$p1" | jq -r '.[].linkinfo.info_kind')
+	elif [[ $NETIF_CREATE == yes && $NETIF_TYPE == veth ]]; then
+		kind=veth # what lib.sh creates when the interface is missing
+	fi
+	[[ $kind == veth ]] || return 0
+	echo "SKIP: needs a real interface, set NETIFS in forwarding.config"
+	exit 4 # ksft_skip, lib.sh is not sourced yet
+}
-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-10-23 19:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 19:20 [Devel] [PATCH hci-8.1 v5 0/1] " Eva Kurchatova
2026-10-23 19:20 ` Eva Kurchatova [this message]
2026-10-23 19:25   ` [Devel] [PATCH hci-8.1 v5 1/1] " no-reply
2026-10-26 12:19     ` Eva Kurchatova (Virtuozzo)
2026-10-27 12:00 ` [Devel] [PATCH hci-8.1 v5 0/1] " Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261023192121.356062-2-eva.kurchatova@virtuozzo.com \
    --to=eva.kurchatova@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox