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 exec_command
, exec_command_and_wait_for_pattern
11 from avocado_qemu
import wait_for_console_pattern
13 class NetDevEthtool(QemuSystemTest
):
15 :avocado: tags=arch:x86_64
16 :avocado: tags=machine:q35
19 # Runs in about 17s under KVM, 19s under TCG, 25s under GCOV
22 # Fetch assets from the netdev-ethtool subdir of my shared test
23 # images directory on fileserver.linaro.org.
24 def get_asset(self
, name
, sha1
):
25 base_url
= ('https://fileserver.linaro.org/s/'
26 'kE4nCFLdQcoBF9t/download?'
27 'path=%2Fnetdev-ethtool&files=' )
29 # use explicit name rather than failing to neatly parse the
30 # URL into a unique one
31 return self
.fetch_asset(name
=name
, locations
=(url
), asset_hash
=sha1
)
33 def common_test_code(self
, netdev
, extra_args
=None, kvm
=False):
35 # This custom kernel has drivers for all the supported network
36 # devices we can emulate in QEMU
37 kernel
= self
.get_asset("bzImage",
38 "33469d7802732d5815226166581442395cb289e2")
40 rootfs
= self
.get_asset("rootfs.squashfs",
41 "9793cea7021414ae844bda51f558bd6565b50cdc")
43 append
= 'printk.time=0 console=ttyS0 '
44 append
+= 'root=/dev/sr0 rootfstype=squashfs '
46 # any additional kernel tweaks for the test
50 # finally invoke ethtool directly
51 append
+= ' init=/usr/sbin/ethtool -- -t eth1 offline'
53 # add the rootfs via a readonly cdrom image
54 drive
= f
"file={rootfs},if=ide,index=0,media=cdrom"
56 self
.vm
.add_args('-kernel', kernel
,
62 self
.vm
.add_args('-accel', 'kvm')
64 self
.vm
.set_console(console_index
=0)
67 wait_for_console_pattern(self
,
68 "The test result is PASS",
69 "The test result is FAIL",
71 # no need to gracefully shutdown, just finish
74 # Skip testing for MSI for now. Allegedly it was fixed by:
75 # 28e96556ba (igb: Allocate MSI-X vector when testing)
76 # but I'm seeing oops in the kernel
77 @skip("Kernel bug with MSI enabled")
80 :avocado: tags=device:igb
82 self
.common_test_code("igb")
84 def test_igb_nomsi(self
):
86 :avocado: tags=device:igb
88 self
.common_test_code("igb", "pci=nomsi")
90 def test_igb_nomsi_kvm(self
):
92 :avocado: tags=device:igb
94 self
.require_accelerator('kvm')
95 self
.common_test_code("igb", "pci=nomsi", True)
97 # It seems the other popular cards we model in QEMU currently fail
98 # the pattern test with:
100 # pattern test failed (reg 0x00178): got 0x00000000 expected 0x00005A5A
102 # So for now we skip them.
104 @skip("Incomplete reg 0x00178 support")
105 def test_e1000(self
):
107 :avocado: tags=device:e1000
109 self
.common_test_code("e1000")
111 @skip("Incomplete reg 0x00178 support")
112 def test_i82550(self
):
114 :avocado: tags=device:i82550
116 self
.common_test_code("i82550")