diff options
author | Meng Li <li.meng@amd.com> | 2022-10-31 11:49:21 +0300 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2022-11-01 12:20:58 +0300 |
commit | e5df326817e97799fda8add1c0f486f3539d238c (patch) | |
tree | 098a72d431286a5cca4ecb61924b83069a4ae688 /tools/testing/selftests/amd-pstate/basic.sh | |
parent | a2fa60ee7cb83d3054a896208da77f06359186a6 (diff) | |
download | linux-e5df326817e97799fda8add1c0f486f3539d238c.tar.xz |
selftests: amd-pstate: Split basic.sh into run.sh and basic.sh.
Split basic.sh into run.sh and basic.sh.
The modification makes basic.sh more pure, just for test basic kernel
functions. The file of run.sh mainly contains functions such as test
entry, parameter check, prerequisite and log clearing etc.
Then you can specify test case in kselftest/amd-pstate, for example:
sudo ./run.sh -c basic. The detail please run the below script.
./run.sh --help
Signed-off-by: Meng Li <li.meng@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/amd-pstate/basic.sh')
-rwxr-xr-x | tools/testing/selftests/amd-pstate/basic.sh | 64 |
1 files changed, 23 insertions, 41 deletions
diff --git a/tools/testing/selftests/amd-pstate/basic.sh b/tools/testing/selftests/amd-pstate/basic.sh index f8e82d91ffcf..e4c43193e4a3 100755 --- a/tools/testing/selftests/amd-pstate/basic.sh +++ b/tools/testing/selftests/amd-pstate/basic.sh @@ -11,46 +11,28 @@ # (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 - -# amd-pstate-ut only run on x86/x86_64 AMD systems. -ARCH=$(uname -m 2>/dev/null | sed -e 's/i.86/x86/' -e 's/x86_64/x86/') -VENDOR=$(cat /proc/cpuinfo | grep -m 1 'vendor_id' | awk '{print $NF}') - -if ! echo "$ARCH" | grep -q x86; then - echo "$0 # Skipped: Test can only run on x86 architectures." - exit $ksft_skip -fi - -if ! echo "$VENDOR" | grep -iq amd; then - echo "$0 # Skipped: Test can only run on AMD CPU." - echo "$0 # Current cpu vendor is $VENDOR." - 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 # Please set X86_AMD_PSTATE enabled." - echo "$0 # Current cpufreq scaling drvier is $scaling_driver." - exit $ksft_skip -fi - -msg="Skip all tests:" -if [ ! -w /dev ]; then - echo $msg please run this as root >&2 - exit $ksft_skip -fi - -if ! /sbin/modprobe -q -n amd-pstate-ut; then - echo "amd-pstate-ut: module amd-pstate-ut is not found [SKIP]" - exit $ksft_skip -fi -if /sbin/modprobe -q amd-pstate-ut; then - /sbin/modprobe -q -r amd-pstate-ut - echo "amd-pstate-ut: ok" +# protect against multiple inclusion +if [ $FILE_BASIC ]; then + return 0 else - echo "amd-pstate-ut: [FAIL]" - exit 1 + FILE_BASIC=DONE fi + +amd_pstate_basic() +{ + printf "\n---------------------------------------------\n" + printf "*** Running AMD P-state ut ***" + printf "\n---------------------------------------------\n" + + if ! /sbin/modprobe -q -n amd-pstate-ut; then + echo "amd-pstate-ut: module amd-pstate-ut is not found [SKIP]" + exit $ksft_skip + fi + if /sbin/modprobe -q amd-pstate-ut; then + /sbin/modprobe -q -r amd-pstate-ut + echo "amd-pstate-basic: ok" + else + echo "amd-pstate-basic: [FAIL]" + exit 1 + fi +} |