diff mbox

[pm-qa,01/10] factor out check_file function

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

Commit Message

Daniel Lezcano Oct. 3, 2011, 8:18 a.m. UTC
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org
---
 include/functions.sh |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/include/functions.sh b/include/functions.sh
index 6702cb2..bff8e13 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -194,13 +194,20 @@  check() {
     return 0
 }
 
+check_file() {
+    local file=$1
+    local dir=$2
+
+    check "'$file' exists" "test -f" $dir/$file
+}
+
 check_cpufreq_files() {
 
     local dirpath=$CPU_PATH/$1/cpufreq
     shift 1
 
     for i in $@; do
-	check "$i exists" "test -f" $dirpath/$i  || return 1
+	check_file $i $dirpath || return 1
     done
 
     return 0
@@ -211,7 +218,7 @@  check_sched_mc_files() {
     local dirpath=$CPU_PATH
 
     for i in $@; do
-	check "$i exists" "test -f" $dirpath/$i  || return 1
+	check_file $i $dirpath || return 1
     done
 
     return 0
@@ -223,7 +230,7 @@  check_topology_files() {
     shift 1
 
     for i in $@; do
-	check "$i exists" "test -f" $dirpath/$i  || return 1
+	check_file $i $dirpath || return 1
     done
 
     return 0