Merge ~canonical-kernel-team/+git/autotest-client-tests:phlin/kselftest-ftrace 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: 2d05e332c887a557a4cacb19bc4ae97d20eccb41
Proposed branch: ~canonical-kernel-team/+git/autotest-client-tests:phlin/kselftest-ftrace
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Diff against target: 220 lines (+190/-0)
5 files modified
ubuntu_kselftests_ftrace/blacklist.trusty (+1/-0)
ubuntu_kselftests_ftrace/blacklist.xenial (+2/-0)
ubuntu_kselftests_ftrace/control (+68/-0)
ubuntu_kselftests_ftrace/helper.mk (+5/-0)
ubuntu_kselftests_ftrace/ubuntu_kernel_selftests.py (+114/-0)
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Andrei Gherzan Approve
Review via email: mp+443340@code.launchpad.net

Commit message

ftrace test sometimes will hang and make ubuntu_kernel_selftests ended
up in an incomplete state.

Split it out to improve the test granularity and flexibility and thus
make it easier to debug.

The ftrace test in ubuntu_kernel_selftests is not removed in this
commit, it will be removed after everything is in place and we have
test results coming out from this newly added ubuntu_kselftests_ftrace
test.

Description of the change

Test split to ubuntu_kselftest_ftrace, ran a quick test on X (although it's blacklisted on X), B, F, J, K. The test can be build and run without any issue.

To post a comment you must log in.
Revision history for this message
Andrei Gherzan (agherzan) wrote :

+1

review: Approve
Revision history for this message
Francis Ginther (fginther) :
review: Approve
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Applied and pushed, thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ubuntu_kselftests_ftrace/blacklist.trusty b/ubuntu_kselftests_ftrace/blacklist.trusty
2new file mode 100644
3index 0000000..41196ed
4--- /dev/null
5+++ b/ubuntu_kselftests_ftrace/blacklist.trusty
6@@ -0,0 +1 @@
7+Blacklisted as we don't have ftrace test in Trusty
8diff --git a/ubuntu_kselftests_ftrace/blacklist.xenial b/ubuntu_kselftests_ftrace/blacklist.xenial
9new file mode 100644
10index 0000000..022473f
11--- /dev/null
12+++ b/ubuntu_kselftests_ftrace/blacklist.xenial
13@@ -0,0 +1,2 @@
14+Blacklisted as in ubuntu_kernel_selftests we don't run ftrace test on Xenial
15+see ubuntu_kernel_selftests/control.ubuntu.xenial
16diff --git a/ubuntu_kselftests_ftrace/control b/ubuntu_kselftests_ftrace/control
17new file mode 100644
18index 0000000..e64acbd
19--- /dev/null
20+++ b/ubuntu_kselftests_ftrace/control
21@@ -0,0 +1,68 @@
22+AUTHOR = "Ubuntu"
23+NAME = 'ubuntu_kernel_selftests'
24+CRITERIA = """
25+Uses built-in kernel repository self tests for ftrace.
26+"""
27+SUITE = "None"
28+TIME = "SHORT"
29+TEST_CLASS = 'kernel'
30+TEST_CATEGORY = 'Functional'
31+TEST_TYPE = "client"
32+DOC = ""
33+
34+
35+categories = ['ftrace']
36+arch = platform.machine()
37+arch_scale = 1
38+# Scale timeouts by 2 for riscv64, some tests timeout due to lack of
39+# timeout, despite progressing fine
40+if arch in ['riscv64']:
41+ arch_scale = 2
42+
43+result = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=arch_scale*60*45)
44+if result == 'GOOD':
45+ for category in categories:
46+ build = '{}-build'.format(category)
47+ result = job.run_test_detail(NAME, test_name=build, tag=build, timeout=arch_scale*60*60)
48+ if result == 'ERROR':
49+ print("ERROR: test suite '{}' failed to build, skipping all the sub tests".format(category))
50+ continue
51+ mk_helper = os.path.join(job.testdir, NAME, 'helper.mk')
52+ dir_root = os.path.join(job.bindir, 'tmp', NAME, 'src', 'linux/tools/testing/selftests/')
53+ dir_src = os.path.join(dir_root, category)
54+ mk_src = os.path.join(dir_src, 'Makefile')
55+ os.chdir(dir_src)
56+ cmd = 'grep SUB_DIRS {}'.format(mk_src)
57+ timeout_threshold = arch_scale*60*30
58+ if utils.system_output(cmd, verbose=False, ignore_status=True):
59+ cmd = 'make -f {} -f {} getsubdirs'.format(mk_helper, mk_src)
60+ subdirs = utils.system_output(cmd).split()
61+ for subdir in subdirs:
62+ dir_src = os.path.join(dir_root, category, subdir)
63+ os.chdir(dir_src)
64+ mk_src = os.path.join(dir_src, 'Makefile')
65+ if os.path.isfile(mk_src):
66+ cmd = 'make -f {} -f {} gettests'.format(mk_src, mk_helper)
67+ tests = utils.system_output(cmd).split()
68+ for item in tests:
69+ test = "{}/{}:{}".format(category, subdir, item)
70+ job.run_test_detail(NAME, test_name=test, tag=test, timeout=timeout_threshold)
71+ elif os.path.isfile(mk_src):
72+ cmd = 'make -f {} -f {} gettests'.format(mk_src, mk_helper)
73+ tests = utils.system_output(cmd).split()
74+ for item in tests:
75+ timeout_threshold = arch_scale*60*45
76+ if item == 'ftracetest':
77+ if arch == 'riscv64':
78+ # autotest timeout on riscv64 is incorrect (lp:1940080), disable it
79+ # It takes about 22 mins on 5.15 and about 35 mins on 5.13
80+ timeout_threshold = 0
81+ else:
82+ # ftracetest will take about ~60 minutes to run on some instances (lp:2008063)
83+ timeout_threshold = 60 * 75
84+ test = "{}:{}".format(category, item)
85+ job.run_test_detail(NAME, test_name=test, tag=test, timeout=timeout_threshold)
86+ else:
87+ print("ERROR: test failed to build, skipping all the sub tests")
88+
89+# vi:set ts=4 sw=4 expandtab syntax=python:
90diff --git a/ubuntu_kselftests_ftrace/helper.mk b/ubuntu_kselftests_ftrace/helper.mk
91new file mode 100755
92index 0000000..ab3bb36
93--- /dev/null
94+++ b/ubuntu_kselftests_ftrace/helper.mk
95@@ -0,0 +1,5 @@
96+gettests:
97+ @echo '$(notdir $(TEST_GEN_PROGS)) $(notdir $(TEST_CUSTOM_PROGS)) $(notdir $(TEST_PROGS))'
98+
99+getsubdirs:
100+ @echo '$(SUB_DIRS)'
101diff --git a/ubuntu_kselftests_ftrace/ubuntu_kernel_selftests.py b/ubuntu_kselftests_ftrace/ubuntu_kernel_selftests.py
102new file mode 100644
103index 0000000..742fbde
104--- /dev/null
105+++ b/ubuntu_kselftests_ftrace/ubuntu_kernel_selftests.py
106@@ -0,0 +1,114 @@
107+#
108+#
109+import os
110+import platform
111+import re
112+from autotest.client import test, utils
113+from autotest.client.shared import error
114+
115+class ubuntu_kernel_selftests(test.test):
116+ version = 1
117+
118+ def install_required_pkgs(self):
119+ '''Function to install necessary packages.'''
120+ pkgs = [
121+ 'debhelper',
122+ 'dpkg-dev',
123+ 'git',
124+ ]
125+ gcc = 'gcc' if self.arch in ['ppc64le', 'aarch64', 's390x', 'riscv64'] else 'gcc-multilib'
126+ pkgs.append(gcc)
127+
128+ cmd = 'yes "" | DEBIAN_FRONTEND=noninteractive apt-get install --yes --force-yes ' + ' '.join(pkgs)
129+ utils.system_output(cmd, retain_output=True)
130+
131+ def initialize(self):
132+ self.arch = platform.processor()
133+ self.flavour = re.split('-\d*-', platform.uname()[2])[-1]
134+ try:
135+ self.series = platform.dist()[2]
136+ except AttributeError:
137+ import distro
138+ self.series = distro.codename()
139+ self.kv = platform.release().split(".")[:2]
140+ self.kv = int(self.kv[0]) * 100 + int(self.kv[1])
141+
142+ def download(self):
143+ '''Function to download kernel source.'''
144+ cmd = "dpkg -S /lib/modules/" + platform.release() + "/kernel | cut -d: -f 1 | cut -d, -f 1"
145+ pkg = os.popen(cmd).readlines()[0].strip()
146+ utils.system("apt-get source --download-only " + pkg)
147+
148+ def extract(self):
149+ '''Function to extract kernel source.'''
150+ os.system("rm -rf linux/")
151+ utils.system("dpkg-source -x linux*dsc linux")
152+
153+ def setup(self):
154+ '''Function to setup the test environment.'''
155+ self.install_required_pkgs()
156+ self.job.require_gcc()
157+ os.chdir(self.srcdir)
158+
159+ # Use a local repo for manual testing. If it does not exist, then clone from the master
160+ # repository.
161+ #
162+ if not os.path.exists('linux'):
163+ self.download()
164+ self.extract()
165+
166+ # clean source tree so changes from debian.foo/reconstruct
167+ # (e.g. deleting files) are applied
168+ os.chdir('linux')
169+ cmd = 'fakeroot debian/rules clean'
170+ utils.system(cmd)
171+ os.chdir(self.srcdir)
172+
173+ #
174+ # Disable new ftrace tests that don't work reliably across
175+ # architectures because of various symbols being checked
176+ #
177+ filenames = [
178+ 'ftrace/func_stack_tracer.tc',
179+ 'ftrace/func-filter-glob.tc',
180+ 'trigger/inter-event/trigger-inter-event-combined-hist.tc',
181+ 'trigger/inter-event/trigger-synthetic-event-createremove.tc',
182+ 'trigger/trigger-hist.tc',
183+ 'trigger/trigger-trace-marker-hist.tc',
184+ 'kprobe/probepoint.tc',
185+ 'kprobe/kprobe_module.tc',
186+ ]
187+
188+ for fn in filenames:
189+ fn = 'linux/tools/testing/selftests/ftrace/test.d/' + fn
190+ if os.path.exists(fn):
191+ os.remove(fn)
192+
193+
194+ def run_once(self, test_name):
195+ if test_name == 'setup':
196+ return
197+ if test_name.endswith('-build'):
198+ os.chdir(self.srcdir)
199+ cmd = "make -C linux/tools/testing/selftests TARGETS={}".format(test_name.replace('-build', ''))
200+ utils.system_output(cmd, retain_output=True)
201+ return
202+
203+ category = test_name.split(':')[0]
204+ sub_test = test_name.split(':')[1]
205+ dir_root = os.path.join(self.srcdir, 'linux', 'tools', 'testing', 'selftests')
206+ os.chdir(dir_root)
207+ cmd = "make run_tests -C {} TEST_PROGS={} TEST_GEN_PROGS='' TEST_CUSTOM_PROGS=''".format(category, sub_test)
208+ result = utils.system_output(cmd, retain_output=True)
209+
210+ # Old pattern for Xenial
211+ pattern = re.compile('selftests: *(?P<case>[\w\-\.]+) \[FAIL\]\n')
212+ if re.search(pattern, result):
213+ raise error.TestError(test_name + ' failed.')
214+ # If the test was not end by previous check, check again with new pattern
215+ pattern = re.compile('not ok [\d\.]* selftests: {}: {} # (?!.*SKIP)'.format(category, sub_test))
216+ if re.search(pattern, result):
217+ raise error.TestError(test_name + ' failed.')
218+
219+
220+# vi:set ts=4 sw=4 expandtab syntax=python:

Subscribers

People subscribed via source and target branches

to all changes: