2018-05-26 17:02:46

by Jeffrin Jose T

[permalink] [raw]
Subject: [PATCH] selftests: intel_pstate: notification about privilege required to run intel_pstate testing script

The intel_pstate related testing script need root level privileges
when trying to access certain file for the successful execution of
the script.But this is not the case always like when using evaluation
only mode, which only require user level privilege.

This patch is to notify the user about the privilege the script
demands for the successful execution of the test.

Signed-off-by: Jeffrin Jose T (Rajagiri SET) <[email protected]>
---
tools/testing/selftests/intel_pstate/run.sh | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/intel_pstate/run.sh b/tools/testing/selftests/intel_pstate/run.sh
index 6ded61670f6d..4ddd389c2cb9 100755
--- a/tools/testing/selftests/intel_pstate/run.sh
+++ b/tools/testing/selftests/intel_pstate/run.sh
@@ -33,6 +33,12 @@ EVALUATE_ONLY=0
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

+msg="skip all tests:"
+if [ $UID != 0 ] && [ $EVALUATE_ONLY == 0 ]; then
+ echo $msg please run this as root >&2
+ exit $ksft_skip
+fi
+
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
--
2.17.0



2018-05-29 17:06:55

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] selftests: intel_pstate: notification about privilege required to run intel_pstate testing script

On 05/26/2018 11:01 AM, Jeffrin Jose T wrote:
> The intel_pstate related testing script need root level privileges
> when trying to access certain file for the successful execution of
> the script.But this is not the case always like when using evaluation
> only mode, which only require user level privilege.
>
> This patch is to notify the user about the privilege the script
> demands for the successful execution of the test.
>
> Signed-off-by: Jeffrin Jose T (Rajagiri SET) <[email protected]>
> ---
> tools/testing/selftests/intel_pstate/run.sh | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/intel_pstate/run.sh b/tools/testing/selftests/intel_pstate/run.sh
> index 6ded61670f6d..4ddd389c2cb9 100755
> --- a/tools/testing/selftests/intel_pstate/run.sh
> +++ b/tools/testing/selftests/intel_pstate/run.sh
> @@ -33,6 +33,12 @@ EVALUATE_ONLY=0
> # Kselftest framework requirement - SKIP code is 4.
> ksft_skip=4
>
> +msg="skip all tests:"
> +if [ $UID != 0 ] && [ $EVALUATE_ONLY == 0 ]; then
> + echo $msg please run this as root >&2
> + exit $ksft_skip
> +fi
> +
> 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
>

Why not do the arch check first and then do the root check? The order of
arch followed by root on non-x86 arch definitely better than root first
check.

thanks,
-- Shuah