Skip to contentSkip to conversation

selftests: drv-net: print device info at the start

PATCH Applied Jakub Kicinski 3 participants 3 messages Aug 3 – Aug 6

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 selftests: drv-net: print device info at the start

When a reviewer asks a developer to run an upstream test during code review, it's often ambiguous whether the test was actually run against a real device, or just against netdevsim. Print the driver name and ifname at the start of the test, e.g.:

# Interface: enp0s13f0u1u4, driver: r8152
TAP version 13
1..1
ok 1 ...

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 .../selftests/drivers/net/lib/py/env.py       | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/lib/py/env.py +20 -1
index e4acf3d8333f..a8e8029868a7 100644
@@ -7,7 +7,7 @@ import time
 import json
 from pathlib import Path
 from lib.py import KsftSkipEx, KsftXfailEx
-from lib.py import ksft_setup, wait_file
+from lib.py import ksft_pr, ksft_setup, wait_file
 from lib.py import cmd, ethtool, ip, CmdExitFailure
 from lib.py import NetNS, NetdevSimDev, UserNetNS
 from .remote import Remote
@@ -31,6 +31,7 @@ from . import bpftool, RtnlFamily, Netlink
 
         # Following attrs must be set be inheriting classes
         self.dev = None
+        self.ifname = None
 
     def _load_env_file(self):
         env = os.environ.copy()
@@ -58,6 +59,22 @@ from . import bpftool, RtnlFamily, Netlink
     def __del__(self):
         pass
 
+    def _print_dev_info(self):
+        """
+        Show whether the test ran on real hardware or netdevsim.
+        Useful to confirm when results are shared on the mailing list.
+        """
+        driver = "unknown"
+        try:
+            info = ethtool(f"-i {self.ifname}").stdout
+            for line in info.splitlines():
+                if line.startswith("driver:"):
+                    driver = line.split(':', 1)[1].strip() or driver
+                    break
+        except (CmdExitFailure, FileNotFoundError):
+            pass
+        ksft_pr(f"Interface: {self.ifname}, driver: {driver}")
+
     def __enter__(self):
         ip(f"link set dev {self.dev['ifname']} up")
         wait_file(f"/sys/class/net/{self.dev['ifname']}/carrier",
@@ -94,6 +111,7 @@ from . import bpftool, RtnlFamily, Netlink
             self.dev = self._ns.nsims[0].dev
         self.ifname = self.dev['ifname']
         self.ifindex = self.dev['ifindex']
+        self._print_dev_info()
 
     def __del__(self):
         if self._ns:
@@ -163,6 +181,7 @@ from . import bpftool, RtnlFamily, Netlink
 
         self.ifname = self.dev['ifname']
         self.ifindex = self.dev['ifindex']
+        self._print_dev_info()
 
         # resolve remote interface name
         self.remote_ifname = self.resolve_remote_ifc()
Signature · 1 line
2.55.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jakub Kicinski

When a reviewer asks a developer to run an upstream test during code review, it's often ambiguous whether the test was actually run against a real device, or just against netdevsim. Print the driver name and ifname at the start of the test, e.g.:

# Interface: enp0s13f0u1u4, driver: r8152
TAP version 13
1..1
ok 1 ...

#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Mon, 3 Aug 2026 14:19:44 -0700 you wrote:

When a reviewer asks a developer to run an upstream test during code review, it's often ambiguous whether the test was actually run against a real device, or just against netdevsim. Print the driver name and ifname at the start of the test, e.g.:

# Interface: enp0s13f0u1u4, driver: r8152
TAP version 13
1..1
ok 1 ...

[...]

Here is the summary with links:
- [net-next] selftests: drv-net: print device info at the start

    https://git.kernel.org/netdev/net-next/c/9cb1d062b094

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html