Hello Amit,
I noticed that the current scripts may be missing some of the thermal objects. Also some tests were failing because of the manipulation of the 'ps' command output.
They have been tested on panda board and with these two patches, I see the pass rate much higher.
Eduardo Valentin (2): Improve the way we check for running binaries thermal_functions: simplify the search for objects
include/thermal_functions.sh | 24 ++++++++++-------------- thermal/thermal_03.sh | 4 ++-- thermal/thermal_06.sh | 4 ++-- 3 files changed, 14 insertions(+), 18 deletions(-)
The current way we are check for running process may lead to wrong results. The 'ps | grep' command may return more than one line, which will cause a false result in the test comparison. Now we use 'pidof' to check if we have the process running.
Signed-off-by: Eduardo Valentin eduardo.valentin@ti.com --- thermal/thermal_03.sh | 4 ++-- thermal/thermal_06.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/thermal/thermal_03.sh b/thermal/thermal_03.sh index 4bb3982..9c20372 100755 --- a/thermal/thermal_03.sh +++ b/thermal/thermal_03.sh @@ -40,11 +40,11 @@ check_temperature_change() { local gpu_pid=0 local init_temp=$(cat $dirpath/temp) $CPU_HEAT_BIN & - cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') + cpu_pid=$(pidof heat_cpu) check "start cpu heat binary" "test $cpu_pid -ne 0"
$GPU_HEAT_BIN & - gpu_pid=$(ps | grep $GPU_HEAT_BIN| awk '{print $1}') + gpu_pid=$(pidof $GPU_HEAT_BIN) check "start gpu heat binary" "test $gpu_pid -ne 0" sleep 5 local final_temp=$(cat $dirpath/temp) diff --git a/thermal/thermal_06.sh b/thermal/thermal_06.sh index 0960cdb..ca1d033 100755 --- a/thermal/thermal_06.sh +++ b/thermal/thermal_06.sh @@ -48,11 +48,11 @@ check_trip_point_change() { local trip_type=0 local trip_type_path=0 $CPU_HEAT_BIN & - cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') + cpu_pid=$(pidof heat_cpu) check "start cpu heat binary" "test $cpu_pid -ne 0"
$GPU_HEAT_BIN & - gpu_pid=$(ps | grep $GPU_HEAT_BIN| awk '{print $1}') + gpu_pid=$(pidof $GPU_HEAT_BIN) check "start gpu heat binary" "test $gpu_pid -ne 0"
local index=0
This patch simplifies the way we search for objects inside the thermal sysfs tree. In some cases, the current code is not listing all expected objects. With this simplification, all objects are now listed.
Signed-off-by: Eduardo Valentin eduardo.valentin@ti.com --- include/thermal_functions.sh | 24 ++++++++++-------------- 1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/include/thermal_functions.sh b/include/thermal_functions.sh index 692529c..84d2ed6 100644 --- a/include/thermal_functions.sh +++ b/include/thermal_functions.sh @@ -57,9 +57,8 @@ for_each_thermal_zone() { local func=$1 shift 1
- zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + zones=$(ls $THERMAL_PATH | grep "thermal_zone")
- ALL_ZONE=$zone for zone in $zones; do INC=0 $func $zone $@ @@ -73,10 +72,8 @@ get_total_trip_point_of_zone() { local zone_path=$THERMAL_PATH/$1 local count=0 shift 1 - trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") - for trip in $trips; do - count=$((count + 1)) - done + count=$(ls $zone_path/trip_point_*_temp | wc -l) + return $count }
@@ -87,7 +84,7 @@ for_each_trip_point_of_zone() { local func=$2 local zone_name=$1 shift 2 - trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") + trips=$(ls $zone_path/trip_point_*_temp) for trip in $trips; do $func $zone_name $count count=$((count + 1)) @@ -102,7 +99,7 @@ for_each_binding_of_zone() { local func=$2 local zone_name=$1 shift 2 - trips=$(ls $zone_path | grep "cdev['$MAX_CDEV']_trip_point") + trips=$(ls $zone_path/cdev*_trip_point) for trip in $trips; do $func $zone_name $count count=$((count + 1)) @@ -124,7 +121,7 @@ check_valid_binding() { shift 2
log_begin "checking $descr" - if [ $trip_point > $trip_point_max ]; then + if [ $trip_point -ge $trip_point_max ]; then log_end "fail" return 1 fi @@ -141,7 +138,7 @@ validate_trip_bindings() { shift 2
check_file $trip_point $dirpath || return 1 - check_valid_binding $trip_point $zone_name || return 1 + check_valid_binding $bind_no $zone_name || return 1 }
validate_trip_level() { @@ -162,9 +159,8 @@ for_each_cooling_device() { local func=$1 shift 1
- devices=$(ls $THERMAL_PATH | grep "cooling_device['$MAX_CDEV']") + devices=$(ls $THERMAL_PATH | grep "cooling_device")
- ALL_DEVICE=$devices for device in $devices; do INC=0 $func $device $@ @@ -218,7 +214,7 @@ disable_all_thermal_zones() { mode_list= local index=0
- local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone") for zone in $th_zones; do mode_list[$index]=$(cat $THERMAL_PATH/$zone/mode) index=$((index + 1)) @@ -231,7 +227,7 @@ enable_all_thermal_zones() {
local index=0
- local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone") for zone in $th_zones; do echo $mode_list[$index] > $THERMAL_PATH/$zone/mode index=$((index + 1))