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

Proposed by Kevin Becker
Status: Superseded
Proposed branch: ~kevinbecker/+git/autotest-client-tests:kevinbecker/ptsematest
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Diff against target: 124 lines (+112/-0)
2 files modified
rt_tests_ptsematest/control (+19/-0)
rt_tests_ptsematest/rt_tests_ptsematest.py (+93/-0)
Reviewer Review Type Date Requested Status
Kevin Becker Pending
Review via email: mp+460964@code.launchpad.net

This proposal supersedes a proposal from 2024-02-21.

Commit message

UBUNTU: SAUCE: Add ptsematest from upstream

Signed-off-by: Kevin Becker <email address hidden>

Description of the change

Runs ptsematest and expects a max latency of 100us or less for the realtime kernel.

To post a comment you must log in.

Unmerged commits

a9b2239... by Kevin Becker

UBUNTU: SAUCE: Add ptsematest from upstream

Signed-off-by: Kevin Becker <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/rt_tests_ptsematest/control b/rt_tests_ptsematest/control
2new file mode 100644
3index 0000000..dd6bbec
4--- /dev/null
5+++ b/rt_tests_ptsematest/control
6@@ -0,0 +1,19 @@
7+AUTHOR = '''
8+Carsten Emde <C.Emde@osadl.org>
9+ '''
10+NAME = "rt_tests_ptsematest"
11+DOC = '''
12+description rt test utils
13+URL https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
14+'''
15+SUITE = "None"
16+TIME = "MEDIUM"
17+TEST_CLASS = 'kernel'
18+TEST_CATEGORY = 'Functional'
19+TEST_TYPE = 'client'
20+
21+result = job.run_test_detail('rt_tests_ptsematest', test_name='setup', tag='setup', timeout=60*5)
22+if result == 'GOOD':
23+ job.run_test('rt_tests_ptsematest', test_name='rt_tests_ptsematest', tag='rt_tests_ptsematest')
24+else:
25+ print("ERROR: test failed to build")
26diff --git a/rt_tests_ptsematest/rt_tests_ptsematest.py b/rt_tests_ptsematest/rt_tests_ptsematest.py
27new file mode 100644
28index 0000000..caa19c7
29--- /dev/null
30+++ b/rt_tests_ptsematest/rt_tests_ptsematest.py
31@@ -0,0 +1,93 @@
32+import multiprocessing
33+import os
34+import platform
35+import re
36+import shutil
37+from autotest.client import test, utils
38+from autotest.client.shared import error
39+
40+class rt_tests_ptsematest(test.test):
41+ version = 1
42+
43+ def initialize(self):
44+ self.flavour = re.split('-\d*-', platform.uname()[2])[-1]
45+ self.arch = platform.processor()
46+
47+ def install_required_pkgs(self):
48+ try:
49+ series = platform.dist()[2]
50+ except AttributeError:
51+ import distro
52+ series = distro.codename()
53+
54+ pkgs = [
55+ 'build-essential',
56+ 'git',
57+ 'libnuma-dev',
58+ ]
59+ gcc = 'gcc' if self.arch in ['ppc64le', 'aarch64', 's390x', 'riscv64'] else 'gcc-multilib'
60+ pkgs.append(gcc)
61+
62+ cmd = 'yes "" | DEBIAN_FRONTEND=noninteractive apt-get install --yes --force-yes ' + ' '.join(pkgs)
63+ self.results = utils.system_output(cmd, retain_output=True)
64+
65+ # setup
66+ #
67+ # Automatically run when there is no autotest/client/tmp/<test-suite> directory
68+ #
69+ def setup(self):
70+ self.install_required_pkgs()
71+ self.job.require_gcc()
72+ os.chdir(self.srcdir)
73+ shutil.rmtree('rt-tests', ignore_errors=True)
74+ branch = 'main'
75+ cmd = 'git clone -b {} https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git'.format(branch)
76+ utils.system_output(cmd, retain_output=True)
77+
78+ # Print test suite HEAD SHA1 commit id for future reference
79+ os.chdir(os.path.join(self.srcdir, 'rt-tests'))
80+ title_local = utils.system_output("git log --oneline -1 | sed 's/(.*)//'", retain_output=False, verbose=False)
81+ title_upstream = utils.system_output("git log --oneline | grep -v SAUCE | head -1", retain_output=False, verbose=False)
82+ print("Latest commit in '{}' branch: {}".format(branch, title_local))
83+ print("Latest upstream commit: {}".format(title_upstream))
84+
85+ try:
86+ nprocs = '-j' + str(multiprocessing.cpu_count())
87+ except:
88+ nprocs = ''
89+ utils.make(nprocs)
90+
91+
92+ # run_once
93+ #
94+ # Driven by the control file for each individual test.
95+ #
96+ # Runs ptsematest with one thread per processor, for 100000 loops, and
97+ # priority set to 80. It will fail if the max latency goes over 100us.
98+ #
99+ def run_once(self, test_name, args='-l 100000 -p 80 -S -q', exit_on_error=True):
100+ if test_name == 'setup':
101+ return
102+
103+ self.results = utils.system_output(self.srcdir + '/rt-tests/ptsematest ' + args, retain_output=True)
104+
105+ # Parse results
106+ max_values = []
107+ lines = self.results.split('\n')
108+
109+ for line in lines:
110+ components = line.split(',')
111+ for component in components:
112+ if 'Max' in component:
113+ # Extract the max latency for each thread
114+ max_value = int(component.strip().split()[-1])
115+ max_values.append(max_value)
116+
117+ # Find the highest "Max" latency
118+ highest_max = max(max_values)
119+ print("Highest Max Latency:", highest_max)
120+
121+ if highest_max > 100:
122+ raise error.TestError('FAIL: Max latency over 100us.')
123+
124+ return

Subscribers

People subscribed via source and target branches