From 60bdc3e4e06faa9039cc533b36208c6869e4b15d Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Mon, 11 Mar 2024 10:19:01 +0530 Subject: [PATCH 1/2] Add cpufreq test with kselftest misc runner Modify kselftest.py to run upstream cpufreq testcase Adding kselftest_cpufreq.yaml and modified kselftest.yaml to run with basic mode of cpufreq.yaml. Signed-off-by: Ayush Jain --- kernel/kselftest.py | 32 +++++++++++++++---- kernel/kselftest.py.data/kselftest.yaml | 3 ++ .../kselftest.py.data/kselftest_cpufreq.yaml | 18 +++++++++++ 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 kernel/kselftest.py.data/kselftest_cpufreq.yaml diff --git a/kernel/kselftest.py b/kernel/kselftest.py index fc07984b6..410967821 100644 --- a/kernel/kselftest.py +++ b/kernel/kselftest.py @@ -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() @@ -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") @@ -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): """ @@ -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() @@ -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)) @@ -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): diff --git a/kernel/kselftest.py.data/kselftest.yaml b/kernel/kselftest.py.data/kselftest.yaml index a90385df6..a68932314 100644 --- a/kernel/kselftest.py.data/kselftest.yaml +++ b/kernel/kselftest.py.data/kselftest.yaml @@ -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' diff --git a/kernel/kselftest.py.data/kselftest_cpufreq.yaml b/kernel/kselftest.py.data/kselftest_cpufreq.yaml new file mode 100644 index 000000000..e73b788a3 --- /dev/null +++ b/kernel/kselftest.py.data/kselftest_cpufreq.yaml @@ -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" From 753b58683d6059043bcde4578b8c64f35ab94d0f Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Mon, 11 Mar 2024 10:20:03 +0530 Subject: [PATCH 2/2] Add kselftest_upstream.yaml Tests to run with upstream kernel only. Signed-off-by: Ayush Jain --- .../kselftest.py.data/kselftest_upstream.yaml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 kernel/kselftest.py.data/kselftest_upstream.yaml diff --git a/kernel/kselftest.py.data/kselftest_upstream.yaml b/kernel/kselftest.py.data/kselftest_upstream.yaml new file mode 100644 index 000000000..fe37ace30 --- /dev/null +++ b/kernel/kselftest.py.data/kselftest_upstream.yaml @@ -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"