aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLisa Nguyen <lisa.nguyen@linaro.org>2015-11-17 17:29:12 -0800
committerLisa Nguyen <lisa.nguyen@linaro.org>2015-11-19 17:34:09 -0800
commit71eb7a9236ef1a2c0e5eaed4430ae06bd57e6d35 (patch)
treec08ef480d7ce09c516fd3683baf655e69e254559
parente714553039fcac2471b2d222cfb3c08b17f52b6d (diff)
cpufreq: Rewrite __check_freq_deviation() function
Add the check to make sure that the array that stores frequency results is not empty before computing deviations. If the array is empty, return 1. Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
-rwxr-xr-xcpufreq/cpufreq_06.sh21
1 files changed, 12 insertions, 9 deletions
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh
index b86db34..b323dc8 100755
--- a/cpufreq/cpufreq_06.sh
+++ b/cpufreq/cpufreq_06.sh
@@ -59,20 +59,23 @@ compute_freq_ratio_sum() {
}
__check_freq_deviation() {
-
res=$(eval echo \$$freq_results_array$index)
- # compute deviation
- dev=$(echo $res $avg | awk '{printf "%.3f", (($1 - $2) / $2) * 100}')
+ if [ ! -z "$res" ]; then
+ # compute deviation
+ dev=$(echo $res $avg | awk '{printf "%.3f", (($1 - $2) / $2) * 100}')
- # change to absolute
- dev=$(echo $dev | awk '{ print ($1 >= 0) ? $1 : 0 - $1}')
+ # change to absolute
+ dev=$(echo $dev | awk '{ print ($1 >= 0) ? $1 : 0 - $1}')
- index=$((index + 1))
+ index=$((index + 1))
+ res=$(echo $dev | awk '{printf "%f", ($dev > 5.0)}')
- res=$(echo $dev | awk '{printf "%f", ($dev > 5.0)}')
- if [ "$res" = "1" ]; then
- return 1
+ if [ "$res" = "1" ]; then
+ return 1
+ fi
+ else
+ return 1
fi
return 0