Merge ~canonical-kernel-team/+git/autotest-client-tests:phlin/remove-net-ubuntu_kernel_selftests into ~canonical-kernel-team/+git/autotest-client-tests:master

Proposed by Po-Hsu Lin
Status: Merged
Merge reported by: Po-Hsu Lin
Merged at revision: d7f0384a51cc417e839fcbb14d7ad58fd1c04f49
Proposed branch: ~canonical-kernel-team/+git/autotest-client-tests:phlin/remove-net-ubuntu_kernel_selftests
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Prerequisite: ~canonical-kernel-team/+git/autotest-client-tests:phlin/add-ubuntu_kselftests_net
Diff against target: 454 lines (+7/-265)
4 files modified
dev/null (+0/-174)
ubuntu_kernel_selftests/control (+1/-1)
ubuntu_kernel_selftests/control.ubuntu.xenial (+1/-1)
ubuntu_kernel_selftests/ubuntu_kernel_selftests.py (+5/-89)
Reviewer Review Type Date Requested Status
Sean Feole Approve
Review via email: mp+456774@code.launchpad.net

Commit message

net test has been moved into ubuntu_kselftests_net, related code
can be removed now.

To post a comment you must log in.
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Comments added to some required packages.

Patch tested with B/F/J/L/M.

Revision history for this message
Sean Feole (sfeole) wrote :
review: Approve
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

This is now live, thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ubuntu_kernel_selftests/control b/ubuntu_kernel_selftests/control
2index 7806fd1..fe8c7d6 100644
3--- a/ubuntu_kernel_selftests/control
4+++ b/ubuntu_kernel_selftests/control
5@@ -11,7 +11,7 @@ TEST_TYPE = "client"
6 DOC = ""
7
8
9-categories = ['breakpoints', 'cpu-hotplug', 'efivarfs', 'memfd', 'memory-hotplug', 'mount', 'powerpc', 'net', 'ptrace', 'seccomp', 'timers', 'user']
10+categories = ['breakpoints', 'cpu-hotplug', 'efivarfs', 'memfd', 'memory-hotplug', 'mount', 'powerpc', 'ptrace', 'seccomp', 'timers', 'user']
11 #
12 # The seccomp tests on 4.19+ on non-x86 are known to be fail and
13 # need fixing up. For now, disable them.
14diff --git a/ubuntu_kernel_selftests/control.ubuntu.xenial b/ubuntu_kernel_selftests/control.ubuntu.xenial
15index b2a2e76..247cd6c 100644
16--- a/ubuntu_kernel_selftests/control.ubuntu.xenial
17+++ b/ubuntu_kernel_selftests/control.ubuntu.xenial
18@@ -11,7 +11,7 @@ TEST_TYPE = "client"
19 DOC = ""
20
21
22-categories = ['breakpoints', 'cpu-hotplug', 'efivarfs', 'memory-hotplug', 'mount', 'net', 'ptrace', 'powerpc', 'seccomp', 'user']
23+categories = ['breakpoints', 'cpu-hotplug', 'efivarfs', 'memory-hotplug', 'mount', 'ptrace', 'powerpc', 'seccomp', 'user']
24
25 result = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=60*30)
26 if result == 'ERROR':
27diff --git a/ubuntu_kernel_selftests/ubuntu_kernel_selftests.py b/ubuntu_kernel_selftests/ubuntu_kernel_selftests.py
28index d3235da..cd29963 100644
29--- a/ubuntu_kernel_selftests/ubuntu_kernel_selftests.py
30+++ b/ubuntu_kernel_selftests/ubuntu_kernel_selftests.py
31@@ -12,54 +12,16 @@ class ubuntu_kernel_selftests(test.test):
32 def install_required_pkgs(self):
33 '''Function to install necessary packages.'''
34 pkgs = [
35- 'bc',
36+ 'bc', # For memory-hotplug
37 'build-essential',
38- 'devscripts',
39- 'docutils-common',
40- 'ethtool',
41- 'fuse',
42- 'git',
43- 'iptables',
44- 'jq',
45- 'kernel-wedge',
46- 'libfuse-dev',
47- 'libnuma-dev',
48- 'libssl-dev',
49- 'netsniff-ng',
50- 'net-tools',
51+ 'fuse', # For memfd
52+ 'kernel-wedge', # For "fakeroot debian/rules clean"
53+ 'libcap-dev', # For seccomp
54+ 'libfuse-dev', # For memfd
55 'pkg-config',
56- 'uuid-runtime'
57 ]
58- if not self.series in ['trusty', 'xenial', 'bionic']:
59- pkgs.append('socat')
60- if not self.arch == 's390x':
61- if not self.series in ['trusty', 'xenial', 'bionic', 'focal', 'jammy']:
62- # With recent kernels BPF requires lld (LLVM-based linker) to
63- # build the corresponding kernel selftests, so make sure this
64- # package is installed (in the releases where it is available)
65- # lld is not available for s390x
66- pkgs.append('lld')
67 gcc = 'gcc' if self.arch in ['ppc64le', 'aarch64', 's390x', 'riscv64'] else 'gcc-multilib'
68 pkgs.append(gcc)
69-
70- if any(x in self.flavour for x in ['aws', 'azure', 'gcp', 'gke', 'ibm', 'oracle']):
71- if not (self.flavour == 'aws' and self.series == 'trusty'):
72- pkgs.append('linux-modules-extra-' + platform.uname()[2])
73-
74- if self.kv >= 415:
75- # extra packages for building bpf tests
76- pkgs.extend(['libcap-dev', 'libelf-dev'])
77- if self.kv in [504, 503]:
78- # special case for B-5.4 (lp:1882559) / B-5.3 (lp:1845860)
79- # clang on F is clang-10 but we need clang-9 (see commit 95f91d59642)
80- # clang on E is clang-9, so it's ok to just check kv here
81- pkgs.extend(['clang-9', 'llvm-9'])
82- elif self.kv == 506:
83- # special case for F-oem-5.6 (lp:1879360)
84- pkgs.extend(['clang-10', 'llvm-10'])
85- else:
86- pkgs.extend(['clang', 'llvm'])
87-
88 cmd = 'yes "" | DEBIAN_FRONTEND=noninteractive apt-get install --yes --force-yes ' + ' '.join(pkgs)
89 utils.system_output(cmd, retain_output=True)
90
91@@ -71,8 +33,6 @@ class ubuntu_kernel_selftests(test.test):
92 except AttributeError:
93 import distro
94 self.series = distro.codename()
95- self.kv = platform.release().split(".")[:2]
96- self.kv = int(self.kv[0]) * 100 + int(self.kv[1])
97
98 def download(self):
99 '''Function to download kernel source.'''
100@@ -192,13 +152,6 @@ class ubuntu_kernel_selftests(test.test):
101 cmd = 'sed -i "s/ mem-on-off-test.sh//" ' + mk
102 utils.system(cmd)
103
104- # net/txtimestamp.sh is very fragile, disable it
105- #
106- fn = 'linux/tools/testing/selftests/net/Makefile'
107- if os.path.exists(fn):
108- cmd = 'sed -i "/^TEST_PROGS += txtimestamp.sh$/d" ' + fn
109- utils.system(cmd)
110-
111 # Build header first (LP: #2031400)
112 if not self.series in ['trusty', 'xenial', 'bionic', 'focal']:
113 cmd = "make -C linux/ headers"
114@@ -210,32 +163,6 @@ class ubuntu_kernel_selftests(test.test):
115 return
116 if test_name.endswith('-build'):
117 os.chdir(self.srcdir)
118- if "net" in test_name:
119- cmds = []
120- cmds.append("sh -c 'echo 1 > /proc/sys/net/ipv4/conf/all/accept_local'")
121- # The net benchmarching tests (e.g. udpgso) can fail when
122- # optmem limit is reached.
123- # https://www.kernel.org/doc/html/latest/networking/msg_zerocopy.html#transmission
124- # LP #1960907
125- cmds.append("sh -c 'echo 2048000 > /proc/sys/net/core/optmem_max'")
126- for cmd in cmds:
127- utils.system(cmd)
128-
129- if self.kv >= 415:
130- # net selftests use a module built by bpf selftests, bpf is available since bionic kernel
131- if self.kv == 506:
132- os.environ["CLANG"] = "clang-10"
133- os.environ["LLC"] = "llc-10"
134- os.environ["LLVM_OBJCOPY"] = "llvm-objcopy-10"
135- os.environ["LLVM_READELF"] = "llvm-readelf-10"
136- elif self.kv in [504, 503]:
137- os.environ["CLANG"] = "clang-9"
138- os.environ["LLC"] = "llc-9"
139- os.environ["LLVM_OBJCOPY"] = "llvm-objcopy-9"
140- os.environ["LLVM_READELF"] = "llvm-readelf-9"
141- cmd = "make -C linux/tools/testing/selftests TARGETS=bpf SKIP_TARGETS= KDIR=/usr/src/linux-headers-{}".format(platform.release())
142- # keep running selftests/net, even if selftests/bpf build fails
143- utils.system(cmd, ignore_status=True)
144 cmd = "make -C linux/tools/testing/selftests TARGETS={}".format(test_name.replace('-build', ''))
145 utils.system_output(cmd, retain_output=True)
146 return
147@@ -247,17 +174,6 @@ class ubuntu_kernel_selftests(test.test):
148 cmd = "make run_tests -C {} TEST_PROGS={} TEST_GEN_PROGS='' TEST_CUSTOM_PROGS=''".format(category, sub_test)
149 result = utils.system_output(cmd, retain_output=True)
150
151- # The output of test_bpf.sh / test_blackhole_dev.sh test will be in the dmesg
152- kernel_module_tests = {'test_bpf.sh': 'CONFIG_TEST_BPF',
153- 'test_blackhole_dev.sh': 'CONFIG_TEST_BLACKHOLE_DEV'}
154- if sub_test in kernel_module_tests.keys():
155- output = utils.system_output('dmesg', retain_output=True)
156- if not output:
157- print("Looks like there's no dmesg output, checking for {}...".format(kernel_module_tests[sub_test]))
158- cmd = "grep ^{} /boot/config-$(uname -r)".format(kernel_module_tests[sub_test])
159- if not utils.system_output(cmd, verbose=False, ignore_status=True):
160- print("{} not enabled.".format(kernel_module_tests[sub_test]))
161-
162 # Old pattern for Xenial
163 pattern = re.compile('selftests: *(?P<case>[\w\-\.]+) \[FAIL\]\n')
164 if re.search(pattern, result):
165diff --git a/ubuntu_kselftests_net/blacklist.trusty b/ubuntu_kselftests_net/blacklist.trusty
166deleted file mode 100644
167index 4682f80..0000000
168--- a/ubuntu_kselftests_net/blacklist.trusty
169+++ /dev/null
170@@ -1 +0,0 @@
171-We don't run net test on Trusty, just ['setup','breakpoints','cpu-hotplug','efivarfs','ipc','mount','powerpc','ptrace'].
172diff --git a/ubuntu_kselftests_net/control b/ubuntu_kselftests_net/control
173deleted file mode 100644
174index 23031df..0000000
175--- a/ubuntu_kselftests_net/control
176+++ /dev/null
177@@ -1,47 +0,0 @@
178-AUTHOR = "Ubuntu"
179-NAME = 'ubuntu_kselftests_net'
180-CRITERIA = """
181-Uses built-in kernel repository self tests for net.
182-"""
183-SUITE = "None"
184-TIME = "SHORT"
185-TEST_CLASS = 'kernel'
186-TEST_CATEGORY = 'Functional'
187-TEST_TYPE = "client"
188-DOC = ""
189-
190-
191-categories = ['net']
192-arch = platform.machine()
193-arch_scale = 1
194-# Scale timeouts by 2 for riscv64, some tests timeout due to lack of
195-# timeout, despite progressing fine
196-if arch in ['riscv64']:
197- arch_scale = 2
198-
199-result = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=arch_scale*60*45)
200-if result == 'GOOD':
201- for category in categories:
202- build = '{}-build'.format(category)
203- result = job.run_test_detail(NAME, test_name=build, tag=build, timeout=arch_scale*60*60)
204- if result == 'ERROR':
205- print("ERROR: test suite '{}' failed to build, skipping all the sub tests".format(category))
206- continue
207- mk_helper = os.path.join(job.testdir, NAME, 'helper.mk')
208- dir_root = os.path.join(job.bindir, 'tmp', NAME, 'src', 'linux/tools/testing/selftests/')
209- dir_src = os.path.join(dir_root, category)
210- mk_src = os.path.join(dir_src, 'Makefile')
211- os.chdir(dir_src)
212- if os.path.isfile(mk_src):
213- cmd = 'make -f {} -f {} gettests'.format(mk_src, mk_helper)
214- tests = utils.system_output(cmd).split()
215- for item in tests:
216- timeout_threshold = arch_scale*60*45
217- if item == 'fcnal-test.sh':
218- timeout_threshold = arch_scale*60*75 # lp:2006499, lp:2012016
219- test = "{}:{}".format(category, item)
220- job.run_test_detail(NAME, test_name=test, tag=test, timeout=timeout_threshold)
221-else:
222- print("ERROR: test failed to build, skipping all the sub tests")
223-
224-# vi:set ts=4 sw=4 expandtab syntax=python:
225diff --git a/ubuntu_kselftests_net/control.ubuntu.xenial b/ubuntu_kselftests_net/control.ubuntu.xenial
226deleted file mode 100644
227index 37dec82..0000000
228--- a/ubuntu_kselftests_net/control.ubuntu.xenial
229+++ /dev/null
230@@ -1,33 +0,0 @@
231-AUTHOR = "Ubuntu"
232-NAME = 'ubuntu_kselftests_net'
233-CRITERIA = """
234-Uses built-in kernel repository self tests for net.
235-"""
236-SUITE = "None"
237-TIME = "SHORT"
238-TEST_CLASS = 'kernel'
239-TEST_CATEGORY = 'Functional'
240-TEST_TYPE = "client"
241-DOC = ""
242-
243-
244-categories = ['net']
245-
246-result = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=60*30)
247-if result == 'ERROR':
248- print("ERROR: test failed to build, skipping all the sub tests")
249-else:
250- for category in categories:
251- build = '{}-build'.format(category)
252- job.run_test_detail(NAME, test_name=build, tag=build, timeout=60*10)
253- mk_helper = os.path.join(job.testdir, NAME, 'helper.mk')
254- dir_src = os.path.join(job.bindir, 'tmp', NAME, 'src', 'linux/tools/testing/selftests/', category)
255- mk_src = os.path.join(dir_src, 'Makefile')
256- os.chdir(dir_src)
257- cmd = 'make -f {} -f {} gettests'.format(mk_helper, mk_src)
258- tests = utils.system_output(cmd).split()
259- for item in tests:
260- test = "{}:{}".format(category, os.path.basename(item))
261- job.run_test_detail(NAME, test_name=test, tag=test, timeout=60*30)
262-
263-# vi:set ts=4 sw=4 expandtab syntax=python:
264diff --git a/ubuntu_kselftests_net/helper.mk b/ubuntu_kselftests_net/helper.mk
265deleted file mode 100755
266index ab3bb36..0000000
267--- a/ubuntu_kselftests_net/helper.mk
268+++ /dev/null
269@@ -1,5 +0,0 @@
270-gettests:
271- @echo '$(notdir $(TEST_GEN_PROGS)) $(notdir $(TEST_CUSTOM_PROGS)) $(notdir $(TEST_PROGS))'
272-
273-getsubdirs:
274- @echo '$(SUB_DIRS)'
275diff --git a/ubuntu_kselftests_net/ubuntu_kselftests_net.py b/ubuntu_kselftests_net/ubuntu_kselftests_net.py
276deleted file mode 100644
277index 766c904..0000000
278--- a/ubuntu_kselftests_net/ubuntu_kselftests_net.py
279+++ /dev/null
280@@ -1,174 +0,0 @@
281-#
282-#
283-import os
284-import platform
285-import re
286-from autotest.client import test, utils
287-from autotest.client.shared import error
288-
289-class ubuntu_kselftests_net(test.test):
290- version = 1
291-
292- def install_required_pkgs(self):
293- '''Function to install necessary packages.'''
294- pkgs = [
295- 'build-essential',
296- 'docutils-common', # For bpf test build
297- 'ethtool', # For net:udpgro_fwd.sh
298- 'iptables', # For net:ip_defrag.sh
299- 'jq', # For net:altnames.sh
300- 'kernel-wedge', # For "fakeroot debian/rules clean"
301- 'libfuse-dev', # For net:reuseport_bpf_numa
302- 'libnuma-dev', # For net:reuseport_bpf_numa
303- 'libssl-dev', # For net:tcp_mmap
304- 'netsniff-ng', # For net:altnames.sh
305- 'net-tools', # For net:rtnetlink.sh
306- 'pkg-config',
307- 'uuid-runtime', # For net:rtnetlink.sh
308- ]
309- # For net:fib_tests.sh
310- if not self.series in ['trusty', 'xenial', 'bionic']:
311- pkgs.append('socat')
312- if not self.arch == 's390x':
313- if not self.series in ['trusty', 'xenial', 'bionic', 'focal', 'jammy']:
314- # With recent kernels BPF requires lld (LLVM-based linker) to
315- # build the corresponding kernel selftests, so make sure this
316- # package is installed (in the releases where it is available)
317- # lld is not available for s390x
318- pkgs.append('lld')
319- gcc = 'gcc' if self.arch in ['ppc64le', 'aarch64', 's390x', 'riscv64'] else 'gcc-multilib'
320- pkgs.append(gcc)
321-
322- # The modules-extra is required for net:rtnetlink.sh test
323- if any(x in self.flavour for x in ['aws', 'azure', 'gcp', 'gke', 'ibm', 'oracle']):
324- if not (self.flavour == 'aws' and self.series == 'trusty'):
325- pkgs.append('linux-modules-extra-' + platform.uname()[2])
326-
327- if self.kv >= 415:
328- # extra packages for building bpf tests, which is required for some tests in net
329- pkgs.extend(['libcap-dev', 'libelf-dev'])
330- if self.kv == 504:
331- # special case for B-5.4 (lp:1882559) / B-5.3 (lp:1845860)
332- # clang on F is clang-10 but we need clang-9 (see commit 95f91d59642)
333- # clang on E is clang-9, so it's ok to just check kv here
334- pkgs.extend(['clang-9', 'llvm-9'])
335- else:
336- pkgs.extend(['clang', 'llvm'])
337-
338- cmd = 'yes "" | DEBIAN_FRONTEND=noninteractive apt-get install --yes --force-yes ' + ' '.join(pkgs)
339- utils.system_output(cmd, retain_output=True)
340-
341- def initialize(self):
342- self.arch = platform.processor()
343- self.flavour = re.split('-\d*-', platform.uname()[2])[-1]
344- try:
345- self.series = platform.dist()[2]
346- except AttributeError:
347- import distro
348- self.series = distro.codename()
349- self.kv = platform.release().split(".")[:2]
350- self.kv = int(self.kv[0]) * 100 + int(self.kv[1])
351-
352- def download(self):
353- '''Function to download kernel source.'''
354- cmd = "dpkg -S /lib/modules/" + platform.release() + "/kernel | cut -d: -f 1 | cut -d, -f 1"
355- pkg = os.popen(cmd).readlines()[0].strip()
356- utils.system("apt-get source --download-only " + pkg)
357-
358- def extract(self):
359- '''Function to extract kernel source.'''
360- os.system("rm -rf linux/")
361- utils.system("dpkg-source -x linux*dsc linux")
362-
363- def setup(self):
364- '''Function to setup the test environment.'''
365- self.install_required_pkgs()
366- self.job.require_gcc()
367- os.chdir(self.srcdir)
368-
369- # Use a local repo for manual testing. If it does not exist, then clone from the master
370- # repository.
371- #
372- if not os.path.exists('linux'):
373- self.download()
374- self.extract()
375-
376- # clean source tree so changes from debian.foo/reconstruct
377- # (e.g. deleting files) are applied
378- os.chdir('linux')
379- cmd = 'fakeroot debian/rules clean'
380- utils.system(cmd)
381- os.chdir(self.srcdir)
382-
383- # net/txtimestamp.sh is very fragile, disable it
384- #
385- fn = 'linux/tools/testing/selftests/net/Makefile'
386- if os.path.exists(fn):
387- cmd = 'sed -i "/^TEST_PROGS += txtimestamp.sh$/d" ' + fn
388- utils.system(cmd)
389-
390- # Build header first (LP: #2031400)
391- if not self.series in ['trusty', 'xenial', 'bionic', 'focal']:
392- cmd = "make -C linux/ headers"
393- utils.system_output(cmd, retain_output=True)
394-
395-
396- def run_once(self, test_name):
397- if test_name == 'setup':
398- return
399- if test_name.endswith('-build'):
400- os.chdir(self.srcdir)
401- if "net" in test_name:
402- cmds = []
403- cmds.append("sh -c 'echo 1 > /proc/sys/net/ipv4/conf/all/accept_local'")
404- # The net benchmarching tests (e.g. udpgso) can fail when
405- # optmem limit is reached.
406- # https://www.kernel.org/doc/html/latest/networking/msg_zerocopy.html#transmission
407- # LP #1960907
408- cmds.append("sh -c 'echo 2048000 > /proc/sys/net/core/optmem_max'")
409- for cmd in cmds:
410- utils.system(cmd)
411-
412- if self.kv >= 415:
413- # net selftests use a module built by bpf selftests, bpf is available since bionic kernel
414- if self.kv == 504:
415- os.environ["CLANG"] = "clang-9"
416- os.environ["LLC"] = "llc-9"
417- os.environ["LLVM_OBJCOPY"] = "llvm-objcopy-9"
418- os.environ["LLVM_READELF"] = "llvm-readelf-9"
419- cmd = "make -C linux/tools/testing/selftests TARGETS=bpf SKIP_TARGETS= KDIR=/usr/src/linux-headers-{}".format(platform.release())
420- # keep running selftests/net, even if selftests/bpf build fails
421- utils.system(cmd, ignore_status=True)
422- cmd = "make -C linux/tools/testing/selftests TARGETS={}".format(test_name.replace('-build', ''))
423- utils.system_output(cmd, retain_output=True)
424- return
425-
426- category = test_name.split(':')[0]
427- sub_test = test_name.split(':')[1]
428- dir_root = os.path.join(self.srcdir, 'linux', 'tools', 'testing', 'selftests')
429- os.chdir(dir_root)
430- cmd = "make run_tests -C {} TEST_PROGS={} TEST_GEN_PROGS='' TEST_CUSTOM_PROGS=''".format(category, sub_test)
431- result = utils.system_output(cmd, retain_output=True)
432-
433- # The output of test_bpf.sh / test_blackhole_dev.sh test will be in the dmesg
434- kernel_module_tests = {'test_bpf.sh': 'CONFIG_TEST_BPF',
435- 'test_blackhole_dev.sh': 'CONFIG_TEST_BLACKHOLE_DEV'}
436- if sub_test in kernel_module_tests.keys():
437- output = utils.system_output('dmesg', retain_output=True)
438- if not output:
439- print("Looks like there's no dmesg output, checking for {}...".format(kernel_module_tests[sub_test]))
440- cmd = "grep ^{} /boot/config-$(uname -r)".format(kernel_module_tests[sub_test])
441- if not utils.system_output(cmd, verbose=False, ignore_status=True):
442- print("{} not enabled.".format(kernel_module_tests[sub_test]))
443-
444- # Old pattern for Xenial
445- pattern = re.compile('selftests: *(?P<case>[\w\-\.]+) \[FAIL\]\n')
446- if re.search(pattern, result):
447- raise error.TestError(test_name + ' failed.')
448- # If the test was not end by previous check, check again with new pattern
449- pattern = re.compile('not ok [\d\.]* selftests: {}: {} # (?!.*SKIP)'.format(category, sub_test))
450- if re.search(pattern, result):
451- raise error.TestError(test_name + ' failed.')
452-
453-
454-# vi:set ts=4 sw=4 expandtab syntax=python:

Subscribers

People subscribed via source and target branches

to all changes: