From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v3 1/1] selftests: drv-net-hw: skip the tests that need a real interface
Date: Wed, 7 Oct 2026 01:26:19 +0300 [thread overview]
Message-ID: <20261006222651.2510417-2-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261006222651.2510417-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 before sourcing lib.sh, which creates the pair as it is sourced
and would leave it behind. The check takes the interfaces the way
lib.sh does, from the command line or forwarding.config, and skips when
the first one is a veth, or does not exist and would be created as one.
Real interfaces named there run with NETIF_CREATE and NETIF_TYPE left
at their defaults, as lib.sh only creates what is missing.
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 | 33 +++++++++++++++++++
7 files changed, 59 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..aa2bb98dc278
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/skip_on_veth.sh
@@ -0,0 +1,33 @@
+#!/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
+skip_on_veth()
+{
+ # lib.sh takes the interfaces from the command line ahead of the config
+ local p1=${1:-${NETIFS[p1]-}}
+ local kind
+
+ if [[ -n $p1 ]] && ip link show dev "$p1" &> /dev/null; then
+ kind=$(ip -j -d link show dev "$p1" | jq -r '.[].linkinfo.info_kind')
+ [[ $kind == veth ]] || return
+ elif [[ $NETIF_CREATE != yes || $NETIF_TYPE != veth ]]; then
+ return
+ fi
+ 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
next prev parent reply other threads:[~2026-10-06 22:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 22:26 [Devel] [PATCH hci-8.1 v3 0/1] " Eva Kurchatova
2026-10-06 22:26 ` Eva Kurchatova [this message]
2026-10-06 22:31 ` [Devel] [PATCH hci-8.1 v3 1/1] " no-reply
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=20261006222651.2510417-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.