aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhanghongbo <hongbo.zhang@linaro.org>2012-09-11 00:35:21 +0800
committerhongbo.zhang <hongbo.zhang@linaro.com>2012-11-28 17:19:33 +0800
commitb6fdbda76431a9368dcbd61ec87790357d5a8529 (patch)
tree7db166b331e1a5c05ab26755dba68e175980c704
parent247116dc3afb303a9c1c8690e4f9dac00cb07ea3 (diff)
suspend: enable the pm_trace.
Signed-off-by: hongbo.zhang <hongbo.zhang@linaro.com>
-rw-r--r--include/suspend_functions.sh35
-rwxr-xr-xsuspend/suspend_01.sh8
-rwxr-xr-xsuspend/suspend_02.sh7
-rwxr-xr-xsuspend/suspend_03.sh8
-rwxr-xr-xsuspend/suspend_04.sh6
-rwxr-xr-xsuspend/suspend_05.sh6
6 files changed, 55 insertions, 15 deletions
diff --git a/include/suspend_functions.sh b/include/suspend_functions.sh
index 6c085db..f06689f 100644
--- a/include/suspend_functions.sh
+++ b/include/suspend_functions.sh
@@ -40,6 +40,7 @@ LOGFILE="$LOGDIR/stress.log"
# Options Config
dry=0
auto=1
+pm_trace=1
timer_sleep=20
# root is needed to fiddle with the clock and use the rtc wakeups.
@@ -103,7 +104,7 @@ suspend_system ()
pm-suspend >> "$LOGFILE"
;;
mem)
- echo "mem" > /sys/power/state
+ `echo "mem" > /sys/power/state` >> "$LOGFILE"
;;
esac
@@ -143,12 +144,32 @@ ECHO ()
enable_trace()
{
- echo 1 > '/sys/power/pm_trace'
+ if [ -w /sys/power/pm_trace ]; then
+ echo 1 > '/sys/power/pm_trace'
+ fi
}
disable_trace()
{
- echo 0 > '/sys/power/pm_trace'
+ if [ -w /sys/power/pm_trace ]; then
+ echo 0 > '/sys/power/pm_trace'
+ fi
+}
+
+trace_state=-1
+
+save_trace()
+{
+ if [ -r /sys/power/pm_trace ]; then
+ trace_state=`cat /sys/power/pm_trace`
+ fi
+}
+
+restore_trace()
+{
+ if [ "$trace_state" -ne -1 -a -w /sys/power/pm_trace ]; then
+ echo "$trace_state" > '/sys/power/pm_trace'
+ fi
}
battery_count()
@@ -263,3 +284,11 @@ phase()
fi
}
+save_trace
+
+if [ "$pm_trace" -eq 1 ]; then
+ enable_trace
+else
+ disable_trace
+fi
+
diff --git a/suspend/suspend_01.sh b/suspend/suspend_01.sh
index 0149c70..d67a66b 100755
--- a/suspend/suspend_01.sh
+++ b/suspend/suspend_01.sh
@@ -30,7 +30,7 @@ source ../include/functions.sh
source ../include/suspend_functions.sh
# test_dbus: switch on/off this test
-test_dbus=0
+test_dbus=1
if [ "$test_dbus" -eq 0 ]; then
log_skip "dbus message suspend test not enabled"
@@ -40,10 +40,12 @@ fi
if [ -x /usr/bin/dbus-send ]; then
phase
check "suspend by dbus message" suspend_system "dbus"
- if [ $? -eq 0 ]; then
- rm -f "$LOGFILE"
+ if [ $? -ne 0 ]; then
+ cat "$LOGFILE" 1>&2
fi
else
log_skip "dbus-send command not exist"
fi
+restore_trace
+rm -f "$LOGFILE"
diff --git a/suspend/suspend_02.sh b/suspend/suspend_02.sh
index cb15801..7e33624 100755
--- a/suspend/suspend_02.sh
+++ b/suspend/suspend_02.sh
@@ -40,10 +40,13 @@ fi
if [ -x /usr/sbin/pm-suspend ]; then
phase
check "suspend via pm-suspend" suspend_system "pmsuspend"
- if [ $? -eq 0 ]; then
- rm -f "$LOGFILE"
+ if [ $? -ne 0 ]; then
+ cat "$LOGFILE" 1>&2
fi
else
log_skip "pm-suspend command not exist"
fi
+restore_trace
+rm -f "$LOGFILE"
+
diff --git a/suspend/suspend_03.sh b/suspend/suspend_03.sh
index a782061..64f2fa1 100755
--- a/suspend/suspend_03.sh
+++ b/suspend/suspend_03.sh
@@ -30,7 +30,7 @@ source ../include/functions.sh
source ../include/suspend_functions.sh
# test_mem: switch on/off this test
-test_mem=0
+test_mem=1
if [ "$test_mem" -eq 0 ]; then
log_skip "suspend to ram via sysfs not enabled"
@@ -41,10 +41,12 @@ supported=$(cat /sys/power/state | grep "mem")
if [ -n "$supported" ]; then
phase
check "suspend to ram via sysfs" suspend_system "mem"
- if [ $? -eq 0 ]; then
- rm -f "$LOGFILE"
+ if [ $? -ne 0 ]; then
+ cat "$LOGFILE" 1>&2
fi
else
log_skip "suspend to ram via sysfs not supported"
fi
+restore_trace
+rm -f "$LOGFILE"
diff --git a/suspend/suspend_04.sh b/suspend/suspend_04.sh
index ed8a580..9f85400 100755
--- a/suspend/suspend_04.sh
+++ b/suspend/suspend_04.sh
@@ -67,8 +67,10 @@ else
phase
sleep 2
check "return of AC while suspended" suspend_system "mem"
- if [ $? -eq 0 ]; then
- rm -f "$LOGFILE"
+ if [ $? -ne 0 ]; then
+ cat "$LOGFILE" 1>&2
fi
fi
+restore_trace
+rm -f "$LOGFILE"
diff --git a/suspend/suspend_05.sh b/suspend/suspend_05.sh
index 767eec1..8604331 100755
--- a/suspend/suspend_05.sh
+++ b/suspend/suspend_05.sh
@@ -59,8 +59,8 @@ else
# Suspend
check "battery drain during suspend" suspend_system "mem"
- if [ $? -eq 0 ]; then
- rm -f "$LOGFILE"
+ if [ $? -ne 0 ]; then
+ cat "$LOGFILE" 1>&2
fi
# get end values
@@ -91,3 +91,5 @@ else
timer_sleep="$save_timer_sleep"
fi
+restore_trace
+rm -f "$LOGFILE"