Remove bashisms in cpuidle test module to make them POSIX-compliant. Also do some minor cleanups to make the scripts readable.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpuidle/cpuidle_01.sh | 21 +++++++++------------ cpuidle/cpuidle_02.sh | 7 +++---- cpuidle/cpuidle_03.sh | 17 ++++++++--------- cpuidle/cpuidle_sanity.sh | 9 ++++----- 4 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/cpuidle/cpuidle_01.sh b/cpuidle/cpuidle_01.sh index 8aa62c2..8aafc3f 100755 --- a/cpuidle/cpuidle_01.sh +++ b/cpuidle/cpuidle_01.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,34 +22,31 @@ # Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
STATES="desc latency name power time usage" FILES="current_driver current_governor_ro"
check_cpuidle_state_files() { - - local dirpath=$CPU_PATH/$1/cpuidle + cpuidle_state_files_dir=$CPU_PATH/$1/cpuidle shift 1
- for i in $(ls -d $dirpath/state*); do - for j in $STATES; do - check_file $j $i || return 1 - done + for i in $(ls -d $cpuidle_state_files_dir/state*); do + for j in $STATES; do + check_file $j $i || return 1 + done done
return 0 }
check_cpuidle_files() { - - local dirpath=$CPU_PATH/cpuidle + cpuidle_files_dir=$CPU_PATH/cpuidle
for i in $FILES; do - check_file $i $CPU_PATH/cpuidle || return 1 + check_file $i $CPU_PATH/cpuidle || return 1 done
return 0 diff --git a/cpuidle/cpuidle_02.sh b/cpuidle/cpuidle_02.sh index 0056382..304fd5b 100755 --- a/cpuidle/cpuidle_02.sh +++ b/cpuidle/cpuidle_02.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,12 +22,11 @@ # Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
CPUIDLE_KILLER=./cpuidle_killer
-check "cpuidle program runs successfully (120 secs)" "./$CPUIDLE_KILLER" +check "cpuidle program runs successfully (120 secs)" "$CPUIDLE_KILLER" test_status_show diff --git a/cpuidle/cpuidle_03.sh b/cpuidle/cpuidle_03.sh index 663d385..af621f5 100755 --- a/cpuidle/cpuidle_03.sh +++ b/cpuidle/cpuidle_03.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,14 +22,14 @@ # Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
CPUIDLE_KILLER=./cpuidle_killer
-if [ $(id -u) -ne 0 ]; then +is_root +if [ $? -ne 0 ]; then log_skip "run as non-root" exit 0 fi @@ -39,17 +39,16 @@ restore_cpus() { }
check_cpuidle_kill() { - if [ "$1" = "cpu0" ]; then - log_skip "skipping cpu0" - return 0 + log_skip "skipping cpu0" + return 1 fi
set_offline $1 - check "cpuidle program runs successfully (120 secs)" "./$CPUIDLE_KILLER" + check "cpuidle program runs successfully (120 secs)" "$CPUIDLE_KILLER" }
-trap "restore_cpus; sigtrap" SIGHUP SIGINT SIGTERM +trap "restore_cpus; sigtrap" HUP INT TERM
for_each_cpu check_cpuidle_kill restore_cpus diff --git a/cpuidle/cpuidle_sanity.sh b/cpuidle/cpuidle_sanity.sh index 65fe549..20b978e 100755 --- a/cpuidle/cpuidle_sanity.sh +++ b/cpuidle/cpuidle_sanity.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -23,7 +23,7 @@ # - initial API and implementation #
-source ../include/functions.sh +. ../include/functions.sh
is_root if [ $? -ne 0 ]; then @@ -32,10 +32,9 @@ if [ $? -ne 0 ]; then fi
check_cpuidle_sysfs_entry() { + cpuidle_sysfs_dir=$CPU_PATH/cpuidle
- local dirpath=$CPU_PATH/cpuidle - - test -d $dirpath + test -d $cpuidle_sysfs_dir if [ $? -ne 0 ]; then echo "cpuidle is not supported. Skipping all cpuidle tests" skip_tests cpuidle