Merge ~canonical-kernel-team/+git/autotest-client-tests:WIP into ~canonical-kernel-team/+git/autotest-client-tests:master

Proposed by Po-Hsu Lin
Status: Merged
Approved by: Po-Hsu Lin
Approved revision: 90ae0262ebf88d7701d82a7ee7cd3a7976e0b6ba
Merge reported by: Po-Hsu Lin
Merged at revision: 90ae0262ebf88d7701d82a7ee7cd3a7976e0b6ba
Proposed branch: ~canonical-kernel-team/+git/autotest-client-tests:WIP
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Diff against target: 208 lines (+166/-1)
6 files modified
ubuntu_ltp/control (+1/-1)
ubuntu_ltp_cve/blacklist.precise (+1/-0)
ubuntu_ltp_cve/blacklist.trusty (+1/-0)
ubuntu_ltp_cve/blacklist.xenial (+1/-0)
ubuntu_ltp_cve/control (+27/-0)
ubuntu_ltp_cve/ubuntu_ltp_cve.py (+135/-0)
Reviewer Review Type Date Requested Status
Canonical Kernel Team Pending
Review via email: mp+428026@code.launchpad.net

Commit message

BugLink: https://bugs.launchpad.net/bugs/1983666

Some of the CVE tests will check the kernel taint flag to determine if
the test pass or not.

So if some other test failed before the CVE subset, like the
read_all_sys in the fs subset (bug 1973153), it will cause
false-positive failures.

It can also reduce the ubuntu_ltp execution time, avoid test being
killed by the 4hrs jenkins timeout threshold. Another benefit to pull
this out is that we can have more flexibility to select what we want
to test.

The downside is the time cost for one extra deployment for this job.

Description of the change

Patch tested with a KVM instance with Focal 5.4

The test will take about 30 minutes to run on it.

This change should be applied along with the change for CKCT.

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

It's a good timing to push this out.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ubuntu_ltp/control b/ubuntu_ltp/control
2index 4a63f0e..25d70a2 100644
3--- a/ubuntu_ltp/control
4+++ b/ubuntu_ltp/control
5@@ -16,7 +16,7 @@ if result == 'ERROR':
6 else:
7 categories = [
8 'fs', 'mm', 'irq', 'sched', 'pty',
9- 'cpuhotplug', 'cve', 'crypto', 'uevent'
10+ 'cpuhotplug', 'crypto', 'uevent'
11 ]
12 blacklist = ['oom01', 'oom02', 'oom03', 'oom04' ,'oom05', 'mkswap01_sh'] # oom* (lp:1847963), mkswap01_sh (lp:1830584)
13 for category in categories:
14diff --git a/ubuntu_ltp_cve/blacklist.precise b/ubuntu_ltp_cve/blacklist.precise
15new file mode 100644
16index 0000000..27ba77d
17--- /dev/null
18+++ b/ubuntu_ltp_cve/blacklist.precise
19@@ -0,0 +1 @@
20+true
21diff --git a/ubuntu_ltp_cve/blacklist.trusty b/ubuntu_ltp_cve/blacklist.trusty
22new file mode 100644
23index 0000000..27ba77d
24--- /dev/null
25+++ b/ubuntu_ltp_cve/blacklist.trusty
26@@ -0,0 +1 @@
27+true
28diff --git a/ubuntu_ltp_cve/blacklist.xenial b/ubuntu_ltp_cve/blacklist.xenial
29new file mode 100644
30index 0000000..27ba77d
31--- /dev/null
32+++ b/ubuntu_ltp_cve/blacklist.xenial
33@@ -0,0 +1 @@
34+true
35diff --git a/ubuntu_ltp_cve/control b/ubuntu_ltp_cve/control
36new file mode 100644
37index 0000000..1e094cf
38--- /dev/null
39+++ b/ubuntu_ltp_cve/control
40@@ -0,0 +1,27 @@
41+AUTHOR = "Ubuntu"
42+NAME = "ubuntu_ltp_cve"
43+CRITERIA = """
44+Use the upstream LTP repository
45+"""
46+SUITE = "None"
47+TIME = "MEDIUM"
48+TEST_CLASS = 'kernel'
49+TEST_CATEGORY = 'Functional'
50+TEST_TYPE = "client"
51+DOC = ""
52+
53+result = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=40*60)
54+if result == 'ERROR':
55+ print("ERROR: test failed to build, skipping all the sub tests")
56+else:
57+ fn = '/opt/ltp/runtest/cve'
58+ with open(fn , 'r') as f:
59+ for line in f:
60+ if line.strip() and not line.startswith('#'):
61+ with open ('/tmp/target' , 'w') as t:
62+ t.write(line)
63+ testcase = line.split()[0]
64+ timeout_threshold = 60*30
65+ job.run_test_detail(NAME, test_name=testcase, tag=testcase, timeout=timeout_threshold)
66+
67+# vi:set ts=4 sw=4 expandtab syntax=python:
68diff --git a/ubuntu_ltp_cve/ubuntu_ltp_cve.py b/ubuntu_ltp_cve/ubuntu_ltp_cve.py
69new file mode 100644
70index 0000000..3647578
71--- /dev/null
72+++ b/ubuntu_ltp_cve/ubuntu_ltp_cve.py
73@@ -0,0 +1,135 @@
74+#
75+#
76+import multiprocessing
77+import os
78+import platform
79+import re
80+import shutil
81+from autotest.client import test, utils
82+
83+class ubuntu_ltp_cve(test.test):
84+ version = 1
85+
86+ def install_required_pkgs(self):
87+ try:
88+ series = platform.dist()[2]
89+ except AttributeError:
90+ import distro
91+ series = distro.codename()
92+
93+ pkgs = [
94+ 'automake',
95+ 'bison',
96+ 'build-essential',
97+ 'byacc',
98+ 'flex',
99+ 'git',
100+ 'keyutils',
101+ 'libacl1-dev',
102+ 'libaio-dev',
103+ 'libcap-dev',
104+ 'libmm-dev',
105+ 'libnuma-dev',
106+ 'libsctp-dev',
107+ 'libselinux1-dev',
108+ 'libssl-dev',
109+ 'libtirpc-dev',
110+ 'pkg-config',
111+ 'quota',
112+ 'xfslibs-dev',
113+ 'xfsprogs',
114+ ]
115+ gcc = 'gcc' if self.arch in ['ppc64le', 'aarch64', 's390x', 'riscv64'] else 'gcc-multilib'
116+ pkgs.append(gcc)
117+
118+ if any(x in self.flavour for x in ['aws', 'azure', 'gcp', 'gke']):
119+ pkgs.append('linux-modules-extra-' + platform.uname()[2])
120+
121+ cmd = 'yes "" | DEBIAN_FRONTEND=noninteractive apt-get install --yes --force-yes ' + ' '.join(pkgs)
122+ self.results = utils.system_output(cmd, retain_output=True)
123+
124+ def initialize(self):
125+ self.flavour = re.split('-\d*-', platform.uname()[2])[-1]
126+ self.arch = platform.processor()
127+
128+ # setup
129+ #
130+ # Automatically run when there is no autotest/client/tmp/<test-suite> directory
131+ #
132+ def setup(self):
133+ self.install_required_pkgs()
134+ self.job.require_gcc()
135+ os.chdir(self.srcdir)
136+ shutil.rmtree('ltp', ignore_errors=True)
137+ branch = 'sru'
138+ cmd = 'git clone -b {} git://git.launchpad.net/~canonical-kernel-team/+git/ltp'.format(branch)
139+ utils.system_output(cmd, retain_output=True)
140+
141+ # Print test suite HEAD SHA1 commit id for future reference
142+ os.chdir(os.path.join(self.srcdir, 'ltp'))
143+ title_local = utils.system_output("git log --oneline -1 | sed 's/(.*)//'", retain_output=False, verbose=False)
144+ title_upstream = utils.system_output("git log --oneline | grep -v SAUCE | head -1", retain_output=False, verbose=False)
145+ print("Latest commit in '{}' branch: {}".format(branch, title_local))
146+ print("Latest upstream commit: {}".format(title_upstream))
147+
148+ # Disable NTFS as we disable RW support
149+ cmd = 'sed -i /ntfs/d lib/tst_supported_fs_types.c'
150+ utils.system_output(cmd)
151+
152+ utils.make('autotools')
153+ utils.configure()
154+ try:
155+ nprocs = '-j' + str(multiprocessing.cpu_count())
156+ except:
157+ nprocs = ''
158+ utils.make(nprocs)
159+ utils.make('install')
160+
161+
162+ # run_once
163+ #
164+ # Driven by the control file for each individual test.
165+ #
166+ def run_once(self, test_name):
167+ if test_name == 'setup':
168+ return
169+
170+ # PHLin - LTP 20220527, most of the default timeout is now just 30 seconds instead of 5 mins, mulitplier must be modified
171+ LTP_TIMEOUT_MUL = '50'
172+
173+ if test_name == 'zram01':
174+ print("Setting LTP_TIMEOUT_MUL={} for zram01 test (lp:1897556)".format(LTP_TIMEOUT_MUL))
175+ os.environ["LTP_TIMEOUT_MUL"] = LTP_TIMEOUT_MUL
176+ elif test_name in ['cve-2018-1000204', 'ioctl_sg01']:
177+ print("Setting LTP_TIMEOUT_MUL={} for cve-2018-1000204 / ioctl_sg01 (lp:1899413, lp:1936886, lp:1949934, lp:1955629)".format(LTP_TIMEOUT_MUL))
178+ os.environ["LTP_TIMEOUT_MUL"] = LTP_TIMEOUT_MUL
179+ elif test_name == 'cve-2017-5754':
180+ print("Setting LTP_TIMEOUT_MUL={} for cve-2017-5754 (lp:1981780)".format(LTP_TIMEOUT_MUL))
181+ os.environ["LTP_TIMEOUT_MUL"] = LTP_TIMEOUT_MUL
182+ elif test_name in ['cve-2017-15299', 'cve-2017-15951']:
183+ print("Setting LTP_TIMEOUT_MUL={} for cve-2017-15299 / cve-2017-15951 (lp:1983299)")
184+ os.environ["LTP_TIMEOUT_MUL"] = LTP_TIMEOUT_MUL
185+ elif test_name == 'fs_fill':
186+ print("Setting LTP_TIMEOUT_MUL={} for fs_fill".format(LTP_TIMEOUT_MUL))
187+ os.environ["LTP_TIMEOUT_MUL"] = LTP_TIMEOUT_MUL
188+ elif test_name == 'read_all_proc':
189+ print("Setting LTP_TIMEOUT_MUL={} for read_all_proc".format(LTP_TIMEOUT_MUL))
190+ os.environ["LTP_TIMEOUT_MUL"] = LTP_TIMEOUT_MUL
191+ elif test_name == 'read_all_sys':
192+ print("Setting LTP_TIMEOUT_MUL={} for read_all_sys".format(LTP_TIMEOUT_MUL))
193+ os.environ["LTP_TIMEOUT_MUL"] = LTP_TIMEOUT_MUL
194+
195+ cmd = '/opt/ltp/runltp -f /tmp/target -q -C /dev/null -l /dev/null -T /dev/null'
196+ print(utils.system_output(cmd, verbose=False))
197+ # /dev/loop# creation will be taken care by the runltp
198+
199+ def cleanup(self, test_name):
200+ if test_name == 'setup':
201+ return
202+
203+ # Restore the timeout multiplier
204+ if 'LTP_TIMEOUT_MUL' in os.environ:
205+ print("Restore timeout multiplier LTP_TIMEOUT_MUL back to default")
206+ del os.environ["LTP_TIMEOUT_MUL"]
207+
208+# vi:set ts=4 sw=4 expandtab syntax=python:

Subscribers

People subscribed via source and target branches

to all changes: