diff mbox

[PMQA] suspend: use generic function to check root user

Message ID 1406710948-13046-1-git-send-email-sanjay.rawat@linaro.org
State New
Headers show

Commit Message

Sanjay Singh Rawat July 30, 2014, 9:02 a.m. UTC
- command (id) to check root user returns different output format
for ubuntu and android. Using generic function to avoid build
errors.
- bug 166

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---
 include/suspend_functions.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/include/suspend_functions.sh b/include/suspend_functions.sh
index 1e8a793..3be29f5 100644
--- a/include/suspend_functions.sh
+++ b/include/suspend_functions.sh
@@ -33,6 +33,7 @@ 
 #  - hongbo.zhang@linaro.org, March, 2012
 #
 
+source ./functions.sh
 
 LOGDIR='/var/lib/pm-utils'
 LOGFILE="$LOGDIR/stress.log"
@@ -44,9 +45,10 @@  pm_trace=1
 timer_sleep=20
 
 # root is needed to fiddle with the clock and use the rtc wakeups.
-if [ $(id -u) -ne 0 ]; then
-	log_skip "run as non-root"
-	exit 0
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
 fi
 
 # Ensure the log directory exists.