aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaul Romero <saul.romero@arm.com>2016-05-31 16:50:54 +0100
committerLisa Nguyen <lisa.nguyen@linaro.org>2016-06-20 18:06:17 -0700
commit2ede55868db2707d021ae78fcc209f6a9e6a6dc7 (patch)
tree504c8980891a43373c2f98d28eefde77331527c0
parentabf5708d280ea32aeab8c4a1998b4376c824b344 (diff)
downloadpm-qa-2ede55868db2707d021ae78fcc209f6a9e6a6dc7.tar.gz
cpufreq: fixed array initializations to calculate freq deviation
Resolve 'err' messages by making changes to calculate sum and average of frequency measurements in cpufreq_06 test. In the function 'compute_freq_ratio' the frequency is stored in an array of variables by indirect reference (http://www.tldp.org/LDP/abs/html/ivr.html) but the variable 'index' that points to next element in the array is initialized to 0 every time hence overriding the values. The same happens for the function 'compute_freq_ratio_sum' where the 'index' variable is always initialized to 0 and the variable 'sum' is always set to 0 not adding the subsequent values. Hence these initializations must be deleted from those functions and written into the 'function check_deviation' for keeping the correct values of frequency and calculations of average and summatory. With these changes the tests can now calculate the real values of average for the frequencies and the deviations can be tested and the tests now passes. This patch fixes this bug: https://bugs.linaro.org/show_bug.cgi?id=2232 Signed-off-by: Saul Romero <saul.romero@arm.com> [lisa: Edit parts of commit message.] Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
-rwxr-xr-xcpufreq/cpufreq_06.sh17
1 files changed, 3 insertions, 14 deletions
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh
index b323dc8..8f1dc22 100755
--- a/cpufreq/cpufreq_06.sh
+++ b/cpufreq/cpufreq_06.sh
@@ -31,7 +31,6 @@ CPUCYCLE=../utils/cpucycle
freq_results_array="results"
compute_freq_ratio() {
- index=0
cpu=$1
freq=$2
@@ -49,25 +48,18 @@ compute_freq_ratio() {
}
compute_freq_ratio_sum() {
- index=0
- sum=0
-
res=$(eval echo \$$freq_results_array$index)
sum=$(echo $sum $res | awk '{ printf "%f", $1 + $2 }')
index=$((index + 1))
-
}
__check_freq_deviation() {
res=$(eval echo \$$freq_results_array$index)
-
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}')
-
index=$((index + 1))
res=$(echo $dev | awk '{printf "%f", ($dev > 5.0)}')
@@ -85,23 +77,20 @@ check_freq_deviation() {
cpu=$1
freq=$2
-
check "deviation for frequency $(frequnit $freq)" __check_freq_deviation
-
}
check_deviation() {
cpu=$1
-
set_governor $cpu userspace
-
+ index=0
for_each_frequency $cpu compute_freq_ratio
-
+ index=0;sum=0
for_each_frequency $cpu compute_freq_ratio_sum
avg=$(echo $sum $index | awk '{ printf "%.3f", $1 / $2}')
-
+ index=0
for_each_frequency $cpu check_freq_deviation
}