[pm-qa,1/2] fix error in script

Message ID 1316206256-11052-1-git-send-email-daniel.lezcano@linaro.org
State Accepted
Headers show

Commit Message

Daniel Lezcano Sept. 16, 2011, 8:50 p.m.
Prevent a syntax error when running the test which leads to an
exception in the script and exiting wildely the loop.

The cpuburn stays running in background.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 include/functions.sh |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

Patch

diff --git a/include/functions.sh b/include/functions.sh
index 2cc44b3..f003414 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -109,8 +109,18 @@  get_governor() {
 wait_latency() {
     local cpu=$1
     local dirpath=$CPU_PATH/$cpu/cpufreq
-    local latency=$(cat $dirpath/cpuinfo_transition_latency)
-    local nrfreq=$(cat $dirpath/scaling_available_frequencies | wc -w)
+    local latency=
+    local nrfreq=
+
+    latency=$(cat $dirpath/cpuinfo_transition_latency)
+    if [ $? != 0 ]; then
+	return $?
+    fi
+
+    nrfreq=$(cat $dirpath/scaling_available_frequencies | wc -w)
+    if [ $? != 0 ]; then
+	return $?
+    fi
 
     nrfreq=$((nrfreq + 1))
     ../utils/nanosleep $(($nrfreq * $latency))