diff options
author | hongbo.zhang <hongbo.zhang@linaro.com> | 2012-11-26 15:32:59 +0800 |
---|---|---|
committer | hongbo.zhang <hongbo.zhang@linaro.com> | 2012-11-28 17:50:36 +0800 |
commit | 9fec6ec9150237108dc1230f4056013c97f3669d (patch) | |
tree | f1ba9cd91dbe7bd3c1d7e82e3e1515d3bdf0145a | |
parent | 5e5c705c036be6bd1154451f051de8bd5c07ac4e (diff) |
thermal: kill heater program if test is terminated by signal
if the thermal test is terminated by signals such as an Ctrl+C operation, the
heat_cpu and also glmark(if there is any) should be terminated too.
Signed-off-by: hongbo.zhang <hongbo.zhang@linaro.com>
-rwxr-xr-x | thermal/thermal_03.sh | 22 | ||||
-rwxr-xr-x | thermal/thermal_04.sh | 11 | ||||
-rwxr-xr-x | thermal/thermal_06.sh | 22 |
3 files changed, 38 insertions, 17 deletions
diff --git a/thermal/thermal_03.sh b/thermal/thermal_03.sh index 86bdffd..5790320 100755 --- a/thermal/thermal_03.sh +++ b/thermal/thermal_03.sh @@ -30,14 +30,23 @@ source ../include/thermal_functions.sh CPU_HEAT_BIN=../utils/heat_cpu GPU_HEAT_BIN=/usr/bin/glmark2 +cpu_pid=0 +gpu_pid=0 + +heater_kill() { + if [ $cpu_pid != 0 ]; then + kill -9 $cpu_pid + fi + if [ $gpu_pid != 0 ]; then + kill -9 $gpu_pid + fi +} check_temperature_change() { local dirpath=$THERMAL_PATH/$1 local zone_name=$1 shift 1 - local cpu_pid=0 - local gpu_pid=0 local init_temp=$(cat $dirpath/temp) $CPU_HEAT_BIN & cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') @@ -55,13 +64,10 @@ check_temperature_change() { sleep 5 local final_temp=$(cat $dirpath/temp) - if [ $cpu_pid != 0 ]; then - kill -9 $cpu_pid - fi - if [ $gpu_pid != 0 ]; then - kill -9 $gpu_pid - fi + heater_kill check "temperature variation with load" "test $final_temp -gt $init_temp" } +trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM + for_each_thermal_zone check_temperature_change diff --git a/thermal/thermal_04.sh b/thermal/thermal_04.sh index 52882e2..8f0dee7 100755 --- a/thermal/thermal_04.sh +++ b/thermal/thermal_04.sh @@ -28,6 +28,13 @@ source ../include/functions.sh source ../include/thermal_functions.sh HEAT_CPU_MODERATE=../utils/heat_cpu +pid=0 + +heater_kill() { + if [ $pid != 0 ]; then + kill -9 $pid + fi +} verify_cooling_device_temp_change() { local dirpath=$THERMAL_PATH/$1 @@ -65,9 +72,11 @@ verify_cooling_device_temp_change() { "test $cool_temp -ge 0" count=$((count+1)) done - kill -9 $pid + heater_kill echo $prev_mode_val > $tzonepath/mode echo $prev_state_val > $dirpath/cur_state } +trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM + for_each_cooling_device verify_cooling_device_temp_change diff --git a/thermal/thermal_06.sh b/thermal/thermal_06.sh index 1497bcc..8013b82 100755 --- a/thermal/thermal_06.sh +++ b/thermal/thermal_06.sh @@ -32,6 +32,17 @@ CPU_HEAT_BIN=../utils/heat_cpu GPU_HEAT_BIN=/usr/bin/glmark2 TEST_LOOP=100 TRIP_CROSSED_COUNT= +cpu_pid=0 +gpu_pid=0 + +heater_kill() { + if [ $cpu_pid != 0 ]; then + kill -9 $cpu_pid + fi + if [ $gpu_pid != 0 ]; then + kill -9 $gpu_pid + fi +} check_trip_point_change() { local dirpath=$THERMAL_PATH/$1 @@ -43,8 +54,6 @@ check_trip_point_change() { local trip_temp=0 local trip_cross= local trip_id= - local cpu_pid=0 - local gpu_pid=0 local trip_type=0 local trip_type_path=0 $CPU_HEAT_BIN & @@ -94,12 +103,9 @@ check_trip_point_change() { index=$((index + 1)) done - if [ $cpu_pid != 0 ]; then - kill -9 $cpu_pid - fi - if [ $gpu_pid != 0 ]; then - kill -9 $gpu_pid - fi + heater_kill } +trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM + for_each_thermal_zone check_trip_point_change |