]> git.proxmox.com Git - mirror_qemu.git/blame - tests/avocado/netdev-ethtool.py
Merge tag 'hppa64-fixes-pull-request' of https://github.com/hdeller/qemu-hppa into...
[mirror_qemu.git] / tests / avocado / netdev-ethtool.py
CommitLineData
9f951114
AB
1# ethtool tests for emulated network devices
2#
3# This test leverages ethtool's --test sequence to validate network
4# device behaviour.
5#
6# SPDX-License-Identifier: GPL-2.0-or-late
7
8from avocado import skip
9from avocado_qemu import QemuSystemTest
9f951114
AB
10from avocado_qemu import wait_for_console_pattern
11
12class NetDevEthtool(QemuSystemTest):
13 """
14 :avocado: tags=arch:x86_64
15 :avocado: tags=machine:q35
16 """
17
18 # Runs in about 17s under KVM, 19s under TCG, 25s under GCOV
19 timeout = 45
20
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=' )
27 url = base_url + name
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)
31
1531fb4d 32 def common_test_code(self, netdev, extra_args=None):
9f951114
AB
33
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")
38
39 rootfs = self.get_asset("rootfs.squashfs",
40 "9793cea7021414ae844bda51f558bd6565b50cdc")
41
42 append = 'printk.time=0 console=ttyS0 '
43 append += 'root=/dev/sr0 rootfstype=squashfs '
44
45 # any additional kernel tweaks for the test
46 if extra_args:
47 append += extra_args
48
49 # finally invoke ethtool directly
50 append += ' init=/usr/sbin/ethtool -- -t eth1 offline'
51
52 # add the rootfs via a readonly cdrom image
53 drive = f"file={rootfs},if=ide,index=0,media=cdrom"
54
55 self.vm.add_args('-kernel', kernel,
56 '-append', append,
57 '-drive', drive,
58 '-device', netdev)
59
9f951114
AB
60 self.vm.set_console(console_index=0)
61 self.vm.launch()
62
63 wait_for_console_pattern(self,
64 "The test result is PASS",
65 "The test result is FAIL",
66 vm=None)
67 # no need to gracefully shutdown, just finish
68 self.vm.kill()
69
9f951114
AB
70 def test_igb(self):
71 """
72 :avocado: tags=device:igb
73 """
74 self.common_test_code("igb")
75
76 def test_igb_nomsi(self):
77 """
78 :avocado: tags=device:igb
79 """
80 self.common_test_code("igb", "pci=nomsi")
81
9f951114
AB
82 # It seems the other popular cards we model in QEMU currently fail
83 # the pattern test with:
84 #
85 # pattern test failed (reg 0x00178): got 0x00000000 expected 0x00005A5A
86 #
87 # So for now we skip them.
88
89 @skip("Incomplete reg 0x00178 support")
90 def test_e1000(self):
91 """
92 :avocado: tags=device:e1000
93 """
94 self.common_test_code("e1000")
95
96 @skip("Incomplete reg 0x00178 support")
97 def test_i82550(self):
98 """
99 :avocado: tags=device:i82550
100 """
101 self.common_test_code("i82550")