diff options
author | Naresh Kamboju <naresh.kamboju@linaro.org> | 2015-06-20 00:25:52 +0530 |
---|---|---|
committer | Naresh Kamboju <naresh.kamboju@linaro.org> | 2015-06-20 00:25:52 +0530 |
commit | 088a3141f2991b949e411a913cf463a08cdb3cdc (patch) | |
tree | 5035aec121649b7af27f10921e3c43894e4d682b | |
parent | 6244615daf701df5e7a0e065adb84b1a5491c15f (diff) |
zram: fixup
Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
-rwxr-xr-x | zram01.sh | 18 | ||||
-rwxr-xr-x | zram02.sh | 15 | ||||
-rwxr-xr-x | zram_lib.sh | 74 |
3 files changed, 83 insertions, 24 deletions
@@ -8,12 +8,12 @@ # # This program is distributed in the hope that it would be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Test creates several zram devices with different filesystems on them. # It fills each device with zeros and checks that compression works. @@ -21,6 +21,9 @@ # Author: Alexey Kodanev <alexey.kodanev@oracle.com> # Modified: Naresh Kamboju <naresh.kamboju@linaro.org> +TCID="zram01" +ERR_CODE=0 + . ./zram_lib.sh # Test will create the following number of zram devices: @@ -73,13 +76,15 @@ zram_fill_fs() if [ "$v" -lt 100 ]; then echo "FAIL compression ratio: 0.$v:1" + ERR_CODE=-1 zram_cleanup return fi - echo "ZRAM compression ratio: $(echo "scale=2; $v / 100 " | bc):1 : PASS" + echo "zram compression ratio: $(echo "scale=2; $v / 100 " | bc):1 : OK" } +zram_load zram_max_streams zram_compress_alg zram_set_disksizes @@ -89,3 +94,10 @@ zram_mount zram_fill_fs zram_cleanup +zram_unload + +if [ $ERR_CODE -ne 0 ]; then + echo "$TCID : FAIL" +else + echo "$TCID : PASS" +fi @@ -8,18 +8,21 @@ # # This program is distributed in the hope that it would be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Test checks that we can create swap zram device. # # Author: Alexey Kodanev <alexey.kodanev@oracle.com> # Modified: Naresh Kamboju <naresh.kamboju@linaro.org> +TCID="zram02" +ERR_CODE=0 + . ./zram_lib.sh # Test will create the following number of zram devices: @@ -38,9 +41,17 @@ zram_max_streams="2" zram_sizes="1048576" # 1M zram_mem_limits="1M" +zram_load zram_max_streams zram_set_disksizes zram_set_memlimit zram_makeswap zram_swapoff zram_cleanup +zram_unload + +if [ $ERR_CODE -ne 0 ]; then + echo "$TCID : FAIL" +else + echo "$TCID : PASS" +fi diff --git a/zram_lib.sh b/zram_lib.sh index 4f4ea89..a96297c 100755 --- a/zram_lib.sh +++ b/zram_lib.sh @@ -8,16 +8,17 @@ # # This program is distributed in the hope that it would be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Author: Alexey Kodanev <alexey.kodanev@oracle.com> # Modified: Naresh Kamboju <naresh.kamboju@linaro.org> +MODULE=0 dev_makeswap=-1 dev_mounted=-1 @@ -42,6 +43,41 @@ zram_cleanup() } +zram_unload() +{ + if [ $MODULE -ne 0 ] ; then + echo "zram rmmod zram" + rmmod zram > /dev/null 2>&1 + fi +} + +zram_load() +{ + # check zram module exists + MODULE_PATH=/lib/modules/`uname -r`/kernel/drivers/zram/zram.ko + if [ -f $MODULE_PATH ]; then + MODULE=1 + echo "create '$dev_num' zram device(s)" + modprobe zram num_devices=$dev_num || \ + echo "failed to insert zram module" + + dev_num_created=$(ls /dev/zram* | wc -w) + + if [ "$dev_num_created" -ne "$dev_num" ]; then + echo "unexpected num of devices: $dev_num_created" + ERR_CODE=-1 + else + echo "zram load module successful" + fi + elif [ -b /dev/zram0 ]; then + echo "/dev/zram0 device file found" + else + echo "ERROR: No zram.ko module or no /dev/zram0 device found" + echo "$TCID : CONFIG_ZRAM is not set" + exit 1 + fi +} + zram_max_streams() { echo "set max_comp_streams to zram device(s)" @@ -58,10 +94,10 @@ zram_max_streams() echo "FAIL can't set max_streams '$max_s', get $max_stream" i=$(($i + 1)) - echo "$sys_path = '$max_streams' ($i/$dev_num)" + echo "$sys_path = '$max_streams' ($i/$dev_num)" done - echo "ZRAM max streams : PASS" + echo "zram max streams : OK" } zram_compress_alg() @@ -69,17 +105,17 @@ zram_compress_alg() echo "test that we can set compression algorithm" local algs=$(cat /sys/block/zram0/comp_algorithm) - echo "supported algs: $algs" + echo "supported algs: $algs" local i=0 for alg in $zram_algs; do local sys_path="/sys/block/zram${i}/comp_algorithm" - echo "$alg" > $sys_path || \ + echo "$alg" > $sys_path || \ echo "FAIL can't set '$alg' to $sys_path" i=$(($i + 1)) - echo "$sys_path = '$alg' ($i/$dev_num)" + echo "$sys_path = '$alg' ($i/$dev_num)" done - echo "ZRAM set compression algorithm : PASS" + echo "zram set compression algorithm : OK" } zram_set_disksizes() @@ -88,14 +124,14 @@ zram_set_disksizes() local i=0 for ds in $zram_sizes; do local sys_path="/sys/block/zram${i}/disksize" - echo "$ds" > $sys_path || \ + echo "$ds" > $sys_path || \ echo "FAIL can't set '$ds' to $sys_path" i=$(($i + 1)) - echo "$sys_path = '$ds' ($i/$dev_num)" + echo "$sys_path = '$ds' ($i/$dev_num)" done - echo "ZRAM set disksizes : PASS" + echo "zram set disksizes : OK" } zram_set_memlimit() @@ -105,14 +141,14 @@ zram_set_memlimit() local i=0 for ds in $zram_mem_limits; do local sys_path="/sys/block/zram${i}/mem_limit" - echo "$ds" > $sys_path || \ + echo "$ds" > $sys_path || \ echo "FAIL can't set '$ds' to $sys_path" i=$(($i + 1)) - echo "$sys_path = '$ds' ($i/$dev_num)" + echo "$sys_path = '$ds' ($i/$dev_num)" done - echo "ZRAM set memory limit : PASS" + echo "zram set memory limit : OK" } zram_makeswap() @@ -133,11 +169,11 @@ zram_makeswap() echo "FAIL swapon /dev/zram$1 failed" fi - echo "done with /dev/zram$i" + echo "done with /dev/zram$i" dev_makeswap=$i done - echo "ZRAM making zram mkswap and swapon : PASS" + echo "zram making zram mkswap and swapon : OK" } zram_swapoff() @@ -153,7 +189,7 @@ zram_swapoff() done dev_makeswap=-1 - echo "ZRAM swapoff : PASS" + echo "zram swapoff : OK" } zram_makefs() @@ -171,7 +207,7 @@ zram_makefs() echo "FAIL failed to make $fs on /dev/zram$i" fi i=$(($i + 1)) - echo "ZRAM mkfs.$fs : PASS" + echo "zram mkfs.$fs : OK" done } @@ -186,5 +222,5 @@ zram_mount() dev_mounted=$i done - echo "ZRAM mount of zram device(s) : PASS" + echo "zram mount of zram device(s) : OK" } |