diff mbox

[pmqa] cpuhotplug: before running check feature is on

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

Commit Message

Sanjay Singh Rawat Jan. 27, 2014, 6:36 a.m. UTC
Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---
 cpuhotplug/cpuhotplug_01.sh |   12 ++++++++++++
 cpuhotplug/cpuhotplug_02.sh |   12 ++++++++++++
 cpuhotplug/cpuhotplug_03.sh |   12 ++++++++++++
 cpuhotplug/cpuhotplug_04.sh |   12 ++++++++++++
 cpuhotplug/cpuhotplug_05.sh |   12 ++++++++++++
 cpuhotplug/cpuhotplug_06.sh |   12 ++++++++++++
 cpuhotplug/cpuhotplug_07.sh |   12 ++++++++++++
 cpuhotplug/cpuhotplug_08.sh |   12 ++++++++++++
 include/functions.sh        |   15 +++++++++++++++
 9 files changed, 111 insertions(+)
diff mbox

Patch

diff --git a/cpuhotplug/cpuhotplug_01.sh b/cpuhotplug/cpuhotplug_01.sh
index 8804df7..81a5e8a 100755
--- a/cpuhotplug/cpuhotplug_01.sh
+++ b/cpuhotplug/cpuhotplug_01.sh
@@ -29,6 +29,18 @@  source ../include/functions.sh
 
 FILES="online offline possible present"
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 for i in $FILES; do
     check_file $i $CPU_PATH || return 1
 done
diff --git a/cpuhotplug/cpuhotplug_02.sh b/cpuhotplug/cpuhotplug_02.sh
index 3157307..c4efcf7 100755
--- a/cpuhotplug/cpuhotplug_02.sh
+++ b/cpuhotplug/cpuhotplug_02.sh
@@ -27,6 +27,18 @@ 
 
 source ../include/functions.sh
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 check_state() {
     local cpu=$1
     local dirpath=$CPU_PATH/$1
diff --git a/cpuhotplug/cpuhotplug_03.sh b/cpuhotplug/cpuhotplug_03.sh
index 13a0ce9..83a0fac 100755
--- a/cpuhotplug/cpuhotplug_03.sh
+++ b/cpuhotplug/cpuhotplug_03.sh
@@ -27,6 +27,18 @@ 
 
 source ../include/functions.sh
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 check_affinity_fails() {
     local cpu=$1
     local cpuid=${cpu:3}
diff --git a/cpuhotplug/cpuhotplug_04.sh b/cpuhotplug/cpuhotplug_04.sh
index 8c5ab52..3114911 100755
--- a/cpuhotplug/cpuhotplug_04.sh
+++ b/cpuhotplug/cpuhotplug_04.sh
@@ -28,6 +28,18 @@ 
 CPUBURN=../utils/cpuburn
 source ../include/functions.sh
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 check_task_migrate() {
     local cpu=$1
     local cpuid=${cpu:3}
diff --git a/cpuhotplug/cpuhotplug_05.sh b/cpuhotplug/cpuhotplug_05.sh
index a8eb312..8db2060 100755
--- a/cpuhotplug/cpuhotplug_05.sh
+++ b/cpuhotplug/cpuhotplug_05.sh
@@ -27,6 +27,18 @@ 
 
 source ../include/functions.sh
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 check_procinfo() {
     local cpu=$1
     local cpuid=${cpu:3}
diff --git a/cpuhotplug/cpuhotplug_06.sh b/cpuhotplug/cpuhotplug_06.sh
index 347906d..5e6954c 100755
--- a/cpuhotplug/cpuhotplug_06.sh
+++ b/cpuhotplug/cpuhotplug_06.sh
@@ -27,6 +27,18 @@ 
 
 source ../include/functions.sh
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 check_procinfo() {
     local cpu=$1
     local cpuid=${cpu:3}
diff --git a/cpuhotplug/cpuhotplug_07.sh b/cpuhotplug/cpuhotplug_07.sh
index d3674d2..97299bb 100755
--- a/cpuhotplug/cpuhotplug_07.sh
+++ b/cpuhotplug/cpuhotplug_07.sh
@@ -28,6 +28,18 @@ 
 source ../include/functions.sh
 TMPFILE=cpuhotplug_07.tmp
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 waitfor_udevadm() {
     while [ 1 ]; do
         lsof | grep udevadm | grep 'sock\|netlink' > /dev/null
diff --git a/cpuhotplug/cpuhotplug_08.sh b/cpuhotplug/cpuhotplug_08.sh
index 9e2c355..7295e5b 100755
--- a/cpuhotplug/cpuhotplug_08.sh
+++ b/cpuhotplug/cpuhotplug_08.sh
@@ -27,6 +27,18 @@ 
 
 source ../include/functions.sh
 
+is_root
+if [ $? -ne 0 ]; then
+    log_skip "user is not root"
+    exit 0
+fi
+
+cpuhotplug_enabled
+if [ $? -ne 0 ]; then
+    log_skip "cpuhotplug not supported"
+    exit 0
+fi
+
 function randomize() {
     echo $[ ( $RANDOM % $1 )  + 1 ]
 }
diff --git a/include/functions.sh b/include/functions.sh
index 2a9cf21..8ee1acf 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -353,6 +353,21 @@  cpuidle_enabled() {
     test -d /sys/devices/system/cpu/cpuidle
 }
 
+cpuhotplug_enabled() {
+    cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
+
+    for cpu in $cpus; do
+        # assuming cpu0 can't be plugged out
+        if [ $cpu != "cpu0" ]; then
+            test -w $CPU_PATH/$cpu/online
+            if [ $? -ne 0 ]; then
+                return 1
+            fi
+        fi
+    done
+    return 0
+}
+
 # currently we support ubuntu and android
 get_os() {
     lsb_release -a 2>&1 | grep -i ubuntu > /dev/null