Skip to content

Commit

Permalink
Merge pull request #2769 from AYUSHJAIN951/kselftest
Browse files Browse the repository at this point in the history
kernel/kselftest: Modify kselftest to run cpufreq testcases
  • Loading branch information
narasimhan-v authored Mar 12, 2024
2 parents 5ed5edd + 753b586 commit eb6f2aa
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
32 changes: 25 additions & 7 deletions kernel/kselftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def setUp(self):
self.test_type = self.params.get('test_type', default='-H')
self.Size_flag = self.params.get('Size', default='-s')
self.Dup_MM_Area = self.params.get('Dup_MM_Area', default='100')
if self.comp == "cpufreq":
self.test_mode = self.params.get('test_mode', default='')
self.testdir = 'tools/testing/selftests/cpufreq'

self.build_option = self.params.get('build_option', default='-bp')
self.run_type = self.params.get('type', default='upstream')
detected_distro = distro.detect()
Expand Down Expand Up @@ -116,9 +120,11 @@ def setUp(self):
if os.path.isdir(l_dir) and 'Makefile' in os.listdir(l_dir):
self.buldir = os.path.join(self.workdir, l_dir)
break
process.system("make headers -C %s" % self.buldir, shell=True, sudo=True)

self.sourcedir = os.path.join(self.buldir, self.testdir)
process.system("make install -C %s" % self.sourcedir, shell=True, sudo=True)
if self.comp != "cpufreq":
process.system("make headers -C %s" % self.buldir, shell=True, sudo=True)
process.system("make install -C %s" % self.sourcedir, shell=True, sudo=True)
else:
if self.subtest == 'pmu/event_code_tests':
self.cancel("selftest not supported on distro")
Expand Down Expand Up @@ -154,10 +160,11 @@ def setUp(self):
shell=True, sudo=True)
process.system("sed -i 's/^.*cmsg_time.sh/#&/g' %s" % make_path,
shell=True, sudo=True)
if self.comp:
build_str = '-C %s' % self.comp
if build.make(self.sourcedir, extra_args='%s' % build_str):
self.fail("Compilation failed, Please check the build logs !!")
if self.comp != "cpufreq":
if self.comp:
build_str = '-C %s' % self.comp
if build.make(self.sourcedir, extra_args='%s' % build_str):
self.fail("Compilation failed, Please check the build logs !!")

def test(self):
"""
Expand All @@ -167,6 +174,8 @@ def test(self):
kself_args = self.params.get("kself_args", default='')
if self.comp == "bpf":
self.bpf()
if self.comp == "cpufreq":
self.cpufreq()
else:
if self.subtest == "ksm_tests":
self.ksmtest()
Expand Down Expand Up @@ -197,7 +206,8 @@ def run_cmd(self, cmd):
Ex: ./ksm_tests -M
"""
try:
process.run(cmd, ignore_status=False, sudo=True)
result = process.run(cmd, ignore_status=False, sudo=True)
self.log.info(result)
except process.CmdError as details:
self.fail("Command %s failed: %s" % (cmd, details))

Expand Down Expand Up @@ -232,6 +242,14 @@ def bpf(self):
self.run_cmd("./test_verifier")
build.make(bpf_test_dir, extra_args='run_tests')

def cpufreq(self):
"""
Execute the kernel cpufreq selftests
"""
os.chdir(self.sourcedir)
cmd = "./main.sh -t " + self.test_mode
self.run_cmd(cmd)

def tearDown(self):
self.log.info('Cleaning up')
if os.path.exists(self.workdir):
Expand Down
3 changes: 3 additions & 0 deletions kernel/kselftest.py.data/kselftest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ component: !mux
kself_args: "summary=1"
mem_plug:
comp: "memory-hotplug"
cpufreq:
comp: "cpufreq"
test_mode: "basic"
run_type: !mux
distro:
type: 'distro'
Expand Down
18 changes: 18 additions & 0 deletions kernel/kselftest.py.data/kselftest_cpufreq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
component: !mux
cpufreq:
comp: "cpufreq"
test_modes: !mux
basic:
test_mode: "basic"
sptest1:
test_mode: "sptest1"
sptest2:
test_mode: "sptest2"
sptest3:
test_mode: "sptest3"
sptest4:
test_mode: "sptest4"
run_type: !mux
upstream:
type: 'upstream'
location: "https://github.com/torvalds/linux/archive/master.zip"
22 changes: 22 additions & 0 deletions kernel/kselftest.py.data/kselftest_upstream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
component: !mux
cpufreq:
comp: "cpufreq"
test_modes: !mux
basic:
test_mode: "basic"
sptest1:
test_mode: "sptest1"
sptest2:
test_mode: "sptest2"
sptest3:
test_mode: "sptest3"
sptest4:
test_mode: "sptest4"
mm:
comp: "mm"
mem_plug:
comp: "memory-hotplug"
run_type: !mux
upstream:
type: 'upstream'
location: "https://github.com/torvalds/linux/archive/master.zip"

0 comments on commit eb6f2aa

Please sign in to comment.