diff mbox series

[V6,3/4] selftests: amd-pstate: Add test trigger for amd-pstate driver

Message ID 20220519134737.359290-4-li.meng@amd.com
State New
Headers show
Series Add unit test module for AMD P-State driver | expand

Commit Message

Meng, Li (Jassmine) May 19, 2022, 1:47 p.m. UTC
Add amd-pstate test trigger in kselftest, it will load/unload
amd-pstate-ut module to test some cases etc.

Signed-off-by: Meng Li <li.meng@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
---
 tools/testing/selftests/Makefile              |  1 +
 tools/testing/selftests/amd-pstate/Makefile   |  8 +++++
 .../selftests/amd-pstate/amd-pstate-ut.sh     | 34 +++++++++++++++++++
 tools/testing/selftests/amd-pstate/config     |  1 +
 4 files changed, 44 insertions(+)
 create mode 100644 tools/testing/selftests/amd-pstate/Makefile
 create mode 100755 tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
 create mode 100644 tools/testing/selftests/amd-pstate/config

Comments

Shuah Khan May 19, 2022, 7:50 p.m. UTC | #1
On 5/19/22 7:47 AM, Meng Li wrote:
> Add amd-pstate test trigger in kselftest, it will load/unload
> amd-pstate-ut module to test some cases etc.
> 
> Signed-off-by: Meng Li <li.meng@amd.com>
> Acked-by: Huang Rui <ray.huang@amd.com>
> ---
>   tools/testing/selftests/Makefile              |  1 +
>   tools/testing/selftests/amd-pstate/Makefile   |  8 +++++
>   .../selftests/amd-pstate/amd-pstate-ut.sh     | 34 +++++++++++++++++++
>   tools/testing/selftests/amd-pstate/config     |  1 +
>   4 files changed, 44 insertions(+)
>   create mode 100644 tools/testing/selftests/amd-pstate/Makefile
>   create mode 100755 tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
>   create mode 100644 tools/testing/selftests/amd-pstate/config
> 
> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index 2319ec87f53d..975c13368286 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -1,5 +1,6 @@
>   # SPDX-License-Identifier: GPL-2.0
>   TARGETS += alsa
> +TARGETS += amd-pstate
>   TARGETS += arm64
>   TARGETS += bpf
>   TARGETS += breakpoints
> diff --git a/tools/testing/selftests/amd-pstate/Makefile b/tools/testing/selftests/amd-pstate/Makefile
> new file mode 100644
> index 000000000000..e1432112fb70
> --- /dev/null
> +++ b/tools/testing/selftests/amd-pstate/Makefile
> @@ -0,0 +1,8 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +# Makefile for amd-pstate/ function selftests
> +
> +TEST_PROGS := amd-pstate-ut.sh
> +
> +include ../lib.mk
> +
> +$(TEST_GEN_FILES): $(HEADERS)

Do you still need this?

> diff --git a/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh b/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
> new file mode 100755
> index 000000000000..970f7a76c7d5
> --- /dev/null
> +++ b/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
> @@ -0,0 +1,34 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# amd-pstate-ut is a test module for testing the amd-pstate driver.
> +# (1) It can help all users to verify their processor support
> +# (SBIOS/Firmware or Hardware).
> +# (2) Kernel can have a basic function test to avoid the kernel
> +# regression during the update.
> +# (3) We can introduce more functional or performance tests to align
> +# the result together, it will benefit power and performance scale optimization.
> +
> +# Kselftest framework requirement - SKIP code is 4.
> +ksft_skip=4
> +
> +if ! uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ | grep -q x86; then

This can be simpler - see prctl/Makefile or other tests that do arch
checks. Also does this test run on non-amd x86_64 systems?

> +	echo "$0 # Skipped: Test can only run on x86 architectures."

All x86 or x86_64 AMD systems? Does this run on Intel systems?

> +	exit $ksft_skip
> +fi
> +
> +msg="Skip all tests:"
> +if [ ! -w /dev ]; then
> +    echo $msg please run this as root >&2
> +    exit $ksft_skip
> +fi
> +
> +scaling_driver=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver)
> +
> +if [ "$scaling_driver" != "amd-pstate" ]; then
> +	echo "$0 # Skipped: Test can only run on amd-pstate driver."
> +	echo "$0 # Current cpufreq scaling drvier is $scaling_driver."
> +	exit $ksft_skip
> +fi
> +
> +$(dirname $0)/../kselftest/module.sh "amd-pstate-ut" amd-pstate-ut

What does this do?

Has this script been updated after moving the module to drivers/cpufreq?
Also doesn't this script need to to load the amd_pstate_ut module?

Please take a look at user/test_user_copy.sh for example on modprobe
checks and appropriate test exit codes

> diff --git a/tools/testing/selftests/amd-pstate/config b/tools/testing/selftests/amd-pstate/config
> new file mode 100644
> index 000000000000..f43103c9adc4
> --- /dev/null
> +++ b/tools/testing/selftests/amd-pstate/config
> @@ -0,0 +1 @@
> +CONFIG_X86_AMD_PSTATE_UT=m
> 

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 2319ec87f53d..975c13368286 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -1,5 +1,6 @@ 
 # SPDX-License-Identifier: GPL-2.0
 TARGETS += alsa
+TARGETS += amd-pstate
 TARGETS += arm64
 TARGETS += bpf
 TARGETS += breakpoints
diff --git a/tools/testing/selftests/amd-pstate/Makefile b/tools/testing/selftests/amd-pstate/Makefile
new file mode 100644
index 000000000000..e1432112fb70
--- /dev/null
+++ b/tools/testing/selftests/amd-pstate/Makefile
@@ -0,0 +1,8 @@ 
+# SPDX-License-Identifier: GPL-2.0-only
+# Makefile for amd-pstate/ function selftests
+
+TEST_PROGS := amd-pstate-ut.sh
+
+include ../lib.mk
+
+$(TEST_GEN_FILES): $(HEADERS)
diff --git a/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh b/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
new file mode 100755
index 000000000000..970f7a76c7d5
--- /dev/null
+++ b/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
@@ -0,0 +1,34 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+# amd-pstate-ut is a test module for testing the amd-pstate driver.
+# (1) It can help all users to verify their processor support
+# (SBIOS/Firmware or Hardware).
+# (2) Kernel can have a basic function test to avoid the kernel
+# regression during the update.
+# (3) We can introduce more functional or performance tests to align
+# the result together, it will benefit power and performance scale optimization.
+
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
+if ! uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ | grep -q x86; then
+	echo "$0 # Skipped: Test can only run on x86 architectures."
+	exit $ksft_skip
+fi
+
+msg="Skip all tests:"
+if [ ! -w /dev ]; then
+    echo $msg please run this as root >&2
+    exit $ksft_skip
+fi
+
+scaling_driver=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver)
+
+if [ "$scaling_driver" != "amd-pstate" ]; then
+	echo "$0 # Skipped: Test can only run on amd-pstate driver."
+	echo "$0 # Current cpufreq scaling drvier is $scaling_driver."
+	exit $ksft_skip
+fi
+
+$(dirname $0)/../kselftest/module.sh "amd-pstate-ut" amd-pstate-ut
diff --git a/tools/testing/selftests/amd-pstate/config b/tools/testing/selftests/amd-pstate/config
new file mode 100644
index 000000000000..f43103c9adc4
--- /dev/null
+++ b/tools/testing/selftests/amd-pstate/config
@@ -0,0 +1 @@ 
+CONFIG_X86_AMD_PSTATE_UT=m