selftests/zram: must be run as root
authorNaresh Kamboju <naresh.kamboju@linaro.org>
Mon, 31 Aug 2015 11:41:55 +0000 (17:11 +0530)
committerShuah Khan <shuahkh@osg.samsung.com>
Tue, 1 Sep 2015 16:51:32 +0000 (10:51 -0600)
Adding new functionality check_prereqs() to check test must be run as root

Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/zram/zram.sh
tools/testing/selftests/zram/zram01.sh
tools/testing/selftests/zram/zram02.sh
tools/testing/selftests/zram/zram_lib.sh

index 6ea4b6a5ccab61705008c5eb51cbc92d99dd99f5..20de9a7612692cc007035055a5b559993b5b8e1d 100755 (executable)
@@ -1,6 +1,16 @@
 #!/bin/bash
 TCID="zram.sh"
 
+check_prereqs()
+{
+       local msg="skip all tests:"
+
+       if [ $UID != 0 ]; then
+               echo $msg must be run as root >&2
+               exit 0
+       fi
+}
+
 run_zram () {
 echo "--------------------"
 echo "running zram tests"
@@ -10,6 +20,8 @@ echo ""
 ./zram02.sh
 }
 
+check_prereqs
+
 # check zram module exists
 MODULE_PATH=/lib/modules/`uname -r`/kernel/drivers/block/zram/zram.ko
 if [ -f $MODULE_PATH ]; then
index 2a2475d4b201ac6a5b77015a5053eefc033f4463..b9566a6478a9ceca788386b7ae7d19b584e208ca 100755 (executable)
@@ -79,6 +79,7 @@ zram_fill_fs()
        echo "zram compression ratio: $(echo "scale=2; $v / 100 " | bc):1: OK"
 }
 
+check_prereqs
 zram_load
 zram_max_streams
 zram_compress_alg
index 96e82dcc195b42e5408fbe954e95af40f1a76ef9..74569b883737ff6402409a9d26693b048d334554 100755 (executable)
@@ -37,6 +37,7 @@ zram_max_streams="2"
 zram_sizes="1048576" # 1M
 zram_mem_limits="1M"
 
+check_prereqs
 zram_load
 zram_max_streams
 zram_set_disksizes
index 3b6abf1942d728deffc038aae071e7cb402c3545..424e68ed1487d86cd7d6c62e28348251781f6500 100755 (executable)
@@ -20,6 +20,16 @@ dev_mounted=-1
 
 trap INT
 
+check_prereqs()
+{
+       local msg="skip all tests:"
+
+       if [ $UID != 0 ]; then
+               echo $msg must be run as root >&2
+               exit 0
+       fi
+}
+
 zram_cleanup()
 {
        echo "zram cleanup"