cpufreq: test feature is enabled before running

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

Commit Message

Sanjay Singh Rawat Jan. 21, 2014, 9:47 a.m.
Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---
 cpufreq/cpufreq_01.sh |    6 ++++++
 cpufreq/cpufreq_02.sh |    6 ++++++
 cpufreq/cpufreq_03.sh |    6 ++++++
 cpufreq/cpufreq_04.sh |    6 ++++++
 cpufreq/cpufreq_05.sh |    6 ++++++
 cpufreq/cpufreq_06.sh |    6 ++++++
 cpufreq/cpufreq_07.sh |    6 ++++++
 cpufreq/cpufreq_08.sh |    6 ++++++
 cpufreq/cpufreq_09.sh |    6 ++++++
 include/functions.sh  |    4 ++++
 10 files changed, 58 insertions(+)

Patch

diff --git a/cpufreq/cpufreq_01.sh b/cpufreq/cpufreq_01.sh
index 6f092fe..00dff64 100755
--- a/cpufreq/cpufreq_01.sh
+++ b/cpufreq/cpufreq_01.sh
@@ -27,6 +27,12 @@ 
 
 source ../include/functions.sh
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 FILES="scaling_available_frequencies scaling_cur_freq scaling_setspeed"
 
 for_each_cpu check_cpufreq_files $FILES
diff --git a/cpufreq/cpufreq_02.sh b/cpufreq/cpufreq_02.sh
index 34e19b7..82d7244 100755
--- a/cpufreq/cpufreq_02.sh
+++ b/cpufreq/cpufreq_02.sh
@@ -29,5 +29,11 @@  source ../include/functions.sh
 
 FILES="scaling_available_governors scaling_governor"
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 for_each_cpu check_cpufreq_files $FILES
 test_status_show
diff --git a/cpufreq/cpufreq_03.sh b/cpufreq/cpufreq_03.sh
index 0c59ce8..85118d7 100755
--- a/cpufreq/cpufreq_03.sh
+++ b/cpufreq/cpufreq_03.sh
@@ -27,6 +27,12 @@ 
 
 source ../include/functions.sh
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 check_governor() {
 
     local cpu=$1
diff --git a/cpufreq/cpufreq_04.sh b/cpufreq/cpufreq_04.sh
index 530366a..4a07315 100755
--- a/cpufreq/cpufreq_04.sh
+++ b/cpufreq/cpufreq_04.sh
@@ -27,6 +27,12 @@ 
 
 source ../include/functions.sh
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 check_frequency() {
 
     local cpu=$1
diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh
index 7830118..3c76bc1 100755
--- a/cpufreq/cpufreq_05.sh
+++ b/cpufreq/cpufreq_05.sh
@@ -27,6 +27,12 @@ 
 
 source ../include/functions.sh
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 if [ $(id -u) -ne 0 ]; then
     log_skip "run as non-root"
     exit 0
diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh
index 25c473e..157b1ef 100755
--- a/cpufreq/cpufreq_06.sh
+++ b/cpufreq/cpufreq_06.sh
@@ -29,6 +29,12 @@  source ../include/functions.sh
 
 CPUCYCLE=../utils/cpucycle
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 compute_freq_ratio() {
 
     local cpu=$1
diff --git a/cpufreq/cpufreq_07.sh b/cpufreq/cpufreq_07.sh
index abfad7f..10fe909 100755
--- a/cpufreq/cpufreq_07.sh
+++ b/cpufreq/cpufreq_07.sh
@@ -29,6 +29,12 @@  source ../include/functions.sh
 
 CPUBURN=../utils/cpuburn
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 check_ondemand() {
 
     local cpu=$1
diff --git a/cpufreq/cpufreq_08.sh b/cpufreq/cpufreq_08.sh
index 79008f0..8ab33b7 100755
--- a/cpufreq/cpufreq_08.sh
+++ b/cpufreq/cpufreq_08.sh
@@ -29,6 +29,12 @@  source ../include/functions.sh
 
 CPUBURN=../utils/cpuburn
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 check_frequency() {
     local cpu=$1
     local freq=$2
diff --git a/cpufreq/cpufreq_09.sh b/cpufreq/cpufreq_09.sh
index a0c1171..832c303 100755
--- a/cpufreq/cpufreq_09.sh
+++ b/cpufreq/cpufreq_09.sh
@@ -29,6 +29,12 @@  source ../include/functions.sh
 
 CPUBURN=../utils/cpuburn
 
+cpufreq_enabled
+if [ $? -ne 0 ]; then
+	log_skip "cpufreq not supported"
+	exit 0
+fi
+
 check_powersave() {
 
     local cpu=$1
diff --git a/include/functions.sh b/include/functions.sh
index 7009fa3..2124ceb 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -344,3 +344,7 @@  restore_frequencies() {
 sigtrap() {
     exit 255
 }
+
+cpufreq_enabled() {
+    test -d /sys/devices/system/cpu/cpufreq
+}