1 # ethtool tests for emulated network devices
3 # This test leverages ethtool's --test sequence to validate network
6 # SPDX-License-Identifier: GPL-2.0-or-late
8 from avocado
import skip
9 from avocado_qemu
import QemuSystemTest
10 from avocado_qemu
import wait_for_console_pattern
12 class NetDevEthtool(QemuSystemTest
):
14 :avocado: tags=arch:x86_64
15 :avocado: tags=machine:q35
18 # Runs in about 17s under KVM, 19s under TCG, 25s under GCOV
21 # Fetch assets from the netdev-ethtool subdir of my shared test
22 # images directory on fileserver.linaro.org.
23 def get_asset(self
, name
, sha1
):
24 base_url
= ('https://fileserver.linaro.org/s/'
25 'kE4nCFLdQcoBF9t/download?'
26 'path=%2Fnetdev-ethtool&files=' )
28 # use explicit name rather than failing to neatly parse the
29 # URL into a unique one
30 return self
.fetch_asset(name
=name
, locations
=(url
), asset_hash
=sha1
)
32 def common_test_code(self
, netdev
, extra_args
=None):
34 # This custom kernel has drivers for all the supported network
35 # devices we can emulate in QEMU
36 kernel
= self
.get_asset("bzImage",
37 "33469d7802732d5815226166581442395cb289e2")
39 rootfs
= self
.get_asset("rootfs.squashfs",
40 "9793cea7021414ae844bda51f558bd6565b50cdc")
42 append
= 'printk.time=0 console=ttyS0 '
43 append
+= 'root=/dev/sr0 rootfstype=squashfs '
45 # any additional kernel tweaks for the test
49 # finally invoke ethtool directly
50 append
+= ' init=/usr/sbin/ethtool -- -t eth1 offline'
52 # add the rootfs via a readonly cdrom image
53 drive
= f
"file={rootfs},if=ide,index=0,media=cdrom"
55 self
.vm
.add_args('-kernel', kernel
,
60 self
.vm
.set_console(console_index
=0)
63 wait_for_console_pattern(self
,
64 "The test result is PASS",
65 "The test result is FAIL",
67 # no need to gracefully shutdown, just finish
72 :avocado: tags=device:igb
74 self
.common_test_code("igb")
76 def test_igb_nomsi(self
):
78 :avocado: tags=device:igb
80 self
.common_test_code("igb", "pci=nomsi")
82 # It seems the other popular cards we model in QEMU currently fail
83 # the pattern test with:
85 # pattern test failed (reg 0x00178): got 0x00000000 expected 0x00005A5A
87 # So for now we skip them.
89 @skip("Incomplete reg 0x00178 support")
92 :avocado: tags=device:e1000
94 self
.common_test_code("e1000")
96 @skip("Incomplete reg 0x00178 support")
97 def test_i82550(self
):
99 :avocado: tags=device:i82550
101 self
.common_test_code("i82550")