[ It's been long overdue and PM-QA gets a makeover... ]
This patchset primarily fixes Linaro Bug# 772 (https://bugs.linaro.org/show_bug.cgi?id=772) to remove bashisms in all PM-QA scripts. These scripts will run on Android, Openembedded, and Ubuntu.
Cleanups have been done to remove redundant code, improve readability, and resolve syntax errors that were not detected before.
Next steps:
Once this patchset has been reviewed and acked, the following steps will be taken:
1. Submit a patch to update the release tag on the pwrmgmt test definitions to pm-qa-v0.5.0
2. Submit a patch to update the pm-qa script (https://git.linaro.org/qa/test-definitions.git/blob/HEAD:/common/scripts/pm-...) used to run PM-QA on Android by removing unnecessary busybox sym links and replace suspend test module with thermal in directory list.
3. Investigate further on why pandaboards do not like the cpuidle_03 test case.
Comments and/or questions are highly encouraged.
Lisa Nguyen (18): functions: Remove bashisms in function scripts cpuidle: Remove bashisms in cpuidle test module cputopology: Remove bashisms in cputopology test module cpufreq: Remove bashisms in cpufreq test module thermal: Remove bashisms in thermal test module cpuhotplug: Remove bashisms in cpuhotplug scripts suspend: Remove bashisms in suspend test module utils: Remove bashisms in utils_sanity.sh powertop: Remove bashisms in powertop test module Test.mk: Add sort function Switches: Export hotplug_allow_cpu0 Add cputopology_sanity script cpuhotplug: Rename 1_sanity_check.sh to cpuhotplug_00.sh cpuhotplug: Rename z_sanity_check.sh to cpuhotplug_09.sh Add descriptions for cpuhotplug_00.sh and cpuhotplug_09.sh Switches: Remove thermal_try_max variable cpufreq: Rewrite logic to check for userspace and powersave governors Android.mk: Update test numbers and remove whitespace
Switches.sh | 6 +- Test.mk | 4 +- cpufreq/Android.mk | 2 +- cpufreq/cpufreq_01.sh | 4 +- cpufreq/cpufreq_02.sh | 5 +- cpufreq/cpufreq_03.sh | 13 +- cpufreq/cpufreq_04.sh | 16 ++- cpufreq/cpufreq_05.sh | 24 ++-- cpufreq/cpufreq_06.sh | 59 ++++----- cpufreq/cpufreq_07.sh | 48 ++++--- cpufreq/cpufreq_08.sh | 31 ++--- cpufreq/cpufreq_09.sh | 27 ++-- cpufreq/cpufreq_sanity.sh | 9 +- cpuhotplug/1_sanity_check.sh | 40 ------ cpuhotplug/1_sanity_check.txt | 1 - cpuhotplug/Android.mk | 18 +-- cpuhotplug/cpuhotplug_00.sh | 39 ++++++ cpuhotplug/cpuhotplug_00.txt | 1 + cpuhotplug/cpuhotplug_01.sh | 5 +- cpuhotplug/cpuhotplug_02.sh | 21 ++-- cpuhotplug/cpuhotplug_03.sh | 15 ++- cpuhotplug/cpuhotplug_04.sh | 21 ++-- cpuhotplug/cpuhotplug_05.sh | 13 +- cpuhotplug/cpuhotplug_06.sh | 16 ++- cpuhotplug/cpuhotplug_07.sh | 17 ++- cpuhotplug/cpuhotplug_08.sh | 23 ++-- cpuhotplug/cpuhotplug_09.sh | 39 ++++++ cpuhotplug/cpuhotplug_09.txt | 1 + cpuhotplug/cpuhotplug_sanity.sh | 5 +- cpuhotplug/z_sanity_check.sh | 40 ------ cpuhotplug/z_sanity_check.txt | 1 - cpuidle/Android.mk | 4 +- cpuidle/cpuidle_01.sh | 21 ++-- cpuidle/cpuidle_02.sh | 7 +- cpuidle/cpuidle_03.sh | 17 ++- cpuidle/cpuidle_sanity.sh | 9 +- cputopology/Android.mk | 2 +- cputopology/cputopology_01.sh | 9 +- cputopology/cputopology_02.sh | 5 +- cputopology/cputopology_sanity.sh | 49 ++++++++ include/functions.sh | 248 +++++++++++++++++-------------------- include/suspend_functions.sh | 24 ++-- include/thermal_functions.sh | 219 ++++++++++++++++---------------- powertop/powertop_01.sh | 19 ++- powertop/powertop_sanity.sh | 8 +- suspend/suspend_01.sh | 9 +- suspend/suspend_02.sh | 9 +- suspend/suspend_03.sh | 9 +- suspend/suspend_04.sh | 11 +- suspend/suspend_05.sh | 11 +- suspend/suspend_sanity.sh | 4 +- thermal/thermal_00.sh | 22 ++-- thermal/thermal_01.sh | 39 +++--- thermal/thermal_02.sh | 36 +++--- thermal/thermal_03.sh | 18 +-- thermal/thermal_04.sh | 37 +++--- thermal/thermal_05.sh | 30 ++--- thermal/thermal_06.sh | 92 +++++++------- thermal/thermal_sanity.sh | 7 +- utils/utils_sanity.sh | 4 +- 60 files changed, 759 insertions(+), 784 deletions(-) delete mode 100755 cpuhotplug/1_sanity_check.sh delete mode 100644 cpuhotplug/1_sanity_check.txt create mode 100755 cpuhotplug/cpuhotplug_00.sh create mode 100644 cpuhotplug/cpuhotplug_00.txt create mode 100755 cpuhotplug/cpuhotplug_09.sh create mode 100644 cpuhotplug/cpuhotplug_09.txt delete mode 100755 cpuhotplug/z_sanity_check.sh delete mode 100644 cpuhotplug/z_sanity_check.txt create mode 100755 cputopology/cputopology_sanity.sh
Remove bashisms such as bash arrays and local keywords in all function scripts. Replace bash arrays with POSIX-compliant ones to store a series of values. Some variables are renamed to be clear of what values are assigned to them. Formatting has been changed to make the scripts more readable.
However, suspend_functions.sh has not been fully tested since the suspend test module is currently disabled by default in PM-QA.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- include/functions.sh | 248 ++++++++++++++++++++---------------------- include/suspend_functions.sh | 4 +- include/thermal_functions.sh | 219 +++++++++++++++++++------------------ 3 files changed, 233 insertions(+), 238 deletions(-)
diff --git a/include/functions.sh b/include/functions.sh index ebe96ad..1de7ab3 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -23,13 +23,12 @@ # - initial API and implementation #
-source ../Switches.sh +. ../Switches.sh
CPU_PATH="/sys/devices/system/cpu" TEST_NAME=$(basename ${0%.sh}) PREFIX=$TEST_NAME INC=0 -CPU= cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") pass_count=0 fail_count=0 @@ -50,9 +49,9 @@ test_status_show() { fi
echo " " - if [[ "$test_script_status" == "fail" ]]; then + if [ "$test_script_status" = "fail" ]; then echo "$TEST_NAME: fail" - elif [[ "$test_script_status" == "skip" ]]; then + elif [ "$test_script_status" = "skip" ]; then echo "$TEST_NAME: skip" else echo "$TEST_NAME: pass" @@ -77,11 +76,11 @@ log_begin() { }
log_end() { - printf "$*\n" + echo "$*"
- if [[ "$*" == "Err" ]]; then + if [ "$*" = "Err" ]; then fail_count=$((fail_count + 1)) - elif [[ "$*" == "skip" ]]; then + elif [ "$*" = "skip" ]; then skip_count=$((skip_count + 1)) else pass_count=$((pass_count + 1)) @@ -94,114 +93,107 @@ log_skip() { }
for_each_cpu() { - - local func=$1 + cpu_func=$1 shift 1
for cpu in $cpus; do - INC=0 - CPU=/$cpu - $func $cpu $@ + INC=0 + CPU=/$cpu + $cpu_func $cpu $@ done
return 0 }
for_each_governor() { - - local cpu=$1 - local func=$2 - local dirpath=$CPU_PATH/$cpu/cpufreq - local governors=$(cat $dirpath/scaling_available_governors) + cpu=$1 + gov_func=$2 + cpufreq_dirpath=$CPU_PATH/$cpu/cpufreq + governors=$(cat $cpufreq_dirpath/scaling_available_governors) shift 2
for governor in $governors; do - $func $cpu $governor $@ + $gov_func $cpu $governor $@ done
return 0 }
for_each_frequency() { - - local cpu=$1 - local func=$2 - local dirpath=$CPU_PATH/$cpu/cpufreq - local frequencies=$(cat $dirpath/scaling_available_frequencies) + cpu=$1 + freq_func=$2 + cpufreq_dirpath=$CPU_PATH/$cpu/cpufreq + frequencies=$(cat $cpufreq_dirpath/scaling_available_frequencies) shift 2
for frequency in $frequencies; do - $func $cpu $frequency $@ + $freq_func $cpu $frequency $@ done
return 0 }
set_governor() { + cpu=$1 + scaling_gov_dirpath=$CPU_PATH/$cpu/cpufreq/scaling_governor + newgov=$2
- local cpu=$1 - local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_governor - local newgov=$2 - - echo $newgov > $dirpath + echo $newgov > $scaling_gov_dirpath }
get_governor() { + cpu=$1 + scaling_gov_dirpath=$CPU_PATH/$cpu/cpufreq/scaling_governor
- local cpu=$1 - local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_governor - - cat $dirpath + cat $scaling_gov_dirpath }
wait_latency() { - local cpu=$1 - local dirpath=$CPU_PATH/$cpu/cpufreq - local latency= - local nrfreq= - local sampling_rate= - local sleep_time= - local gov=$(cat $dirpath/scaling_governor) + cpu=$1 + cpufreq_dirpath=$CPU_PATH/$cpu/cpufreq + scaling_gov=$(cat $cpufreq_dirpath/scaling_governor) + nanosleep="../utils/nanosleep"
# consider per-policy governor case - if [ -e $CPU_PATH/$cpu/cpufreq/$gov ]; then - sampling_rate=$(cat $CPU_PATH/$cpu/cpufreq/$gov/sampling_rate) + if [ -e $cpufreq_dirpath/$scaling_gov ]; then + sampling_rate=$(cat $cpufreq_dirpath/$scaling_gov/sampling_rate) + elif [ -e $CPU_PATH/cpufreq/$scaling_gov/sampling_rate ]; then + sampling_rate=0 else - sampling_rate=$(cat $CPU_PATH/cpufreq/$gov/sampling_rate) + sampling_rate=$(cat $CPU_PATH/cpufreq/$scaling_gov/sampling_rate) fi + sampling_rate=$((sampling_rate * 1000)) # unit nsec
- latency=$(cat $dirpath/cpuinfo_transition_latency) + latency=$(cat $cpufreq_dirpath/cpuinfo_transition_latency) if [ $? -ne 0 ]; then - return 1 + return 1 fi
- nrfreq=$(cat $dirpath/scaling_available_frequencies | wc -w) + nrfreq=$(cat $cpufreq_dirpath/scaling_available_frequencies | wc -w) if [ $? -ne 0 ]; then - return 1 + return 1 fi
nrfreq=$((nrfreq + 1)) - sleep_time=$(($latency + $sampling_rate)) - - ../utils/nanosleep $(($nrfreq * $sleep_time)) + $nanosleep $(($nrfreq * $sleep_time)) }
frequnit() { - local freq=$1 - local ghz=$(echo "scale=1;($freq / 1000000)" | bc -l) - local mhz=$(echo "scale=1;($freq / 1000)" | bc -l) + freq=$1 + ghz=$(echo "scale=1;($freq / 1000000)" | bc -l) + mhz=$(echo "scale=1;($freq / 1000)" | bc -l)
res=$(echo "($ghz > 1.0)" | bc -l) if [ "$res" = "1" ]; then - echo $ghz GHz + echo $ghz GHz return 0 fi
res=$(echo "($mhz > 1.0)" | bc -l) if [ "$res" = "1" ];then - echo $mhz MHz + echo $mhz MHz return 0 fi
@@ -209,75 +201,73 @@ frequnit() { }
set_frequency() { - - local cpu=$1 - local dirpath=$CPU_PATH/$cpu/cpufreq - local newfreq=$2 - local setfreqpath=$dirpath/scaling_setspeed + cpu=$1 + cpufreq_dirpath=$CPU_PATH/$cpu/cpufreq + newfreq=$2 + setfreqpath=$cpufreq_dirpath/scaling_setspeed
echo $newfreq > $setfreqpath wait_latency $cpu }
get_frequency() { - local cpu=$1 - local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_cur_freq - cat $dirpath + cpu=$1 + scaling_cur_freq=$CPU_PATH/$cpu/cpufreq/scaling_cur_freq + cat $scaling_cur_freq }
get_max_frequency() { - local cpu=$1 - local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_max_freq - cat $dirpath + cpu=$1 + scaling_max_freq=$CPU_PATH/$cpu/cpufreq/scaling_max_freq + cat $scaling_max_freq }
get_min_frequency() { - local cpu=$1 - local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_min_freq - cat $dirpath + cpu=$1 + scaling_min_freq=$CPU_PATH/$cpu/cpufreq/scaling_min_freq + cat $scaling_min_freq }
set_online() { - local cpu=$1 - local dirpath=$CPU_PATH/$cpu + cpu=$1 + current_cpu=$CPU_PATH/$cpu
if [ "$cpu" = "cpu0" ]; then - return 0 + return 0 fi
- echo 1 > $dirpath/online + echo 1 > $current_cpu/online }
set_offline() { - local cpu=$1 - local dirpath=$CPU_PATH/$cpu + cpu=$1 + current_cpu=$CPU_PATH/$cpu
if [ "$cpu" = "cpu0" ]; then - return 0 + return 0 fi
- echo 0 > $dirpath/online + echo 0 > $current_cpu/online }
get_online() { - local cpu=$1 - local dirpath=$CPU_PATH/$cpu + cpu=$1 + current_cpu=$CPU_PATH/$cpu
- cat $dirpath/online + cat $current_cpu/online }
check() { - - local descr=$1 - local func=$2 + description=$1 + function=$2 shift 2;
- log_begin "checking $descr" + log_begin "checking $description"
- $func $@ + $function $@ if [ $? -ne 0 ]; then - log_end "Err" - return 1 + log_end "Err" + return 1 fi
log_end "Ok" @@ -286,108 +276,100 @@ check() { }
check_file() { - local file=$1 - local dir=$2 + file=$1 + dir=$2
check "'$file' exists in '$dir'" "test -f" $dir/$file }
check_cpufreq_files() { - - local dirpath=$CPU_PATH/$1/cpufreq + dirpath=$CPU_PATH/$1/cpufreq shift 1
for i in $@; do - check_file $i $dirpath || return 1 + check_file $i $dirpath || return 1 done
return 0 }
check_sched_mc_files() { - - local dirpath=$CPU_PATH - for i in $@; do - check_file $i $dirpath || return 1 + check_file $i $CPU_PATH || return 1 done
return 0 }
check_topology_files() { - - local dirpath=$CPU_PATH/$1/topology + dirpath=$CPU_PATH/$1/topology shift 1
for i in $@; do - check_file $i $dirpath || return 1 + check_file $i $dirpath || return 1 done
return 0 }
check_cpuhotplug_files() { - - local dirpath=$CPU_PATH/$1 + dirpath=$CPU_PATH/$1 shift 1
for i in $@; do - if [ `echo $dirpath | grep -c "cpu0"` -eq 1 ]; then - if [ $hotplug_allow_cpu0 -eq 0 ]; then - continue - fi - fi + if [ `echo $dirpath | grep -c "cpu0"` -eq 1 ]; then + if [ $hotplug_allow_cpu0 -eq 0 ]; then + continue + fi + fi
- check_file $i $dirpath || return 1 + check_file $i $dirpath || return 1 done
return 0 }
save_governors() { - - governors_backup= - local index=0 + gov_array_name="governors_backup" + index=0
for cpu in $cpus; do - governors_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_governor) - index=$((index + 1)) + scaling_gov=$(cat $CPU_PATH/$cpu/cpufreq/scaling_governor) + eval $gov_array_name$index=$scaling_gov + eval export $gov_array_name$index + index=$((index + 1)) done }
restore_governors() { - - local index=0 - local oldgov= + index=0
for cpu in $cpus; do - oldgov=${governors_backup[$index]} - echo $oldgov > $CPU_PATH/$cpu/cpufreq/scaling_governor - index=$((index + 1)) + oldgov=$(eval echo $$gov_array_name$index) + echo $oldgov > $CPU_PATH/$cpu/cpufreq/scaling_governor + index=$((index + 1)) done }
save_frequencies() { - - frequencies_backup= - local index=0 + freq_array_name="frequencies_backup" + index=0
for cpu in $cpus; do - frequencies_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_cur_freq) - index=$((index + 1)) + freq=$(cat $CPU_PATH/$cpu/cpufreq/scaling_cur_freq) + eval $freq_array_name$index=$freq + eval export $freq_array_name$index + index=$((index + 1)) done }
restore_frequencies() { - - local index=0 - local oldfreq= + index=0
for cpu in $cpus; do - oldfreq=${frequencies_backup[$index]} - echo $oldfreq > $CPU_PATH/$cpu/cpufreq/scaling_setspeed - index=$((index + 1)) + oldfreq=$(eval echo $$freq_array_name$index) + echo $oldfreq > $CPU_PATH/$cpu/cpufreq/scaling_setspeed + index=$((index + 1)) done }
@@ -421,11 +403,11 @@ is_root() { }
is_cpu0_hotplug_allowed() { - local status=$1 + status=$1
if [ $status -eq 1 ]; then - return 0 + return 0 else - return 1 + return 1 fi } diff --git a/include/suspend_functions.sh b/include/suspend_functions.sh index 3be29f5..d5c8e2b 100644 --- a/include/suspend_functions.sh +++ b/include/suspend_functions.sh @@ -113,6 +113,7 @@ suspend_system () # Wait on the machine coming back up -- pulling the dmesg over. echo "v---" >>"$LOGFILE" retry=30 + while [ "$retry" -gt 0 ]; do let "retry=$retry-1"
@@ -131,6 +132,7 @@ suspend_system () fi sleep 1 done + echo "^---" >>"$LOGFILE" rm -f "$LOGFILE.dmesg"* if [ "$retry" -eq 0 ]; then @@ -242,6 +244,7 @@ ac_check() ECHO "*** WARNING: AC power not in expected state" \ "($ac_becomes) after test" fi + ac_is="$ac_becomes" }
@@ -293,4 +296,3 @@ if [ "$pm_trace" -eq 1 ]; then else disable_trace fi - diff --git a/include/thermal_functions.sh b/include/thermal_functions.sh index bfc6620..b66aeef 100644 --- a/include/thermal_functions.sh +++ b/include/thermal_functions.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -26,20 +26,22 @@ THERMAL_PATH="/sys/devices/virtual/thermal" MAX_ZONE=0-12 MAX_CDEV=0-50 -ALL_ZONE= -ALL_CDEV= +thermal_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") +scale_freq_array="scale_freq" +mode_list_array="mode_list" +thermal_gov_array="thermal_gov_backup"
check_valid_temp() { - local file=$1 - local zone_name=$2 - local dir=$THERMAL_PATH/$2 + file=$1 + zone_name=$2 + dir=$THERMAL_PATH/$2
- local temp_file=$dir/$1 - local func=cat + temp_file=$dir/$1 + func=cat shift 2;
- local temp_val=$($func $temp_file) - local descr="'$zone_name'/'$file' ='$temp_val'" + temp_val=$($func $temp_file) + descr="'$zone_name'/'$file' ='$temp_val'" log_begin "checking $descr"
if [ $temp_val -gt 0 ]; then @@ -53,74 +55,72 @@ check_valid_temp() { }
for_each_thermal_zone() { - - local func=$1 + thermal_zone_func=$1 shift 1
- zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") - - ALL_ZONE=$zone - for zone in $zones; do - INC=0 - $func $zone $@ + for zone in $thermal_zones; do + INC=0 + $thermal_zone_func $zone $@ done
return 0 }
get_total_trip_point_of_zone() { - - local zone_path=$THERMAL_PATH/$1 - local count=0 + zone_path=$THERMAL_PATH/$1 + count=0 shift 1 + trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") for trip in $trips; do - count=$((count + 1)) + count=$((count + 1)) done + return $count }
for_each_trip_point_of_zone() { - - local zone_path=$THERMAL_PATH/$1 - local count=0 - local func=$2 - local zone_name=$1 + zone_path=$THERMAL_PATH/$1 + count=0 + trip_pt_func=$2 + zone_name=$1 shift 2 + trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") for trip in $trips; do - $func $zone_name $count - count=$((count + 1)) + $trip_pt_func $zone_name $count + count=$((count + 1)) done + return 0 }
for_each_binding_of_zone() { - - local zone_path=$THERMAL_PATH/$1 - local count=0 - local func=$2 - local zone_name=$1 + zone_path=$THERMAL_PATH/$1 + count=0 + binding_zone_func=$2 + zone_name=$1 shift 2 + trips=$(ls $zone_path | grep "cdev['$MAX_CDEV']_trip_point") for trip in $trips; do - $func $zone_name $count - count=$((count + 1)) + $binding_zone_func $zone_name $count + count=$((count + 1)) done
return 0 - }
check_valid_binding() { - local trip_point=$1 - local zone_name=$2 - local dirpath=$THERMAL_PATH/$2 - local temp_file=$2/$1 - local trip_point_val=$(cat $dirpath/$trip_point) + trip_point=$1 + zone_name=$2 + dirpath=$THERMAL_PATH/$2 + temp_file=$2/$1 + trip_point_val=$(cat $dirpath/$trip_point) + get_total_trip_point_of_zone $zone_name - local trip_point_max=$? - local descr="'$temp_file' valid binding" + trip_point_max=$? + descr="'$temp_file' valid binding" shift 2
log_begin "checking $descr" @@ -134,10 +134,10 @@ check_valid_binding() { }
validate_trip_bindings() { - local zone_name=$1 - local bind_no=$2 - local dirpath=$THERMAL_PATH/$1 - local trip_point=cdev$2_trip_point + zone_name=$1 + bind_no=$2 + dirpath=$THERMAL_PATH/$1 + trip_point=cdev$2_trip_point shift 2
check_file $trip_point $dirpath || return 1 @@ -145,11 +145,11 @@ validate_trip_bindings() { }
validate_trip_level() { - local zone_name=$1 - local trip_no=$2 - local dirpath=$THERMAL_PATH/$1 - local trip_temp=trip_point_$2_temp - local trip_type=trip_point_$2_type + zone_name=$1 + trip_no=$2 + dirpath=$THERMAL_PATH/$1 + trip_temp=trip_point_$2_temp + trip_type=trip_point_$2_type shift 2
check_file $trip_temp $dirpath || return 1 @@ -158,88 +158,97 @@ validate_trip_level() { }
for_each_cooling_device() { - - local func=$1 + cooling_device_func=$1 shift 1
- devices=$(ls $THERMAL_PATH | grep "cooling_device['$MAX_CDEV']") - if [ "$devices" == "" ]; then - log_skip "no cooling devices" - return 0 + cooling_devices=$(ls $THERMAL_PATH | grep "cooling_device['$MAX_CDEV']") + if [ "$cooling_devices" = "" ]; then + log_skip "no cooling devices" + return 0 fi
- ALL_DEVICE=$devices - for device in $devices; do - INC=0 - $func $device $@ + for device in $cooling_devices; do + INC=0 + $cooling_device_func $device $@ done
return 0 } -check_scaling_freq() {
- local before_freq_list=$1 - local after_freq_list=$2 +# double check the values of this function +check_scaling_freq() { + before_freq_list=$1 + after_freq_list=$2 shift 2 - local index=0 + index=0
- local flag=0 + flag=0 for cpu in $cpus; do - if [ ${before_freq_list[$index]} -ne ${after_freq_list[$index]} ] ; then - flag=1 - fi + eval export $before_freq_list$index + eval export $after_freq_list$index + + bfreq=$(eval echo $$before_freq_list$index) + afreq=$(eval echo $$after_freq_list$index) + + if [ "$bfreq" -ne "$afreq" ]; then + flag=1 + fi + index=$((index + 1)) done + return $flag }
store_scaling_maxfreq() { - scale_freq= - local index=0 + index=0
for cpu in $cpus; do - scale_freq[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_max_freq) + scaling_max_freq=$(cat $CPU_PATH/$cpu/cpufreq/scaling_max_freq) + eval $scaling_freq_array$index=$scaling_max_freq + eval export $scaling_freq_array$index index=$((index + 1)) done + return 0 }
get_trip_id() { - - local trip_name=$1 + trip_name=$1 shift 1
- local id1=$(echo $trip_name|cut -c12) - local id2=$(echo $trip_name|cut -c13) + id1=$(echo $trip_name|cut -c12) + id2=$(echo $trip_name|cut -c13) if [ $id2 != "_" ]; then - id1=$(($id2 + 10*$id1)) + id1=$(($id2 + 10*$id1)) fi + return $id1 }
disable_all_thermal_zones() { + index=0
- mode_list= - local index=0 - - local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") - for zone in $th_zones; do - mode_list[$index]=$(cat $THERMAL_PATH/$zone/mode) + for zone in $thermal_zones; do + mode=$(cat $THERMAL_PATH/$zone/mode) + eval $mode_list_array$index=$mode + eval export $mode_list_array$index index=$((index + 1)) - echo -n "disabled" > $THERMAL_PATH/$zone/mode + echo -n "disabled" > $THERMAL_PATH/$zone/mode done + return 0 }
enable_all_thermal_zones() { + index=0
- local index=0 - - local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") - for zone in $th_zones; do - echo ${mode_list[$index]} > $THERMAL_PATH/$zone/mode + for zone in $thermal_zones; do + mode=$(eval echo $$mode_list_array$index) + echo $mode > $THERMAL_PATH/$zone/mode index=$((index + 1)) done + return 0 }
@@ -255,6 +264,7 @@ start_glmark2() { if [ -x $GPU_HEAT_BIN ]; then $GPU_HEAT_BIN & gpu_pid=$(pidof $GPU_HEAT_BIN) + # Starting X application from serial console needs this if [ -z "$gpu_pid" ]; then cp /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.bk @@ -266,6 +276,7 @@ start_glmark2() { $GPU_HEAT_BIN & gpu_pid=$(pidof $GPU_HEAT_BIN) fi + test -z "$gpu_pid" && cpu_pid=0 echo "start gpu heat binary $gpu_pid" else @@ -280,33 +291,33 @@ kill_glmark2() { fi
if [ "$gpu_pid" -ne 0 ]; then - kill -9 $gpu_pid + kill -9 $gpu_pid fi }
set_thermal_governors() { + gov=$1 + index=0
- local gov=$1 - local index=0 - thermal_governor_backup[MAX_ZONE]= - - local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") - for zone in $th_zones; do - thermal_governor_backup[$index]=$(cat $THERMAL_PATH/$zone/policy) + for zone in $thermal_zones; do + policy=$(cat $THERMAL_PATH/$zone/policy) + eval $thermal_gov_array$index=$policy + eval export $thermal_gov_array$index index=$((index + 1)) echo $gov > $THERMAL_PATH/$zone/policy done + return 0 }
restore_thermal_governors() { + index=0
- local index=0 - - local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") - for zone in $th_zones; do - echo ${thermal_governor_backup[$index]} > $THERMAL_PATH/$zone/policy + for zone in $thermal_zones; do + policy=$(eval echo $$thermal_gov_array$index) + echo $policy > $THERMAL_PATH/$zone/policy index=$((index + 1)) done + return 0 }
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
Remove bashisms in the cputopology scripts.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cputopology/cputopology_01.sh | 9 ++++----- cputopology/cputopology_02.sh | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/cputopology/cputopology_01.sh b/cputopology/cputopology_01.sh index 617c9b8..cab757d 100755 --- a/cputopology/cputopology_01.sh +++ b/cputopology/cputopology_01.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,12 +25,11 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
check_physical_package_id() { - - local package_id=$CPU_PATH/$1/topology/physical_package_id - local val=$(cat $package_id) + package_id=$CPU_PATH/$1/topology/physical_package_id + val=$(cat $package_id)
check "topology is enabled" "test "$val" != "-1"" } diff --git a/cputopology/cputopology_02.sh b/cputopology/cputopology_02.sh index 84199c2..17513e9 100755 --- a/cputopology/cputopology_02.sh +++ b/cputopology/cputopology_02.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,10 +22,9 @@ # 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
FILES="core_id core_siblings core_siblings_list physical_package_id \ thread_siblings thread_siblings_list"
Remove bashisms in the cpufreq test module in addition to renaming variables to more meaningful names and minor cleanups.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpufreq/cpufreq_01.sh | 4 ++-- cpufreq/cpufreq_02.sh | 5 ++--- cpufreq/cpufreq_03.sh | 13 ++++++------ cpufreq/cpufreq_04.sh | 16 +++++++-------- cpufreq/cpufreq_05.sh | 24 +++++++++++------------ cpufreq/cpufreq_06.sh | 48 ++++++++++++++++++++------------------------- cpufreq/cpufreq_07.sh | 48 ++++++++++++++++++++------------------------- cpufreq/cpufreq_08.sh | 26 +++++++++++------------- cpufreq/cpufreq_09.sh | 25 +++++++++++------------ cpufreq/cpufreq_sanity.sh | 9 ++++----- 10 files changed, 96 insertions(+), 122 deletions(-)
diff --git a/cpufreq/cpufreq_01.sh b/cpufreq/cpufreq_01.sh index 6f092fe..fa86941 100755 --- a/cpufreq/cpufreq_01.sh +++ b/cpufreq/cpufreq_01.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,7 +25,7 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
FILES="scaling_available_frequencies scaling_cur_freq scaling_setspeed"
diff --git a/cpufreq/cpufreq_02.sh b/cpufreq/cpufreq_02.sh index 34e19b7..760bb78 100755 --- a/cpufreq/cpufreq_02.sh +++ b/cpufreq/cpufreq_02.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,10 +22,9 @@ # 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
FILES="scaling_available_governors scaling_governor"
diff --git a/cpufreq/cpufreq_03.sh b/cpufreq/cpufreq_03.sh index 65a6ad7..4a5029b 100755 --- a/cpufreq/cpufreq_03.sh +++ b/cpufreq/cpufreq_03.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,20 +25,19 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
check_governor() { - - local cpu=$1 - local newgov=$2 + cpu=$1 + newgov=$2
shift 2
- local oldgov=$(get_governor $cpu) + oldgov=$(get_governor $cpu)
set_governor $cpu $newgov
- check "governor change to '$newgov'" "test "$(get_governor $cpu)" == "$newgov"" + check "governor change to '$newgov'" "test "$(get_governor $cpu)" = "$newgov""
set_governor $cpu $oldgov } diff --git a/cpufreq/cpufreq_04.sh b/cpufreq/cpufreq_04.sh index d4ed1bd..f9b16dc 100755 --- a/cpufreq/cpufreq_04.sh +++ b/cpufreq/cpufreq_04.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,25 +22,23 @@ # 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
check_frequency() { - - local cpu=$1 - local newfreq=$2 + cpu=$1 + newfreq=$2
shift 2
- local oldgov=$(get_governor $cpu) - local oldfreq=$(get_frequency $cpu) + oldgov=$(get_governor $cpu) + oldfreq=$(get_frequency $cpu)
set_governor $cpu userspace set_frequency $cpu $newfreq
- check "setting frequency '$(frequnit $newfreq)'" "test "$(get_frequency $cpu)" == "$newfreq"" + check "setting frequency '$(frequnit $newfreq)'" "test "$(get_frequency $cpu)" = "$newfreq""
set_frequency $cpu $oldfreq set_governor $cpu $oldgov diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh index 1f0dd8d..1113106 100755 --- a/cpufreq/cpufreq_05.sh +++ b/cpufreq/cpufreq_05.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,37 +22,35 @@ # 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
save_governors
-trap restore_governors SIGHUP SIGINT SIGTERM +trap restore_governors HUP INT TERM
switch_ondemand() { - local cpu=$1 + cpu=$1 set_governor $cpu 'ondemand' }
switch_conservative() { - local cpu=$1 + cpu=$1 set_governor $cpu 'conservative' }
switch_userspace() { - local cpu=$1 + cpu=$1 set_governor $cpu 'userspace' }
check_governor() { - local cpu=$1 - local gov=$2 + cpu=$1 + gov=$2 + GOV_PATH=$CPU_PATH/$cpu/cpufreq/$gov
- if [ -d $CPU_PATH/$cpu/cpufreq/$gov ]; then - GOV_PATH=$CPU_PATH/$cpu/cpufreq/$gov - else + if [ ! -d $GOV_PATH ]; then GOV_PATH=$CPU_PATH/cpufreq/$gov fi check "'$gov' directory exists" "test -d $GOV_PATH" @@ -94,7 +92,7 @@ fi nrcpus=$(ls $CPU_PATH | grep "cpu[0-9].*" | wc -l) if [ $nrcpus -gt 1 ]; then affected=$(cat $CPU_PATH/cpu0/cpufreq/affected_cpus | grep 1) - if [ -z $affected ]; then + if [ -z "$affected" ]; then switch_ondemand cpu0 switch_conservative cpu1 check_governor cpu0 'ondemand' diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh index e2e708a..9159c9e 100755 --- a/cpufreq/cpufreq_06.sh +++ b/cpufreq/cpufreq_06.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,40 +22,41 @@ # 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
CPUCYCLE=../utils/cpucycle +INDEX=1 +cpufreq_ratio_array_name="freq_ratio"
compute_freq_ratio() { - - local cpu=$1 - local freq=$2 + cpu=$1 + freq=$2
set_frequency $cpu $freq
result=$($CPUCYCLE $cpu) if [ $? -ne 0 ]; then - return 1 + return 1 fi
- results[$index]=$(echo "scale=3;($result / $freq)" | bc -l) + result=$(echo "scale=3;($result / $freq)" | bc -l) + + eval $cpufreq_ratio_array_name$index=$result + eval export $cpufreq_ratio_array_name$index index=$((index + 1)) + }
compute_freq_ratio_sum() { - - res=${results[$index]} - sum=$(echo "($sum + $res)" | bc -l) - index=$((index + 1)) - + res=$(eval echo $$cpufreq_ratio_array_name$index) + sum=$(echo "($sum + $res)" | bc) + index=$(($index + 1)) }
__check_freq_deviation() { - - res=${results[$index]} + res=$(eval echo $$cpufreq_ratio_array_name$index)
# compute deviation dev=$(echo "scale=3;((( $res - $avg ) / $avg) * 100 )" | bc -l) @@ -63,38 +64,31 @@ __check_freq_deviation() { # change to absolute dev=$(echo $dev | awk '{ print ($1 >= 0) ? $1 : 0 - $1}')
- index=$((index + 1)) - res=$(echo "($dev > 5.0)" | bc -l) if [ "$res" = "1" ]; then - return 1 + return 1 fi
return 0 }
check_freq_deviation() { - - local cpu=$1 - local freq=$2 + cpu=$1 + freq=$2
check "deviation for frequency $(frequnit $freq)" __check_freq_deviation
}
check_deviation() { - - local cpu=$1 + cpu=$1
set_governor $cpu userspace - for_each_frequency $cpu compute_freq_ratio
index=0 sum=0 - for_each_frequency $cpu compute_freq_ratio_sum - avg=$(echo "scale=3;($sum / $index)" | bc -l)
index=0 @@ -110,7 +104,7 @@ fi save_governors save_frequencies
-trap "restore_frequencies; restore_governors; sigtrap" SIGHUP SIGINT SIGTERM +trap "restore_frequencies; restore_governors; sigtrap" HUP INT TERM
for_each_cpu check_deviation
diff --git a/cpufreq/cpufreq_07.sh b/cpufreq/cpufreq_07.sh index b65d212..24f7c97 100755 --- a/cpufreq/cpufreq_07.sh +++ b/cpufreq/cpufreq_07.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,48 +22,42 @@ # 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
CPUBURN=../utils/cpuburn
check_ondemand() { - - local cpu=$1 - local maxfreq=$(get_max_frequency $cpu) - local minfreq=$(get_min_frequency $cpu) - local curfreq=$(get_frequency $cpu) - local pid= + cpu=$1 + maxfreq=$(get_max_frequency $cpu) + minfreq=$(get_min_frequency $cpu) + curfreq=$(get_frequency $cpu)
set_governor $cpu ondemand
# wait for a quescient point for i in $(seq 1 10); do + if [ "$minfreq" -eq "$(get_frequency $cpu)" ]; then + $CPUBURN $cpu & + pid=$!
- if [ "$minfreq" -eq "$(get_frequency $cpu)" ]; then - - $CPUBURN $cpu & - pid=$! - - sleep 1 - wait_latency $cpu - curfreq=$(get_frequency $cpu) - kill $pid - - check "'ondemand' increase frequency on load" "test "$curfreq" == "$maxfreq"" + sleep 1 + wait_latency $cpu + curfreq=$(get_frequency $cpu) + kill $pid
- sleep 1 - curfreq=$(get_frequency $cpu) + check "'ondemand' increase frequency on load" "test "$curfreq" = "$maxfreq""
- check "'ondemand' decrease frequency on idle" "test "$curfreq" == "$minfreq"" + sleep 1 + curfreq=$(get_frequency $cpu)
- return 0 - fi + check "'ondemand' decrease frequency on idle" "test "$curfreq" = "$minfreq""
- sleep 1 + return 0 + fi
+ sleep 1 done
log_skip "can not reach a quescient point for 'ondemand'" @@ -79,7 +73,7 @@ fi
save_governors
-trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM +trap "restore_governors; sigtrap" HUP INT TERM
for_each_cpu check_ondemand
diff --git a/cpufreq/cpufreq_08.sh b/cpufreq/cpufreq_08.sh index 2250017..e43c002 100755 --- a/cpufreq/cpufreq_08.sh +++ b/cpufreq/cpufreq_08.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,18 +22,15 @@ # 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
CPUBURN=../utils/cpuburn
check_frequency() { - local cpu=$1 - local freq=$2 - local curfreq= - local pid= + cpu=$1 + freq=$2
$CPUBURN $cpu & pid=$! @@ -44,20 +41,19 @@ check_frequency() { curfreq=$(get_frequency $cpu) kill $pid
- check "'userspace' $(frequnit $freq) is fixed" "test "$curfreq" == "$freq"" + check "'userspace' $(frequnit $freq) is fixed" "test "$curfreq" = "$freq"" if [ "$?" != "0" ]; then - return 1 + return 1 fi
return 0 }
check_userspace() { - - local cpu=$1 - local maxfreq=$(get_max_frequency $cpu) - local minfreq=$(get_min_frequency $cpu) - local curfreq=$(get_frequency $cpu) + cpu=$1 + maxfreq=$(get_max_frequency $cpu) + minfreq=$(get_min_frequency $cpu) + curfreq=$(get_frequency $cpu)
set_governor $cpu userspace
@@ -72,7 +68,7 @@ if [ -z "$supported" ]; then return 0 fi
-trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM +trap "restore_governors; sigtrap" HUP INT TERM
for_each_cpu check_userspace
diff --git a/cpufreq/cpufreq_09.sh b/cpufreq/cpufreq_09.sh index 62c953d..7a3cd26 100755 --- a/cpufreq/cpufreq_09.sh +++ b/cpufreq/cpufreq_09.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,27 +22,25 @@ # 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
CPUBURN=../utils/cpuburn
check_powersave() { - - local cpu=$1 - local minfreq=$(get_min_frequency $cpu) - local curfreq=$(get_frequency $cpu) + cpu=$1 + minfreq=$(get_min_frequency $cpu) + curfreq=$(get_frequency $cpu)
set_governor $cpu powersave
wait_latency $cpu curfreq=$(get_frequency $cpu)
- check "'powersave' sets frequency to $(frequnit $minfreq)" "test "$curfreq" == "$minfreq"" + check "'powersave' sets frequency to $(frequnit $minfreq)" "test "$curfreq" = "$minfreq"" if [ "$?" != "0" ]; then - return 1 + return 1 fi
$CPUBURN $cpu & @@ -52,9 +50,9 @@ check_powersave() { curfreq=$(get_frequency $cpu) kill $pid
- check "'powersave' frequency $(frequnit $minfreq) is fixed" "test "$curfreq" == "$minfreq"" + check "'powersave' frequency $(frequnit $minfreq) is fixed" "test "$curfreq" = "$minfreq"" if [ "$?" -ne "0" ]; then - return 1 + return 1 fi
return 0 @@ -65,12 +63,11 @@ save_governors supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "powersave") if [ -z "$supported" ]; then log_skip "powersave not supported" - return 0 + return 1 fi
-trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM +trap "restore_governors; sigtrap" HUP INT TERM
for_each_cpu check_powersave - restore_governors test_status_show diff --git a/cpufreq/cpufreq_sanity.sh b/cpufreq/cpufreq_sanity.sh index e3518b8..4c598e7 100755 --- a/cpufreq/cpufreq_sanity.sh +++ b/cpufreq/cpufreq_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_cpufreq_sysfs_entry() { + cpufreq_sysfs_dir=$CPU_PATH/cpufreq
- local dirpath=$CPU_PATH/cpufreq - - test -d $dirpath + test -d $cpufreq_sysfs_dir if [ $? -ne 0 ]; then echo "cpufreq is not supported. Skipping all cpufreq tests" skip_tests cpufreq
Remove bashism in thermal scripts and remove thermal_try_max variable as it is not used anywhere else nor does its value changes. Rename variables to something more meaningful and improve format for readability.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- thermal/thermal_00.sh | 22 ++++++----- thermal/thermal_01.sh | 39 ++++++++----------- thermal/thermal_02.sh | 36 +++++++++--------- thermal/thermal_03.sh | 18 ++++----- thermal/thermal_04.sh | 37 +++++++++--------- thermal/thermal_05.sh | 30 +++++++-------- thermal/thermal_06.sh | 92 +++++++++++++++++++++++---------------------- thermal/thermal_sanity.sh | 7 ++-- 8 files changed, 141 insertions(+), 140 deletions(-)
diff --git a/thermal/thermal_00.sh b/thermal/thermal_00.sh index cdc5a10..9ed1be4 100755 --- a/thermal/thermal_00.sh +++ b/thermal/thermal_00.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,24 +25,26 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal...
-source ../include/functions.sh -source ../include/thermal_functions.sh +. ../include/functions.sh +. ../include/thermal_functions.sh
check_cooling_device_type() { - local all_zones=$(ls $THERMAL_PATH | grep "cooling_device['$MAX_CDEV']") + all_cdev_zones=$(ls $THERMAL_PATH | grep "cooling_device['$MAX_CDEV']") + echo "Cooling Device list:" - for i in $all_zones; do - local type=$(cat $THERMAL_PATH/$i/type) - echo "- $type" + for i in $all_cdev_zones; do + cooling_type=$(cat $THERMAL_PATH/$i/type) + echo "- $cooling_type" done }
check_thermal_zone_type() { - local all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + echo "Thermal Zone list:" for i in $all_zones; do - local type=$(cat $THERMAL_PATH/$i/type) - echo "- $type" + type=$(cat $THERMAL_PATH/$i/type) + echo "- $type" done }
diff --git a/thermal/thermal_01.sh b/thermal/thermal_01.sh index dac26d1..dfda2f5 100755 --- a/thermal/thermal_01.sh +++ b/thermal/thermal_01.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,38 +22,35 @@ # Amit Daniel amit.kachhap@linaro.org (Samsung Electronics) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/thermal_functions.sh +. ../include/functions.sh +. ../include/thermal_functions.sh
ATTRIBUTES="mode temp type uevent"
check_thermal_zone_attributes() { - - local dirpath=$THERMAL_PATH/$1 - local zone_name=$1 + dirpath=$THERMAL_PATH/$1 + zone_name=$1 shift 1 for i in $ATTRIBUTES; do - check_file $i $dirpath || return 1 + check_file $i $dirpath || return 1 done
check_valid_temp "temp" $zone_name || return 1 }
check_thermal_zone_mode() { - - local dirpath=$THERMAL_PATH/$1 - local zone_name=$1 + dirpath=$THERMAL_PATH/$1 + zone_name=$1 shift 1 - local prev_mode=$(cat $dirpath/mode) + prev_mode=$(cat $dirpath/mode) echo -n enabled > $dirpath/mode - local cur_mode=$(cat $dirpath/mode) + cur_mode=$(cat $dirpath/mode) check "$zone_name cur_mode=$cur_mode"\ "test $cur_mode = enabled" || return 1 echo -n disabled > $dirpath/mode - local cur_mode=$(cat $dirpath/mode) + cur_mode=$(cat $dirpath/mode) check "$zone_name cur_mode=$cur_mode"\ "test $cur_mode = disabled" || return 1
@@ -61,26 +58,22 @@ check_thermal_zone_mode() { }
check_thermal_zone_trip_level() { - - local all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + for i in $all_zones; do - for_each_trip_point_of_zone $i "validate_trip_level" || return 1 + for_each_trip_point_of_zone $i "validate_trip_level" || return 1 done }
check_thermal_zone_bindings() { - - local all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") for i in $all_zones; do - for_each_binding_of_zone $i "validate_trip_bindings" || return 1 + for_each_binding_of_zone $i "validate_trip_bindings" || return 1 done }
for_each_thermal_zone check_thermal_zone_attributes - for_each_thermal_zone check_thermal_zone_mode - check_thermal_zone_trip_level - check_thermal_zone_bindings test_status_show diff --git a/thermal/thermal_02.sh b/thermal/thermal_02.sh index 1f53612..ef5b86c 100755 --- a/thermal/thermal_02.sh +++ b/thermal/thermal_02.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,38 +25,40 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/thermal_functions.sh +. ../include/functions.sh +. ../include/thermal_functions.sh
CDEV_ATTRIBUTES="cur_state max_state type uevent"
check_cooling_device_attributes() {
- local dirpath=$THERMAL_PATH/$1 - local cdev_name=$1 + dirpath=$THERMAL_PATH/$1 + cdev_name=$1 shift 1
for i in $CDEV_ATTRIBUTES; do - check_file $i $dirpath || return 1 + check_file $i $dirpath || return 1 done
}
check_cooling_device_states() { - local dirpath=$THERMAL_PATH/$1 - local cdev_name=$1 + dirpath=$THERMAL_PATH/$1 + cdev_name=$1 shift 1 - local max_state=$(cat $dirpath/max_state) - local prev_state_val=$(cat $dirpath/cur_state) - local count=0 - local cur_state_val=0 + max_state=$(cat $dirpath/max_state) + prev_state_val=$(cat $dirpath/cur_state) + count=0 + cur_state_val=0 + while (test $count -le $max_state); do - echo $count > $dirpath/cur_state - cur_state_val=$(cat $dirpath/cur_state) - check "$cdev_name cur_state=$count"\ - "test $cur_state_val -eq $count" || return 1 - count=$((count+1)) + echo $count > $dirpath/cur_state + cur_state_val=$(cat $dirpath/cur_state) + check "$cdev_name cur_state=$count"\ + "test $cur_state_val -eq $count" || return 1 + count=$((count+1)) done + echo $prev_state_val > $dirpath/cur_state }
diff --git a/thermal/thermal_03.sh b/thermal/thermal_03.sh index cf53a1a..2b3f9d7 100755 --- a/thermal/thermal_03.sh +++ b/thermal/thermal_03.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,25 +25,25 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/thermal_functions.sh +. ../include/functions.sh +. ../include/thermal_functions.sh
CPU_HEAT_BIN=../utils/heat_cpu cpu_pid=0
heater_kill() { if [ $cpu_pid -ne 0 ]; then - kill -9 $cpu_pid + kill -9 $cpu_pid fi kill_glmark2 }
check_temperature_change() { - local dirpath=$THERMAL_PATH/$1 - local zone_name=$1 + dirpath=$THERMAL_PATH/$1 + zone_name=$1 shift 1
- local init_temp=$(cat $dirpath/temp) + init_temp=$(cat $dirpath/temp) $CPU_HEAT_BIN & cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') test -z $cpu_pid && cpu_pid=0 @@ -53,12 +53,12 @@ check_temperature_change() { start_glmark2
sleep 5 - local final_temp=$(cat $dirpath/temp) + final_temp=$(cat $dirpath/temp) heater_kill check "temperature variation with load" "test $final_temp -gt $init_temp" }
-trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM +trap "heater_kill; sigtrap" HUP INT TERM
for_each_thermal_zone check_temperature_change test_status_show diff --git a/thermal/thermal_04.sh b/thermal/thermal_04.sh index 8bf3799..def1740 100755 --- a/thermal/thermal_04.sh +++ b/thermal/thermal_04.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,8 +25,8 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/thermal_functions.sh +. ../include/functions.sh +. ../include/thermal_functions.sh HEAT_CPU_MODERATE=../utils/heat_cpu pid=0
@@ -37,30 +37,31 @@ heater_kill() { }
verify_cooling_device_temp_change() { - local dirpath=$THERMAL_PATH/$1 - local cdev_name=$1 + dirpath=$THERMAL_PATH/$1 + dev_name=$1 shift 1 - local tzonepath=$THERMAL_PATH/thermal_zone0 + tzonepath=$THERMAL_PATH/thermal_zone0 test -d $tzonepath + if [ $? -ne 0 ] ; then - echo "No thermal zone present" - return 1; + echo "No thermal zone present" + return 1 fi - local max_state=$(cat $dirpath/max_state) - local prev_state_val=$(cat $dirpath/cur_state) + max_state=$(cat $dirpath/max_state) + prev_state_val=$(cat $dirpath/cur_state)
- local count=1 - local cur_state_val=0 - local init_temp=0 - local final_temp=0 - local cool_temp=0 + count=1 + cur_state_val=0 + init_temp=0 + final_temp=0 + cool_temp=0 ./$HEAT_CPU_MODERATE moderate & pid=$! test $pid -eq 0 && return
while (test $count -le $max_state); do - echo 0 > $dirpath/cur_state - sleep 5 + echo 0 > $dirpath/cur_state + sleep 5 init_temp=$(cat $tzonepath/temp)
echo $count > $dirpath/cur_state @@ -75,7 +76,7 @@ verify_cooling_device_temp_change() { echo $prev_state_val > $dirpath/cur_state }
-trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM +trap "heater_kill; sigtrap" HUP INT TERM
set_thermal_governors user_space
diff --git a/thermal/thermal_05.sh b/thermal/thermal_05.sh index 52a0ac2..828a75e 100755 --- a/thermal/thermal_05.sh +++ b/thermal/thermal_05.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,42 +25,42 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/thermal_functions.sh +. ../include/functions.sh +. ../include/thermal_functions.sh
verify_cpufreq_cooling_device_action() { - local dirpath=$THERMAL_PATH/$1 - local cdev_name=$1 + dirpath=$THERMAL_PATH/$1 + cdev_name=$1 shift 1
- local cpufreq_cdev=$(cat $dirpath/type) + cpufreq_cdev=$(cat $dirpath/type) cat $dirpath/type | grep cpufreq if [ $? -ne 0 ] ; then log_skip "Cannot find cpufreq in $cdev_name..." return 0 fi
- local max_state=$(cat $dirpath/max_state) - local prev_state_val=$(cat $dirpath/cur_state) + max_state=$(cat $dirpath/max_state) + prev_state_val=$(cat $dirpath/cur_state) disable_all_thermal_zones
- local count=1 - local before_scale_max=0 - local after_scale_max=0 - local change=0 + count=1 + before_scale_max=0 + after_scale_max=0 + change=0
while (test $count -le $max_state); do - echo 0 > $dirpath/cur_state + echo 0 > $dirpath/cur_state sleep 1
store_scaling_maxfreq - before_scale_max=$scale_freq + before_scale_max=$scale_freq_array
echo $count > $dirpath/cur_state sleep 1
store_scaling_maxfreq - after_scale_max=$scale_freq + after_scale_max=$scale_freq_array
check_scaling_freq $before_scale_max $after_scale_max change=$? diff --git a/thermal/thermal_06.sh b/thermal/thermal_06.sh index d8877f0..1d6943c 100755 --- a/thermal/thermal_06.sh +++ b/thermal/thermal_06.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,37 +25,33 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/thermal_functions.sh - -if [ "$thermal_try_max" -eq 0 ]; then - log_skip "test of trip points being crossed" - return 0 -fi +. ../include/functions.sh +. ../include/thermal_functions.sh
TEST_LOOP=100 CPU_HEAT_BIN=../utils/heat_cpu cpu_pid=0 +trip_point_array_name="trip_point_list"
heater_kill() { if [ $cpu_pid -ne 0 ]; then - kill -9 $cpu_pid + kill -9 $cpu_pid fi kill_glmark2 }
check_trip_point_change() { - local dirpath=$THERMAL_PATH/$1 - local zone_name=$1 + dirpath=$THERMAL_PATH/$1 + zone_name=$1 shift 1
- local count=0 - local cur_temp=0 - local trip_temp=0 - local trip_cross= - local trip_id= - local trip_type=0 - local trip_type_path=0 + count=0 + cur_temp=0 + trip_temp=0 + trip_cross= + trip_id= + trip_type=0 + trip_type_path=0 $CPU_HEAT_BIN & cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') test -z $cpu_pid && cpu_pid=0 @@ -64,43 +60,51 @@ check_trip_point_change() {
start_glmark2
- local index=0 - for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do - trip_cross[$index]=0 - index=$((index + 1)) + index=0 + + for trip in $(ls $dirpath/thermal_zone0 | grep "trip_point_['$MAX_ZONE']_temp") + do + value=0 + eval $trip_point_array_name$index=$value + eval export $trip_point_array_name$index + index=$((index + 1)) done + while (test $count -lt $TEST_LOOP); do - index=0 - sleep 1 - for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do - cur_temp=$(cat $dirpath/temp) - trip_temp=$(cat $dirpath/$trip) - if [ $cur_temp -gt $trip_temp ]; then - trip_cross[$index]=$((${trip_cross[$index]} + 1)) - fi - index=$((index + 1)) + index=0 + sleep 1
- done - count=$((count + 1)) + for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do + cur_temp=$(cat $dirpath/temp) + trip_temp=$(cat $dirpath/$trip) + if [ $cur_temp -gt $trip_temp ]; then + value=$(eval echo $$trip_point_array_name$index) + eval $trip_point_array_name$index=$((value + 1)) + fi + index=$((index + 1)) + done + + count=$((index + 1)) done + index=0 for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do - get_trip_id $trip - trip_id=$? - trip_type=$(cat $dirpath/trip_point_$((trip_id))_type) - trip_temp=$(cat $dirpath/$trip) - - if [ $trip_type != "critical" ]; then - count=${trip_cross[$index]} - check "$trip:$trip_temp crossed" "test $count -gt 0" - fi - index=$((index + 1)) + get_trip_id $trip + trip_id=$? + trip_type=$(cat $dirpath/trip_point_$((trip_id))_type) + trip_temp=$(cat $dirpath/$trip) + + if [ $trip_type != "critical" ]; then + count=$(eval echo $$trip_point_array_name$index) + check "$trip:$trip_temp crossed" "test $count -gt 0" + fi + index=$((index + 1)) done
heater_kill }
-trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM +trap "heater_kill; sigtrap" HUP INT TERM
for_each_thermal_zone check_trip_point_change test_status_show diff --git a/thermal/thermal_sanity.sh b/thermal/thermal_sanity.sh index c9149c0..4b76c88 100755 --- a/thermal/thermal_sanity.sh +++ b/thermal/thermal_sanity.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -23,8 +23,8 @@ # - initial API and implementation #
-source ../include/functions.sh -source ../include/thermal_functions.sh +. ../include/functions.sh +. ../include/thermal_functions.sh
is_root if [ $? -ne 0 ]; then @@ -33,7 +33,6 @@ if [ $? -ne 0 ]; then fi
check_thermal_zone() { - test -d $THERMAL_PATH if [ $? -ne 0 ]; then echo "thermal zone is not available. Skipping all tests"
Remove bashism in cpuhotplug scripts. $RANDOM is an internal BASH function, so remove it to follow POSIX standards.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpuhotplug/1_sanity_check.sh | 7 +++---- cpuhotplug/cpuhotplug_01.sh | 5 ++--- cpuhotplug/cpuhotplug_02.sh | 21 ++++++++++----------- cpuhotplug/cpuhotplug_03.sh | 15 +++++++-------- cpuhotplug/cpuhotplug_04.sh | 21 ++++++++++----------- cpuhotplug/cpuhotplug_05.sh | 13 ++++++------- cpuhotplug/cpuhotplug_06.sh | 16 +++++++--------- cpuhotplug/cpuhotplug_07.sh | 17 ++++++++--------- cpuhotplug/cpuhotplug_08.sh | 23 ++++++++++++----------- cpuhotplug/cpuhotplug_sanity.sh | 5 ++--- cpuhotplug/z_sanity_check.sh | 7 +++---- 11 files changed, 70 insertions(+), 80 deletions(-)
diff --git a/cpuhotplug/1_sanity_check.sh b/cpuhotplug/1_sanity_check.sh index e091879..d4bc02a 100755 --- a/cpuhotplug/1_sanity_check.sh +++ b/cpuhotplug/1_sanity_check.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,13 +22,12 @@ # Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) # - initial API and implementation # - # URL :
-source ../include/functions.sh +. ../include/functions.sh
sanity_check() { - local ret=$(cat $CPU_PATH/offline) + ret=$(cat $CPU_PATH/offline) if [ -z "$ret" ]; then return 0 else diff --git a/cpuhotplug/cpuhotplug_01.sh b/cpuhotplug/cpuhotplug_01.sh index 8804df7..8591a21 100755 --- a/cpuhotplug/cpuhotplug_01.sh +++ b/cpuhotplug/cpuhotplug_01.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,10 +22,9 @@ # 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
FILES="online offline possible present"
diff --git a/cpuhotplug/cpuhotplug_02.sh b/cpuhotplug/cpuhotplug_02.sh index d2bb5b4..e304484 100755 --- a/cpuhotplug/cpuhotplug_02.sh +++ b/cpuhotplug/cpuhotplug_02.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,19 +22,18 @@ # 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
check_state() { - local cpu=$1 - local dirpath=$CPU_PATH/$1 - local state= + cpu=$1 + dirpath=$CPU_PATH/$1 + state= shift 1
- if [ "$cpu" == "cpu0" ]; then - is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 + if [ "$cpu" = "cpu0" ]; then + is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 fi
set_offline $cpu @@ -42,8 +41,8 @@ check_state() {
check "cpu is offline" "test $state -eq 0" if [ $? -ne 0 ]; then - set_online $cpu - return 1 + set_online $cpu + return 1 fi
set_online $cpu @@ -51,7 +50,7 @@ check_state() {
check "cpu is online" "test $state -eq 1" if [ $? -ne 0 ]; then - return 1 + return 1 fi
return 0 diff --git a/cpuhotplug/cpuhotplug_03.sh b/cpuhotplug/cpuhotplug_03.sh index 2a5ae48..176269e 100755 --- a/cpuhotplug/cpuhotplug_03.sh +++ b/cpuhotplug/cpuhotplug_03.sh @@ -25,16 +25,15 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
check_affinity_fails() { - local cpu=$1 - local cpuid=${cpu:3} - local dirpath=$CPU_PATH/$1 - local ret= - - if [ "$cpu" == "cpu0" ]; then - is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 + cpu=$1 + cpuid=$(echo $cpu | awk '{print substr($0,4)}') + dirpath=$CPU_PATH/$1 + + if [ "$cpu" = "cpu0" ]; then + is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 fi
set_offline $cpu diff --git a/cpuhotplug/cpuhotplug_04.sh b/cpuhotplug/cpuhotplug_04.sh index 7938e7d..570e097 100755 --- a/cpuhotplug/cpuhotplug_04.sh +++ b/cpuhotplug/cpuhotplug_04.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,22 +22,21 @@ # Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
CPUBURN=../utils/cpuburn -source ../include/functions.sh +. ../include/functions.sh
check_task_migrate() { - local cpu=$1 - local cpuid=${cpu:3} - local cpumask=$((1 << cpuid)) - local dirpath=$CPU_PATH/$1 - local pid= - local ret= + cpu=$1 + cpuid=$(echo $cpu | awk '{print substr($0,4)}') + cpumask=$((1 << cpuid)) + dirpath=$CPU_PATH/$1 + pid= + ret=
- if [ "$cpu" == "cpu0" ]; then - is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 + if [ "$cpu" = "cpu0" ]; then + is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 fi
taskset 0x$cpumask $CPUBURN $cpu & diff --git a/cpuhotplug/cpuhotplug_05.sh b/cpuhotplug/cpuhotplug_05.sh index 4042f2c..53bc48e 100755 --- a/cpuhotplug/cpuhotplug_05.sh +++ b/cpuhotplug/cpuhotplug_05.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,15 +25,14 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh +. ../include/functions.sh
check_procinfo() { - local cpu=$1 - local cpuid=${cpu:3} - local ret= + cpu=$1 + cpuid=$(echo $cpu | awk '{print substr($0,4)}')
- if [ "$cpu" == "cpu0" ]; then - is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 + if [ "$cpu" = "cpu0" ]; then + is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 fi
set_offline $cpu diff --git a/cpuhotplug/cpuhotplug_06.sh b/cpuhotplug/cpuhotplug_06.sh index 0461e37..29870c2 100755 --- a/cpuhotplug/cpuhotplug_06.sh +++ b/cpuhotplug/cpuhotplug_06.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,18 +22,16 @@ # 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
check_procinfo() { - local cpu=$1 - local cpuid=${cpu:3} - local ret= - - if [ "$cpu" == "cpu0" ]; then - is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 + cpu=$1 + cpuid=$(echo $cpu | awk '{print substr($0,4)}') + + if [ "$cpu" = "cpu0" ]; then + is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 fi
set_offline $cpu diff --git a/cpuhotplug/cpuhotplug_07.sh b/cpuhotplug/cpuhotplug_07.sh index a3526be..3668871 100755 --- a/cpuhotplug/cpuhotplug_07.sh +++ b/cpuhotplug/cpuhotplug_07.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,20 +22,19 @@ # 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 TMPFILE=cpuhotplug_07.tmp
check_notification() { - local cpu=$1 - local cpuid=${cpu:3} - local pid= - local ret= + cpu=$1 + cpuid=$(echo $cpu | awk '{print substr($0,4)}') + pid= + ret=
- if [ "$cpu" == "cpu0" ]; then - is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 + if [ "$cpu" = "cpu0" ]; then + is_cpu0_hotplug_allowed $hotplug_allow_cpu0 || return 0 fi
# damn ! udevadm is buffering the output, we have to use a temp file diff --git a/cpuhotplug/cpuhotplug_08.sh b/cpuhotplug/cpuhotplug_08.sh index c6ef477..71164d6 100755 --- a/cpuhotplug/cpuhotplug_08.sh +++ b/cpuhotplug/cpuhotplug_08.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,23 +22,24 @@ # 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 + +randomize() { + random=$(od -A n -N 2 -t u2 /dev/urandom) + number=$(echo $random % $1)
-function randomize() { if [ $hotplug_allow_cpu0 -eq 0 ]; then - echo $[ ( $RANDOM % $1 ) + 1 ] - else - echo $[ ( $RANDOM % $1 ) ] + number=$(($number + 1)) fi + + echo $number }
random_stress() { - local cpu_present=$(cat /sys/devices/system/cpu/present | cut -d '-' -f 2) - local cpurand=$(randomize $cpu_present) - local ret= + cpu_present=$(cat /sys/devices/system/cpu/present | cut -d '-' -f 2) + cpurand=$(randomize $cpu_present)
# randomize will in range "1-$cpu_present) so cpu0 is ignored set_offline cpu$cpurand @@ -50,5 +51,5 @@ random_stress() { check "cpu$cpurand is online" "test $ret -eq 0" }
-for i in $(seq 1 100); do random_stress ; done +for i in $(seq 1 100); do random_stress; done test_status_show diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh index 9a9df25..aa1fb91 100755 --- a/cpuhotplug/cpuhotplug_sanity.sh +++ b/cpuhotplug/cpuhotplug_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,7 +32,6 @@ if [ $? -ne 0 ]; then fi
check_cpuhotplug_sysfs_entry() { - cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then diff --git a/cpuhotplug/z_sanity_check.sh b/cpuhotplug/z_sanity_check.sh index c39413e..98115a3 100755 --- a/cpuhotplug/z_sanity_check.sh +++ b/cpuhotplug/z_sanity_check.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,13 +22,12 @@ # Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) # - initial API and implementation # - # URL :
-source ../include/functions.sh +. ../include/functions.sh
sanity_check() { - local ret=$(cat $CPU_PATH/offline) + ret=$(cat $CPU_PATH/offline) if [ -z "$ret" ]; then return 0 else
Currently, the suspend test module is disabled by default, but make the suspend scripts more POSIX-compliant to be consistent with other scripts.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- include/suspend_functions.sh | 20 +++++++++----------- suspend/suspend_01.sh | 9 ++++----- suspend/suspend_02.sh | 9 ++++----- suspend/suspend_03.sh | 9 ++++----- suspend/suspend_04.sh | 11 +++++------ suspend/suspend_05.sh | 11 +++++------ suspend/suspend_sanity.sh | 4 ++-- 7 files changed, 33 insertions(+), 40 deletions(-)
diff --git a/include/suspend_functions.sh b/include/suspend_functions.sh index d5c8e2b..d59d4df 100644 --- a/include/suspend_functions.sh +++ b/include/suspend_functions.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Script to automate suspend / resume # @@ -33,7 +33,7 @@ # - hongbo.zhang@linaro.org, March, 2012 #
-source ./functions.sh +. ../include/functions.sh
LOGDIR='/var/lib/pm-utils' LOGFILE="$LOGDIR/stress.log" @@ -115,7 +115,7 @@ suspend_system () retry=30
while [ "$retry" -gt 0 ]; do - let "retry=$retry-1" + retry=$((retry - 1))
# Accumulate the dmesg delta. dmesg >"$LOGFILE.dmesg.B" @@ -237,7 +237,7 @@ ac_online()
ac_check() { - typeset ac_current=`ac_online` + ac_current=`ac_online`
if [ "$ac_becomes" -ne -1 -a "$ac_current" -ne -1 -a \ "$ac_current" -ne "$ac_becomes" ]; then @@ -254,9 +254,7 @@ phase_interactive=1
phase() { - typeset sleep - - let phase="$phase+1" + phase=$((phase + 1))
if [ "$ac_needed" -ne "$ac_is" ]; then case "$ac_needed" in @@ -267,12 +265,12 @@ phase() fi if [ "$timer_sleep" -gt 60 ]; then - let sleep="$timer_sleep / 60" - sleep="$sleep minutes" + sleep_calculated="$timer_sleep / 60" + sleep_calculated="$sleep_calculated minutes" else - sleep="$timer_sleep seconds" + sleep_calculated="$timer_sleep seconds" fi - echo "*** machine will suspend for $sleep" + echo "*** machine will suspend for $sleep_calculated"
if [ "$auto" -eq 1 ]; then : diff --git a/suspend/suspend_01.sh b/suspend/suspend_01.sh index 6ba8d41..8668d02 100755 --- a/suspend/suspend_01.sh +++ b/suspend/suspend_01.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,16 +22,15 @@ # Hongbo ZHANG hongbo.zhang@linaro.org (ST-Ericsson Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/suspend_functions.sh +. ../include/functions.sh +. ../include/suspend_functions.sh
if [ "$suspend_dbus" -eq 0 ]; then log_skip "dbus message suspend test not enabled" - exit 0 + return 0 fi
if [ -x /usr/bin/dbus-send ]; then diff --git a/suspend/suspend_02.sh b/suspend/suspend_02.sh index 666b6a5..ad6b3cb 100755 --- a/suspend/suspend_02.sh +++ b/suspend/suspend_02.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -26,12 +26,12 @@ # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/suspend_functions.sh +. ../include/functions.sh +. ../include/suspend_functions.sh
if [ "$suspend_pmsuspend" -eq 0 ]; then log_skip "pm-suspend test not enabled" - exit 0 + return 0 fi
if [ -x /usr/sbin/pm-suspend ]; then @@ -47,4 +47,3 @@ fi restore_trace test_status_show rm -f "$LOGFILE" - diff --git a/suspend/suspend_03.sh b/suspend/suspend_03.sh index 474d3f5..90f54cf 100755 --- a/suspend/suspend_03.sh +++ b/suspend/suspend_03.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,16 +22,15 @@ # Hongbo ZHANG hongbo.zhang@linaro.org (ST-Ericsson Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/suspend_functions.sh +. ../include/functions.sh +. ../include/suspend_functions.sh
if [ "$suspend_mem" -eq 0 ]; then log_skip "suspend to ram via sysfs not enabled" - exit 0 + return 0 fi
supported=$(cat /sys/power/state | grep "mem") diff --git a/suspend/suspend_04.sh b/suspend/suspend_04.sh index 1f62cab..e2e0ff4 100755 --- a/suspend/suspend_04.sh +++ b/suspend/suspend_04.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,21 +22,20 @@ # Hongbo ZHANG hongbo.zhang@linaro.org (ST-Ericsson Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/suspend_functions.sh +. ../include/functions.sh +. ../include/suspend_functions.sh
if [ "$suspend_ac" -eq 0 ]; then log_skip "suspend test involving ac power remove" - exit 0 + return 0 fi
if [ ! -d /proc/acpi/battery/ ]; then log_skip "acpi interface is not there" - exit 0 + return 0 fi
battery_count=`battery_count` diff --git a/suspend/suspend_05.sh b/suspend/suspend_05.sh index 9d5793e..98067cc 100755 --- a/suspend/suspend_05.sh +++ b/suspend/suspend_05.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -22,23 +22,22 @@ # Hongbo ZHANG hongbo.zhang@linaro.org (ST-Ericsson Corporation) # - initial API and implementation # - # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
-source ../include/functions.sh -source ../include/suspend_functions.sh +. ../include/functions.sh +. ../include/suspend_functions.sh
args_power_sleep=60
if [ "$suspend_power" -eq 0 ]; then log_skip "battery consumption test while suspend" - exit 0 + return 0 fi
if [ ! -d /proc/acpi/battery/ ]; then log_skip "acpi interface is not there" - exit 0 + return 0 fi
battery_count=`battery_count` diff --git a/suspend/suspend_sanity.sh b/suspend/suspend_sanity.sh index 0f2b5d5..f37eccb 100755 --- a/suspend/suspend_sanity.sh +++ b/suspend/suspend_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
Remove bashisms in utils_sanity.sh script.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- utils/utils_sanity.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/utils/utils_sanity.sh b/utils/utils_sanity.sh index 84f4905..c5bdcd7 100755 --- a/utils/utils_sanity.sh +++ b/utils/utils_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
Currently, the powertop test module is disabled by default, but make the powertop scripts POSIX-compliant to be consistent with other scripts.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- powertop/powertop_01.sh | 19 +++++++++---------- powertop/powertop_sanity.sh | 8 +++----- 2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/powertop/powertop_01.sh b/powertop/powertop_01.sh index c66b725..4e9ff71 100755 --- a/powertop/powertop_01.sh +++ b/powertop/powertop_01.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -25,15 +25,14 @@
# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#powerto...
-source ../include/functions.sh +. ../include/functions.sh
run_powertop() { - - local bin_path=`command -v powertop` - local report=csv - local seconds=10 - local iterations=2 - local report_name=PowerTOP*.csv + bin_path=`command -v powertop` + report=csv + seconds=10 + iterations=2 + report_name=PowerTOP*.csv
# remove old reports if exists rm -f $report_name @@ -44,8 +43,8 @@ run_powertop() { end_time=`date +%s`
# check if powertop run for desired time - let expected_time="$iterations * $seconds" - let actual_time="$end_time - $start_time" + expected_time="$iterations * $seconds" + actual_time="$end_time - $start_time"
check "if powertop run for $expected_time sec" "test $actual_time -ge $expected_time"
diff --git a/powertop/powertop_sanity.sh b/powertop/powertop_sanity.sh index 3ae3065..cb76b64 100755 --- a/powertop/powertop_sanity.sh +++ b/powertop/powertop_sanity.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # PM-QA validation test suite for the power management on Linux # @@ -23,12 +23,10 @@ # - initial API and implementation #
-source ../include/functions.sh +. ../include/functions.sh
check_powertop() { - - local bin_name=powertop - + bin_name=powertop command -v $bin_name >/dev/null 2>&1 && return 1 || return 0 }
Use the sort built-in function to ensure that scripts will be executed in order depending on make version.
See the following link for details on return value of the built-in wildcard function:
https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- Test.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Test.mk b/Test.mk index 66fe44b..2834fbb 100644 --- a/Test.mk +++ b/Test.mk @@ -21,8 +21,8 @@ # Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) # - initial API and implementation
-SNT=$(wildcard *sanity.sh) -TST=$(wildcard *[^{sanity}].sh) +SNT:=$(wildcard *[sanity].sh) +TST:=$(sort $(wildcard *[!sanity].sh)) LOG=$(TST:.sh=.log) CFLAGS?=-g -Wall -pthread CC?=gcc
Export hotplug_allow_cpu0 to resolve invalid comparison errors from cpuhotplug scripts in Android.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- Switches.sh | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/Switches.sh b/Switches.sh index cc59992..e01d4c5 100644 --- a/Switches.sh +++ b/Switches.sh @@ -9,3 +9,6 @@ export suspend_pmsuspend=1 export suspend_mem=1 export suspend_ac=0 export suspend_power=0 + +# Disable hotplugging cpu0 +export hotplug_allow_cpu0=0
Add cputopology_sanity script to check for topology entries for all cpus. Also, all test modules have a sanity script, so add one for cputopology test module.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cputopology/cputopology_sanity.sh | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 cputopology/cputopology_sanity.sh
diff --git a/cputopology/cputopology_sanity.sh b/cputopology/cputopology_sanity.sh new file mode 100755 index 0000000..1c6d784 --- /dev/null +++ b/cputopology/cputopology_sanity.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2014, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Lisa Nguyen lisa.nguyen@linaro.org +# - initial implementation +# + +. ../include/functions.sh + +is_root +if [ $? -ne 0 ]; then + log_skip "User is not root" + exit 0 +fi + +check_cputopology_sysfs_entry() { + for cpu in $cpus; do + cputopology_sysfs_dir="$CPU_PATH/$cpu/topology" + + test -d $cputopology_sysfs_dir + if [ $? -ne 0 ]; then + echo "cputopology entry not found. Skipping all cputopology tests" + skip_tests cputopology + return 0 + fi + done + + return 1 +} + +check_cputopology_sysfs_entry
1_sanity_check does not provide a meaningful name of what this script does. Rename 1_sanity_check.sh to cpuhotplug_00.sh to be the first subtest to check if all cpus are online before starting the remaining cpuhotplug tests.
Also, rename sanity_check() function to check_cpus_online() to make it clear of what the function does.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpuhotplug/1_sanity_check.sh | 39 --------------------------------------- cpuhotplug/cpuhotplug_00.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 39 deletions(-) delete mode 100755 cpuhotplug/1_sanity_check.sh create mode 100755 cpuhotplug/cpuhotplug_00.sh
diff --git a/cpuhotplug/1_sanity_check.sh b/cpuhotplug/1_sanity_check.sh deleted file mode 100755 index d4bc02a..0000000 --- a/cpuhotplug/1_sanity_check.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# PM-QA validation test suite for the power management on Linux -# -# Copyright (C) 2011, Linaro Limited. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributors: -# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) -# - initial API and implementation -# -# URL : - -. ../include/functions.sh - -sanity_check() { - ret=$(cat $CPU_PATH/offline) - if [ -z "$ret" ]; then - return 0 - else - return 1 - fi -} - -check "all cpu are online" "sanity_check" -test_status_show diff --git a/cpuhotplug/cpuhotplug_00.sh b/cpuhotplug/cpuhotplug_00.sh new file mode 100755 index 0000000..9b2f1ee --- /dev/null +++ b/cpuhotplug/cpuhotplug_00.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) +# - initial API and implementation +# +# URL : + +. ../include/functions.sh + +check_cpus_online() { + ret=$(cat $CPU_PATH/offline) + if [ -z "$ret" ]; then + return 0 + else + return 1 + fi +} + +check "all cpus are online" "check_cpus_online" +test_status_show
Rename z_sanity_check.sh script to cpuhotplug_09.sh to give it a more meaningful name and to check if all cpus are back online after running previous cpuhotplug tests.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpuhotplug/cpuhotplug_09.sh | 39 +++++++++++++++++++++++++++++++++++++++ cpuhotplug/z_sanity_check.sh | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100755 cpuhotplug/cpuhotplug_09.sh delete mode 100755 cpuhotplug/z_sanity_check.sh
diff --git a/cpuhotplug/cpuhotplug_09.sh b/cpuhotplug/cpuhotplug_09.sh new file mode 100755 index 0000000..d6fc0cc --- /dev/null +++ b/cpuhotplug/cpuhotplug_09.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) +# - initial API and implementation +# +# URL : + +. ../include/functions.sh + +check_cpus_online() { + ret=$(cat $CPU_PATH/offline) + if [ -z "$ret" ]; then + return 0 + else + return 1 + fi +} + +check "all cpus are back online" "check_cpus_online" +test_status_show diff --git a/cpuhotplug/z_sanity_check.sh b/cpuhotplug/z_sanity_check.sh deleted file mode 100755 index 98115a3..0000000 --- a/cpuhotplug/z_sanity_check.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# PM-QA validation test suite for the power management on Linux -# -# Copyright (C) 2011, Linaro Limited. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributors: -# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) -# - initial API and implementation -# -# URL : - -. ../include/functions.sh - -sanity_check() { - ret=$(cat $CPU_PATH/offline) - if [ -z "$ret" ]; then - return 0 - else - return 1 - fi -} - -check "all cpu are back online" "sanity_check" -test_status_show
On Tue, Jan 20, 2015 at 6:06 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Rename z_sanity_check.sh script to cpuhotplug_09.sh to give it a more meaningful name and to check if all cpus are back online after running previous cpuhotplug tests.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
cpuhotplug/cpuhotplug_09.sh | 39 +++++++++++++++++++++++++++++++++++++++
Rename to 99 instead of 09 so that you don't have to change the number if you add another hotplug test.
cpuhotplug/z_sanity_check.sh | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100755 cpuhotplug/cpuhotplug_09.sh delete mode 100755 cpuhotplug/z_sanity_check.sh
diff --git a/cpuhotplug/cpuhotplug_09.sh b/cpuhotplug/cpuhotplug_09.sh new file mode 100755 index 0000000..d6fc0cc --- /dev/null +++ b/cpuhotplug/cpuhotplug_09.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) +# - initial API and implementation +# +# URL :
+. ../include/functions.sh
+check_cpus_online() {
ret=$(cat $CPU_PATH/offline)
if [ -z "$ret" ]; then
return 0
else
return 1
fi
+}
+check "all cpus are back online" "check_cpus_online" +test_status_show diff --git a/cpuhotplug/z_sanity_check.sh b/cpuhotplug/z_sanity_check.sh deleted file mode 100755 index 98115a3..0000000 --- a/cpuhotplug/z_sanity_check.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# PM-QA validation test suite for the power management on Linux -# -# Copyright (C) 2011, Linaro Limited. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributors: -# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) -# - initial API and implementation -# -# URL :
-. ../include/functions.sh
-sanity_check() {
ret=$(cat $CPU_PATH/offline)
if [ -z "$ret" ]; then
return 0
else
return 1
fi
-}
-check "all cpu are back online" "sanity_check"
-test_status_show
1.7.9.5
On 19 January 2015 at 22:57, Amit Kucheria amit.kucheria@linaro.org wrote:
On Tue, Jan 20, 2015 at 6:06 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Rename z_sanity_check.sh script to cpuhotplug_09.sh to give it a more meaningful name and to check if all cpus are back online after running previous cpuhotplug tests.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
cpuhotplug/cpuhotplug_09.sh | 39 +++++++++++++++++++++++++++++++++++++++
Rename to 99 instead of 09 so that you don't have to change the number if you add another hotplug test.
Okay that will be an easy fix.
cpuhotplug/z_sanity_check.sh | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100755 cpuhotplug/cpuhotplug_09.sh delete mode 100755 cpuhotplug/z_sanity_check.sh
diff --git a/cpuhotplug/cpuhotplug_09.sh b/cpuhotplug/cpuhotplug_09.sh new file mode 100755 index 0000000..d6fc0cc --- /dev/null +++ b/cpuhotplug/cpuhotplug_09.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) +# - initial API and implementation +# +# URL :
+. ../include/functions.sh
+check_cpus_online() {
ret=$(cat $CPU_PATH/offline)
if [ -z "$ret" ]; then
return 0
else
return 1
fi
+}
+check "all cpus are back online" "check_cpus_online" +test_status_show diff --git a/cpuhotplug/z_sanity_check.sh b/cpuhotplug/z_sanity_check.sh deleted file mode 100755 index 98115a3..0000000 --- a/cpuhotplug/z_sanity_check.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# PM-QA validation test suite for the power management on Linux -# -# Copyright (C) 2011, Linaro Limited. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributors: -# Daniel Lezcano daniel.lezcano@linaro.org (IBM Corporation) -# - initial API and implementation -# -# URL :
-. ../include/functions.sh
-sanity_check() {
ret=$(cat $CPU_PATH/offline)
if [ -z "$ret" ]; then
return 0
else
return 1
fi
-}
-check "all cpu are back online" "sanity_check"
-test_status_show
1.7.9.5
After renaming 1_sanity_script.sh and z_sanity_script.sh to cpuhotplug_00.sh and cpuhotplug_09.sh respectively, provide the text files for these scripts that contain the description of these tests.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpuhotplug/1_sanity_check.txt | 1 - cpuhotplug/cpuhotplug_00.txt | 1 + cpuhotplug/cpuhotplug_09.txt | 1 + cpuhotplug/z_sanity_check.txt | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 cpuhotplug/1_sanity_check.txt create mode 100644 cpuhotplug/cpuhotplug_00.txt create mode 100644 cpuhotplug/cpuhotplug_09.txt delete mode 100644 cpuhotplug/z_sanity_check.txt
diff --git a/cpuhotplug/1_sanity_check.txt b/cpuhotplug/1_sanity_check.txt deleted file mode 100644 index 8930419..0000000 --- a/cpuhotplug/1_sanity_check.txt +++ /dev/null @@ -1 +0,0 @@ -ensure all the cpus are online before the tests diff --git a/cpuhotplug/cpuhotplug_00.txt b/cpuhotplug/cpuhotplug_00.txt new file mode 100644 index 0000000..9a05396 --- /dev/null +++ b/cpuhotplug/cpuhotplug_00.txt @@ -0,0 +1 @@ +check if all cpus are online diff --git a/cpuhotplug/cpuhotplug_09.txt b/cpuhotplug/cpuhotplug_09.txt new file mode 100644 index 0000000..d6b0119 --- /dev/null +++ b/cpuhotplug/cpuhotplug_09.txt @@ -0,0 +1 @@ +check if all cpus are back online diff --git a/cpuhotplug/z_sanity_check.txt b/cpuhotplug/z_sanity_check.txt deleted file mode 100644 index 2b6c2fa..0000000 --- a/cpuhotplug/z_sanity_check.txt +++ /dev/null @@ -1 +0,0 @@ -ensure all the cpus are online when the tests are finished
Remove thermal_try_max variable since it is not used anywhere in PM-QA nor does its value change at any point.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- Switches.sh | 3 --- 1 file changed, 3 deletions(-)
diff --git a/Switches.sh b/Switches.sh index e01d4c5..111d5cb 100644 --- a/Switches.sh +++ b/Switches.sh @@ -1,8 +1,5 @@ # These are switches to enable/disable some tests.
-# Thermal tests -export thermal_try_max=0 - # Suspend tests export suspend_dbus=0 export suspend_pmsuspend=1
Rewrite the logic to check for userspace and powersave governors, so that the test_status_show() function gets called before these cpufreq scripts exit to display the final results.
Without this change, these cpufreq scripts will run on Android but will not print "cpufreq_xx: pass/fail/skip" at the end.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpufreq/cpufreq_06.sh | 11 +++++------ cpufreq/cpufreq_08.sh | 5 ++--- cpufreq/cpufreq_09.sh | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh index 9159c9e..75369bf 100755 --- a/cpufreq/cpufreq_06.sh +++ b/cpufreq/cpufreq_06.sh @@ -98,16 +98,15 @@ check_deviation() { supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") if [ -z "$supported" ]; then log_skip "userspace not supported" - return 0 -fi +else + save_governors + save_frequencies
-save_governors -save_frequencies + for_each_cpu check_deviation +fi
trap "restore_frequencies; restore_governors; sigtrap" HUP INT TERM
-for_each_cpu check_deviation - restore_frequencies restore_governors test_status_show diff --git a/cpufreq/cpufreq_08.sh b/cpufreq/cpufreq_08.sh index e43c002..bfa984c 100755 --- a/cpufreq/cpufreq_08.sh +++ b/cpufreq/cpufreq_08.sh @@ -65,12 +65,11 @@ save_governors supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") if [ -z "$supported" ]; then log_skip "userspace not supported" - return 0 +else + for_each_cpu check_userspace fi
trap "restore_governors; sigtrap" HUP INT TERM
-for_each_cpu check_userspace - restore_governors test_status_show diff --git a/cpufreq/cpufreq_09.sh b/cpufreq/cpufreq_09.sh index 7a3cd26..3356e83 100755 --- a/cpufreq/cpufreq_09.sh +++ b/cpufreq/cpufreq_09.sh @@ -63,11 +63,11 @@ save_governors supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "powersave") if [ -z "$supported" ]; then log_skip "powersave not supported" - return 1 +else + for_each_cpu check_powersave fi
trap "restore_governors; sigtrap" HUP INT TERM
-for_each_cpu check_powersave restore_governors test_status_show
Update the Android makefiles in cputopology and cpuhotplug since a few subtests have been added or renamed. Remove unnecessary whitespace detected by checkpatch as well.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpufreq/Android.mk | 2 +- cpuhotplug/Android.mk | 18 ++---------------- cpuidle/Android.mk | 4 ++-- cputopology/Android.mk | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/cpufreq/Android.mk b/cpufreq/Android.mk index 15d6d9e..4f1bd34 100644 --- a/cpufreq/Android.mk +++ b/cpufreq/Android.mk @@ -5,7 +5,7 @@ module_name = cpufreq
define $(module_name)_add_executable include $(CLEAR_VARS) - LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh diff --git a/cpuhotplug/Android.mk b/cpuhotplug/Android.mk index fabb70a..e74170f 100644 --- a/cpuhotplug/Android.mk +++ b/cpuhotplug/Android.mk @@ -5,7 +5,7 @@ module_name = cpuhotplug
define $(module_name)_add_executable include $(CLEAR_VARS) - LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh @@ -14,19 +14,5 @@ define $(module_name)_add_executable include $(BUILD_PREBUILT) endef
-test_num := sanity 01 02 03 04 05 06 07 08 +test_num := sanity 00 01 02 03 04 05 06 07 08 09 $(foreach item,$(test_num),$(eval $(call $(module_name)_add_executable, $(module_name)_$(item)))) - -define $(module_name)_etc_add_executable - include $(CLEAR_VARS) - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE_CLASS := tests - LOCAL_MODULE := $1.sh - systemtarball: $1.sh - LOCAL_SRC_FILES := $1.sh - LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/pm-qa/$(module_name) - include $(BUILD_PREBUILT) -endef - -test_names := 1_sanity_check z_sanity_check -$(foreach item,$(test_names),$(eval $(call $(module_name)_etc_add_executable, $(item)))) diff --git a/cpuidle/Android.mk b/cpuidle/Android.mk index 1d1292c..cf22f18 100644 --- a/cpuidle/Android.mk +++ b/cpuidle/Android.mk @@ -5,7 +5,7 @@ module_name = cpuidle
define $(module_name)_add_executable include $(CLEAR_VARS) - LOCAL_MODULE_TAGS := optional + LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh @@ -21,7 +21,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := cpuidle_killer systemtarball: cpuidle_killer LOCAL_SRC_FILES:= cpuidle_killer.c -LOCAL_STATIC_LIBRARIES := libcutils libc +LOCAL_STATIC_LIBRARIES := libcutils libc LOCAL_MODULE_TAGS := tests LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/pm-qa/$(module_name) include $(BUILD_EXECUTABLE) diff --git a/cputopology/Android.mk b/cputopology/Android.mk index d5b5480..3555496 100644 --- a/cputopology/Android.mk +++ b/cputopology/Android.mk @@ -14,5 +14,5 @@ define $(module_name)_add_executable include $(BUILD_PREBUILT) endef
-test_num := 01 02 +test_num := sanity 01 02 $(foreach item,$(test_num),$(eval $(call $(module_name)_add_executable, $(module_name)_$(item))))
On Tue, Jan 20, 2015 at 6:06 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Update the Android makefiles in cputopology and cpuhotplug since a few subtests have been added or renamed. Remove unnecessary whitespace detected by checkpatch as well.
Have you ensured that the test spec[1] corresponds to the current script numbering?
[1] https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
cpufreq/Android.mk | 2 +- cpuhotplug/Android.mk | 18 ++---------------- cpuidle/Android.mk | 4 ++-- cputopology/Android.mk | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/cpufreq/Android.mk b/cpufreq/Android.mk index 15d6d9e..4f1bd34 100644 --- a/cpufreq/Android.mk +++ b/cpufreq/Android.mk @@ -5,7 +5,7 @@ module_name = cpufreq
define $(module_name)_add_executable include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh
diff --git a/cpuhotplug/Android.mk b/cpuhotplug/Android.mk index fabb70a..e74170f 100644 --- a/cpuhotplug/Android.mk +++ b/cpuhotplug/Android.mk @@ -5,7 +5,7 @@ module_name = cpuhotplug
define $(module_name)_add_executable include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh
@@ -14,19 +14,5 @@ define $(module_name)_add_executable include $(BUILD_PREBUILT) endef
-test_num := sanity 01 02 03 04 05 06 07 08 +test_num := sanity 00 01 02 03 04 05 06 07 08 09 $(foreach item,$(test_num),$(eval $(call $(module_name)_add_executable, $(module_name)_$(item))))
-define $(module_name)_etc_add_executable
- include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_CLASS := tests
- LOCAL_MODULE := $1.sh
- systemtarball: $1.sh
- LOCAL_SRC_FILES := $1.sh
- LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/pm-qa/$(module_name)
- include $(BUILD_PREBUILT)
-endef
-test_names := 1_sanity_check z_sanity_check -$(foreach item,$(test_names),$(eval $(call $(module_name)_etc_add_executable, $(item)))) diff --git a/cpuidle/Android.mk b/cpuidle/Android.mk index 1d1292c..cf22f18 100644 --- a/cpuidle/Android.mk +++ b/cpuidle/Android.mk @@ -5,7 +5,7 @@ module_name = cpuidle
define $(module_name)_add_executable include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh
@@ -21,7 +21,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := cpuidle_killer systemtarball: cpuidle_killer LOCAL_SRC_FILES:= cpuidle_killer.c -LOCAL_STATIC_LIBRARIES := libcutils libc +LOCAL_STATIC_LIBRARIES := libcutils libc LOCAL_MODULE_TAGS := tests LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/pm-qa/$(module_name) include $(BUILD_EXECUTABLE) diff --git a/cputopology/Android.mk b/cputopology/Android.mk index d5b5480..3555496 100644 --- a/cputopology/Android.mk +++ b/cputopology/Android.mk @@ -14,5 +14,5 @@ define $(module_name)_add_executable include $(BUILD_PREBUILT) endef
-test_num := 01 02 +test_num := sanity 01 02 $(foreach item,$(test_num),$(eval $(call $(module_name)_add_executable, $(module_name)_$(item)))) -- 1.7.9.5
On 19 January 2015 at 22:59, Amit Kucheria amit.kucheria@linaro.org wrote:
On Tue, Jan 20, 2015 at 6:06 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Update the Android makefiles in cputopology and cpuhotplug since a few subtests have been added or renamed. Remove unnecessary whitespace detected by checkpatch as well.
Have you ensured that the test spec[1] corresponds to the current script numbering?
[1] https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
Thanks for the reminder. It's on my to-do list to update the test specs since some test cases don't exist anymore (like the ones in the suspend module). Then I will add the new ones with their descriptions.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
cpufreq/Android.mk | 2 +- cpuhotplug/Android.mk | 18 ++---------------- cpuidle/Android.mk | 4 ++-- cputopology/Android.mk | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/cpufreq/Android.mk b/cpufreq/Android.mk index 15d6d9e..4f1bd34 100644 --- a/cpufreq/Android.mk +++ b/cpufreq/Android.mk @@ -5,7 +5,7 @@ module_name = cpufreq
define $(module_name)_add_executable include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh
diff --git a/cpuhotplug/Android.mk b/cpuhotplug/Android.mk index fabb70a..e74170f 100644 --- a/cpuhotplug/Android.mk +++ b/cpuhotplug/Android.mk @@ -5,7 +5,7 @@ module_name = cpuhotplug
define $(module_name)_add_executable include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh
@@ -14,19 +14,5 @@ define $(module_name)_add_executable include $(BUILD_PREBUILT) endef
-test_num := sanity 01 02 03 04 05 06 07 08 +test_num := sanity 00 01 02 03 04 05 06 07 08 09 $(foreach item,$(test_num),$(eval $(call $(module_name)_add_executable, $(module_name)_$(item))))
-define $(module_name)_etc_add_executable
- include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_CLASS := tests
- LOCAL_MODULE := $1.sh
- systemtarball: $1.sh
- LOCAL_SRC_FILES := $1.sh
- LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/pm-qa/$(module_name)
- include $(BUILD_PREBUILT)
-endef
-test_names := 1_sanity_check z_sanity_check -$(foreach item,$(test_names),$(eval $(call $(module_name)_etc_add_executable, $(item)))) diff --git a/cpuidle/Android.mk b/cpuidle/Android.mk index 1d1292c..cf22f18 100644 --- a/cpuidle/Android.mk +++ b/cpuidle/Android.mk @@ -5,7 +5,7 @@ module_name = cpuidle
define $(module_name)_add_executable include $(CLEAR_VARS)
- LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := tests LOCAL_MODULE := $1.sh systemtarball: $1.sh
@@ -21,7 +21,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := cpuidle_killer systemtarball: cpuidle_killer LOCAL_SRC_FILES:= cpuidle_killer.c -LOCAL_STATIC_LIBRARIES := libcutils libc +LOCAL_STATIC_LIBRARIES := libcutils libc LOCAL_MODULE_TAGS := tests LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/pm-qa/$(module_name) include $(BUILD_EXECUTABLE) diff --git a/cputopology/Android.mk b/cputopology/Android.mk index d5b5480..3555496 100644 --- a/cputopology/Android.mk +++ b/cputopology/Android.mk @@ -14,5 +14,5 @@ define $(module_name)_add_executable include $(BUILD_PREBUILT) endef
-test_num := 01 02 +test_num := sanity 01 02 $(foreach item,$(test_num),$(eval $(call $(module_name)_add_executable, $(module_name)_$(item)))) -- 1.7.9.5
On Tue, Jan 20, 2015 at 6:06 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
[ It's been long overdue and PM-QA gets a makeover... ]
Indeed.
This patchset primarily fixes Linaro Bug# 772 (https://bugs.linaro.org/show_bug.cgi?id=772) to remove bashisms in all PM-QA scripts. These scripts will run on Android, Openembedded, and Ubuntu.
Sorry, but I don't like the way you've split up patches 1-9 by directory. Can you merge them back and split them up by "change" across directories. (Great use for git add -p)
e.g. All bash -> sh changes can be one patch, all replacing source with . could be another and so on. This makes it easier to review similar changes together. Use your judgement to merge several trivial changes together in one patch.
-#!/bin/bash +#!/bin/sh
-source ../include/functions.sh +. ../include/functions.sh
Cleanups have been done to remove redundant code, improve readability, and resolve syntax errors that were not detected before.
Next steps:
Once this patchset has been reviewed and acked, the following steps will be taken:
- Submit a patch to update the release tag on the pwrmgmt
test definitions to pm-qa-v0.5.0
- Submit a patch to update the pm-qa script
(https://git.linaro.org/qa/test-definitions.git/blob/HEAD:/common/scripts/pm-...) used to run PM-QA on Android by removing unnecessary busybox sym links and replace suspend test module with thermal in directory list.
- Investigate further on why pandaboards do not like the
cpuidle_03 test case.
Comments and/or questions are highly encouraged.
Lisa Nguyen (18): functions: Remove bashisms in function scripts cpuidle: Remove bashisms in cpuidle test module cputopology: Remove bashisms in cputopology test module cpufreq: Remove bashisms in cpufreq test module thermal: Remove bashisms in thermal test module cpuhotplug: Remove bashisms in cpuhotplug scripts suspend: Remove bashisms in suspend test module utils: Remove bashisms in utils_sanity.sh powertop: Remove bashisms in powertop test module Test.mk: Add sort function Switches: Export hotplug_allow_cpu0 Add cputopology_sanity script cpuhotplug: Rename 1_sanity_check.sh to cpuhotplug_00.sh cpuhotplug: Rename z_sanity_check.sh to cpuhotplug_09.sh Add descriptions for cpuhotplug_00.sh and cpuhotplug_09.sh Switches: Remove thermal_try_max variable cpufreq: Rewrite logic to check for userspace and powersave governors Android.mk: Update test numbers and remove whitespace
Switches.sh | 6 +- Test.mk | 4 +- cpufreq/Android.mk | 2 +- cpufreq/cpufreq_01.sh | 4 +- cpufreq/cpufreq_02.sh | 5 +- cpufreq/cpufreq_03.sh | 13 +- cpufreq/cpufreq_04.sh | 16 ++- cpufreq/cpufreq_05.sh | 24 ++-- cpufreq/cpufreq_06.sh | 59 ++++----- cpufreq/cpufreq_07.sh | 48 ++++--- cpufreq/cpufreq_08.sh | 31 ++--- cpufreq/cpufreq_09.sh | 27 ++-- cpufreq/cpufreq_sanity.sh | 9 +- cpuhotplug/1_sanity_check.sh | 40 ------ cpuhotplug/1_sanity_check.txt | 1 - cpuhotplug/Android.mk | 18 +-- cpuhotplug/cpuhotplug_00.sh | 39 ++++++ cpuhotplug/cpuhotplug_00.txt | 1 + cpuhotplug/cpuhotplug_01.sh | 5 +- cpuhotplug/cpuhotplug_02.sh | 21 ++-- cpuhotplug/cpuhotplug_03.sh | 15 ++- cpuhotplug/cpuhotplug_04.sh | 21 ++-- cpuhotplug/cpuhotplug_05.sh | 13 +- cpuhotplug/cpuhotplug_06.sh | 16 ++- cpuhotplug/cpuhotplug_07.sh | 17 ++- cpuhotplug/cpuhotplug_08.sh | 23 ++-- cpuhotplug/cpuhotplug_09.sh | 39 ++++++ cpuhotplug/cpuhotplug_09.txt | 1 + cpuhotplug/cpuhotplug_sanity.sh | 5 +- cpuhotplug/z_sanity_check.sh | 40 ------ cpuhotplug/z_sanity_check.txt | 1 - cpuidle/Android.mk | 4 +- cpuidle/cpuidle_01.sh | 21 ++-- cpuidle/cpuidle_02.sh | 7 +- cpuidle/cpuidle_03.sh | 17 ++- cpuidle/cpuidle_sanity.sh | 9 +- cputopology/Android.mk | 2 +- cputopology/cputopology_01.sh | 9 +- cputopology/cputopology_02.sh | 5 +- cputopology/cputopology_sanity.sh | 49 ++++++++ include/functions.sh | 248 +++++++++++++++++-------------------- include/suspend_functions.sh | 24 ++-- include/thermal_functions.sh | 219 ++++++++++++++++---------------- powertop/powertop_01.sh | 19 ++- powertop/powertop_sanity.sh | 8 +- suspend/suspend_01.sh | 9 +- suspend/suspend_02.sh | 9 +- suspend/suspend_03.sh | 9 +- suspend/suspend_04.sh | 11 +- suspend/suspend_05.sh | 11 +- suspend/suspend_sanity.sh | 4 +- thermal/thermal_00.sh | 22 ++-- thermal/thermal_01.sh | 39 +++--- thermal/thermal_02.sh | 36 +++--- thermal/thermal_03.sh | 18 +-- thermal/thermal_04.sh | 37 +++--- thermal/thermal_05.sh | 30 ++--- thermal/thermal_06.sh | 92 +++++++------- thermal/thermal_sanity.sh | 7 +- utils/utils_sanity.sh | 4 +- 60 files changed, 759 insertions(+), 784 deletions(-) delete mode 100755 cpuhotplug/1_sanity_check.sh delete mode 100644 cpuhotplug/1_sanity_check.txt create mode 100755 cpuhotplug/cpuhotplug_00.sh create mode 100644 cpuhotplug/cpuhotplug_00.txt create mode 100755 cpuhotplug/cpuhotplug_09.sh create mode 100644 cpuhotplug/cpuhotplug_09.txt delete mode 100755 cpuhotplug/z_sanity_check.sh delete mode 100644 cpuhotplug/z_sanity_check.txt create mode 100755 cputopology/cputopology_sanity.sh
-- 1.7.9.5
On 19 January 2015 at 22:55, Amit Kucheria amit.kucheria@linaro.org wrote:
On Tue, Jan 20, 2015 at 6:06 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
[ It's been long overdue and PM-QA gets a makeover... ]
Indeed.
This patchset primarily fixes Linaro Bug# 772 (https://bugs.linaro.org/show_bug.cgi?id=772) to remove bashisms in all PM-QA scripts. These scripts will run on Android, Openembedded, and Ubuntu.
Sorry, but I don't like the way you've split up patches 1-9 by directory. Can you merge them back and split them up by "change" across directories. (Great use for git add -p) e.g. All bash -> sh changes can be one patch, all replacing source with . could be another and so on. This makes it easier to review similar changes together. Use your judgement to merge several trivial changes together in one patch.
-#!/bin/bash +#!/bin/sh
-source ../include/functions.sh +. ../include/functions.sh
Sure, not a problem. Will remerge and split into logical changes instead for v2.
Thanks for the feedback.
Cleanups have been done to remove redundant code, improve readability, and resolve syntax errors that were not detected before.
Next steps:
Once this patchset has been reviewed and acked, the following steps will be taken:
- Submit a patch to update the release tag on the pwrmgmt
test definitions to pm-qa-v0.5.0
- Submit a patch to update the pm-qa script
(https://git.linaro.org/qa/test-definitions.git/blob/HEAD:/common/scripts/pm-...) used to run PM-QA on Android by removing unnecessary busybox sym links and replace suspend test module with thermal in directory list.
- Investigate further on why pandaboards do not like the
cpuidle_03 test case.
Comments and/or questions are highly encouraged.
Lisa Nguyen (18): functions: Remove bashisms in function scripts cpuidle: Remove bashisms in cpuidle test module cputopology: Remove bashisms in cputopology test module cpufreq: Remove bashisms in cpufreq test module thermal: Remove bashisms in thermal test module cpuhotplug: Remove bashisms in cpuhotplug scripts suspend: Remove bashisms in suspend test module utils: Remove bashisms in utils_sanity.sh powertop: Remove bashisms in powertop test module Test.mk: Add sort function Switches: Export hotplug_allow_cpu0 Add cputopology_sanity script cpuhotplug: Rename 1_sanity_check.sh to cpuhotplug_00.sh cpuhotplug: Rename z_sanity_check.sh to cpuhotplug_09.sh Add descriptions for cpuhotplug_00.sh and cpuhotplug_09.sh Switches: Remove thermal_try_max variable cpufreq: Rewrite logic to check for userspace and powersave governors Android.mk: Update test numbers and remove whitespace
Switches.sh | 6 +- Test.mk | 4 +- cpufreq/Android.mk | 2 +- cpufreq/cpufreq_01.sh | 4 +- cpufreq/cpufreq_02.sh | 5 +- cpufreq/cpufreq_03.sh | 13 +- cpufreq/cpufreq_04.sh | 16 ++- cpufreq/cpufreq_05.sh | 24 ++-- cpufreq/cpufreq_06.sh | 59 ++++----- cpufreq/cpufreq_07.sh | 48 ++++--- cpufreq/cpufreq_08.sh | 31 ++--- cpufreq/cpufreq_09.sh | 27 ++-- cpufreq/cpufreq_sanity.sh | 9 +- cpuhotplug/1_sanity_check.sh | 40 ------ cpuhotplug/1_sanity_check.txt | 1 - cpuhotplug/Android.mk | 18 +-- cpuhotplug/cpuhotplug_00.sh | 39 ++++++ cpuhotplug/cpuhotplug_00.txt | 1 + cpuhotplug/cpuhotplug_01.sh | 5 +- cpuhotplug/cpuhotplug_02.sh | 21 ++-- cpuhotplug/cpuhotplug_03.sh | 15 ++- cpuhotplug/cpuhotplug_04.sh | 21 ++-- cpuhotplug/cpuhotplug_05.sh | 13 +- cpuhotplug/cpuhotplug_06.sh | 16 ++- cpuhotplug/cpuhotplug_07.sh | 17 ++- cpuhotplug/cpuhotplug_08.sh | 23 ++-- cpuhotplug/cpuhotplug_09.sh | 39 ++++++ cpuhotplug/cpuhotplug_09.txt | 1 + cpuhotplug/cpuhotplug_sanity.sh | 5 +- cpuhotplug/z_sanity_check.sh | 40 ------ cpuhotplug/z_sanity_check.txt | 1 - cpuidle/Android.mk | 4 +- cpuidle/cpuidle_01.sh | 21 ++-- cpuidle/cpuidle_02.sh | 7 +- cpuidle/cpuidle_03.sh | 17 ++- cpuidle/cpuidle_sanity.sh | 9 +- cputopology/Android.mk | 2 +- cputopology/cputopology_01.sh | 9 +- cputopology/cputopology_02.sh | 5 +- cputopology/cputopology_sanity.sh | 49 ++++++++ include/functions.sh | 248 +++++++++++++++++-------------------- include/suspend_functions.sh | 24 ++-- include/thermal_functions.sh | 219 ++++++++++++++++---------------- powertop/powertop_01.sh | 19 ++- powertop/powertop_sanity.sh | 8 +- suspend/suspend_01.sh | 9 +- suspend/suspend_02.sh | 9 +- suspend/suspend_03.sh | 9 +- suspend/suspend_04.sh | 11 +- suspend/suspend_05.sh | 11 +- suspend/suspend_sanity.sh | 4 +- thermal/thermal_00.sh | 22 ++-- thermal/thermal_01.sh | 39 +++--- thermal/thermal_02.sh | 36 +++--- thermal/thermal_03.sh | 18 +-- thermal/thermal_04.sh | 37 +++--- thermal/thermal_05.sh | 30 ++--- thermal/thermal_06.sh | 92 +++++++------- thermal/thermal_sanity.sh | 7 +- utils/utils_sanity.sh | 4 +- 60 files changed, 759 insertions(+), 784 deletions(-) delete mode 100755 cpuhotplug/1_sanity_check.sh delete mode 100644 cpuhotplug/1_sanity_check.txt create mode 100755 cpuhotplug/cpuhotplug_00.sh create mode 100644 cpuhotplug/cpuhotplug_00.txt create mode 100755 cpuhotplug/cpuhotplug_09.sh create mode 100644 cpuhotplug/cpuhotplug_09.txt delete mode 100755 cpuhotplug/z_sanity_check.sh delete mode 100644 cpuhotplug/z_sanity_check.txt create mode 100755 cputopology/cputopology_sanity.sh
-- 1.7.9.5