From f21fb798fe38cf87b177d45820991f0e315c0ba8 Mon Sep 17 00:00:00 2001 From: Naresh Kamboju Date: Tue, 18 Aug 2015 12:31:59 +0530 Subject: selftests/zram: Adding zram tests zram: Compressed RAM based block devices ---------------------------------------- The zram module creates RAM based block devices named /dev/zram ( = 0, 1, ...). Pages written to these disks are compressed and stored in memory itself. These disks allow very fast I/O and compression provides good amounts of memory savings. Some of the usecases include /tmp storage, use as swap disks, various caches under /var and maybe many more :) Statistics for individual zram devices are exported through sysfs nodes at /sys/block/zram/ This patch is to validate the zram functionality. Test interacts with block device /dev/zram and sysfs nodes /sys/block/zram/ zram.sh: sanity check of CONFIG_ZRAM and to run zram01 and zram02 tests zram01.sh: creates general purpose ram disks with different filesystems zram02.sh: creates block device for swap zram_lib.sh: create library with initialization/cleanup functions README: ZRAM introduction and Kconfig required. Makefile: To run zram tests zram test output ----------------- ./zram.sh -------------------- running zram tests -------------------- /dev/zram0 device file found: OK set max_comp_streams to zram device(s) /sys/block/zram0/max_comp_streams = '2' (1/1) zram max streams: OK test that we can set compression algorithm supported algs: [lzo] lz4 /sys/block/zram0/comp_algorithm = 'lzo' (1/1) zram set compression algorithm: OK set disk size to zram device(s) /sys/block/zram0/disksize = '2097152' (1/1) zram set disksizes: OK set memory limit to zram device(s) /sys/block/zram0/mem_limit = '2M' (1/1) zram set memory limit: OK make ext4 filesystem on /dev/zram0 zram mkfs.ext4: OK mount /dev/zram0 zram mount of zram device(s): OK fill zram0... zram0 can be filled with '1932' KB zram used 3M, zram disk sizes 2097152M zram compression ratio: 699050.66:1: OK zram cleanup zram01 : [PASS] /dev/zram0 device file found: OK set max_comp_streams to zram device(s) /sys/block/zram0/max_comp_streams = '2' (1/1) zram max streams: OK set disk size to zram device(s) /sys/block/zram0/disksize = '1048576' (1/1) zram set disksizes: OK set memory limit to zram device(s) /sys/block/zram0/mem_limit = '1M' (1/1) zram set memory limit: OK make swap with zram device(s) done with /dev/zram0 zram making zram mkswap and swapon: OK zram swapoff: OK zram cleanup zram02 : [PASS] CC: Shuah Khan CC: Tyler Baker CC: Milosz Wasilewski CC: Alexey Kodanev Signed-off-by: Naresh Kamboju Signed-off-by: Alexey Kodanev Reviewed-By: Tyler Baker Signed-off-by: Shuah Khan --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/zram/Makefile | 12 ++ tools/testing/selftests/zram/README | 40 ++++++ tools/testing/selftests/zram/zram.sh | 23 ++++ tools/testing/selftests/zram/zram01.sh | 98 ++++++++++++++ tools/testing/selftests/zram/zram02.sh | 53 ++++++++ tools/testing/selftests/zram/zram_lib.sh | 222 +++++++++++++++++++++++++++++++ 7 files changed, 449 insertions(+) create mode 100644 tools/testing/selftests/zram/Makefile create mode 100644 tools/testing/selftests/zram/README create mode 100755 tools/testing/selftests/zram/zram.sh create mode 100755 tools/testing/selftests/zram/zram01.sh create mode 100755 tools/testing/selftests/zram/zram02.sh create mode 100755 tools/testing/selftests/zram/zram_lib.sh (limited to 'tools') diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 24ae9e829e9a..9763dd95b4c8 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -22,6 +22,7 @@ endif TARGETS += user TARGETS += vm TARGETS += x86 +TARGETS += zram #Please keep the TARGETS list alphabetically sorted # Run "make quicktest=1 run_tests" or # "make quicktest=1 kselftest from top level Makefile diff --git a/tools/testing/selftests/zram/Makefile b/tools/testing/selftests/zram/Makefile new file mode 100644 index 000000000000..ec45513c7303 --- /dev/null +++ b/tools/testing/selftests/zram/Makefile @@ -0,0 +1,12 @@ +all: + +TEST_PROGS := zram.sh +TEST_FILES := zram01.sh zram02.sh zram_lib.sh + +include ../lib.mk + +run_tests: + @/bin/bash ./zram.sh + +clean: + $(RM) err.log diff --git a/tools/testing/selftests/zram/README b/tools/testing/selftests/zram/README new file mode 100644 index 000000000000..eb17917c8a3a --- /dev/null +++ b/tools/testing/selftests/zram/README @@ -0,0 +1,40 @@ +zram: Compressed RAM based block devices +---------------------------------------- +* Introduction + +The zram module creates RAM based block devices named /dev/zram +( = 0, 1, ...). Pages written to these disks are compressed and stored +in memory itself. These disks allow very fast I/O and compression provides +good amounts of memory savings. Some of the usecases include /tmp storage, +use as swap disks, various caches under /var and maybe many more :) + +Statistics for individual zram devices are exported through sysfs nodes at +/sys/block/zram/ + +Kconfig required: +CONFIG_ZRAM=y +CONFIG_ZRAM_LZ4_COMPRESS=y +CONFIG_ZPOOL=y +CONFIG_ZSMALLOC=y + +ZRAM Testcases +-------------- +zram_lib.sh: create library with initialization/cleanup functions +zram.sh: For sanity check of CONFIG_ZRAM and to run zram01 and zram02 + +Two functional tests: zram01 and zram02: +zram01.sh: creates general purpose ram disks with ext4 filesystems +zram02.sh: creates block device for swap + +Commands required for testing: + - bc + - dd + - free + - awk + - mkswap + - swapon + - swapoff + - mkfs/ mkfs.ext4 + +For more information please refer: +kernel-source-tree/Documentation/blockdev/zram.txt diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh new file mode 100755 index 000000000000..6ea4b6a5ccab --- /dev/null +++ b/tools/testing/selftests/zram/zram.sh @@ -0,0 +1,23 @@ +#!/bin/bash +TCID="zram.sh" + +run_zram () { +echo "--------------------" +echo "running zram tests" +echo "--------------------" +./zram01.sh +echo "" +./zram02.sh +} + +# check zram module exists +MODULE_PATH=/lib/modules/`uname -r`/kernel/drivers/block/zram/zram.ko +if [ -f $MODULE_PATH ]; then + run_zram +elif [ -b /dev/zram0 ]; then + run_zram +else + echo "$TCID : No zram.ko module or /dev/zram0 device file not found" + echo "$TCID : CONFIG_ZRAM is not set" + exit 1 +fi diff --git a/tools/testing/selftests/zram/zram01.sh b/tools/testing/selftests/zram/zram01.sh new file mode 100755 index 000000000000..2a2475d4b201 --- /dev/null +++ b/tools/testing/selftests/zram/zram01.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# 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 +# GNU General Public License for more details. +# +# Test creates several zram devices with different filesystems on them. +# It fills each device with zeros and checks that compression works. +# +# Author: Alexey Kodanev +# Modified: Naresh Kamboju + +TCID="zram01" +ERR_CODE=0 + +. ./zram_lib.sh + +# Test will create the following number of zram devices: +dev_num=1 +# This is a list of parameters for zram devices. +# Number of items must be equal to 'dev_num' parameter. +zram_max_streams="2" + +# The zram sysfs node 'disksize' value can be either in bytes, +# or you can use mem suffixes. But in some old kernels, mem +# suffixes are not supported, for example, in RHEL6.6GA's kernel +# layer, it uses strict_strtoull() to parse disksize which does +# not support mem suffixes, in some newer kernels, they use +# memparse() which supports mem suffixes. So here we just use +# bytes to make sure everything works correctly. +zram_sizes="2097152" # 2MB +zram_mem_limits="2M" +zram_filesystems="ext4" +zram_algs="lzo" + +zram_fill_fs() +{ + local mem_free0=$(free -m | awk 'NR==2 {print $4}') + + for i in $(seq 0 $(($dev_num - 1))); do + echo "fill zram$i..." + local b=0 + while [ true ]; do + dd conv=notrunc if=/dev/zero of=zram${i}/file \ + oflag=append count=1 bs=1024 status=none \ + > /dev/null 2>&1 || break + b=$(($b + 1)) + done + echo "zram$i can be filled with '$b' KB" + done + + local mem_free1=$(free -m | awk 'NR==2 {print $4}') + local used_mem=$(($mem_free0 - $mem_free1)) + + local total_size=0 + for sm in $zram_sizes; do + local s=$(echo $sm | sed 's/M//') + total_size=$(($total_size + $s)) + done + + echo "zram used ${used_mem}M, zram disk sizes ${total_size}M" + + local v=$((100 * $total_size / $used_mem)) + + 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: OK" +} + +zram_load +zram_max_streams +zram_compress_alg +zram_set_disksizes +zram_set_memlimit +zram_makefs +zram_mount + +zram_fill_fs +zram_cleanup +zram_unload + +if [ $ERR_CODE -ne 0 ]; then + echo "$TCID : [FAIL]" +else + echo "$TCID : [PASS]" +fi diff --git a/tools/testing/selftests/zram/zram02.sh b/tools/testing/selftests/zram/zram02.sh new file mode 100755 index 000000000000..96e82dcc195b --- /dev/null +++ b/tools/testing/selftests/zram/zram02.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# 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 +# GNU General Public License for more details. +# +# Test checks that we can create swap zram device. +# +# Author: Alexey Kodanev +# Modified: Naresh Kamboju + +TCID="zram02" +ERR_CODE=0 + +. ./zram_lib.sh + +# Test will create the following number of zram devices: +dev_num=1 +# This is a list of parameters for zram devices. +# Number of items must be equal to 'dev_num' parameter. +zram_max_streams="2" + +# The zram sysfs node 'disksize' value can be either in bytes, +# or you can use mem suffixes. But in some old kernels, mem +# suffixes are not supported, for example, in RHEL6.6GA's kernel +# layer, it uses strict_strtoull() to parse disksize which does +# not support mem suffixes, in some newer kernels, they use +# memparse() which supports mem suffixes. So here we just use +# bytes to make sure everything works correctly. +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/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh new file mode 100755 index 000000000000..3b6abf1942d7 --- /dev/null +++ b/tools/testing/selftests/zram/zram_lib.sh @@ -0,0 +1,222 @@ +#!/bin/sh +# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# 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 +# GNU General Public License for more details. +# +# Author: Alexey Kodanev +# Modified: Naresh Kamboju + +MODULE=0 +dev_makeswap=-1 +dev_mounted=-1 + +trap INT + +zram_cleanup() +{ + echo "zram cleanup" + local i= + for i in $(seq 0 $dev_makeswap); do + swapoff /dev/zram$i + done + + for i in $(seq 0 $dev_mounted); do + umount /dev/zram$i + done + + for i in $(seq 0 $(($dev_num - 1))); do + echo 1 > /sys/block/zram${i}/reset + rm -rf zram$i + done + +} + +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/block/zram/zram.ko + if [ -f $MODULE_PATH ]; then + MODULE=1 + echo "create '$dev_num' zram device(s)" + modprobe zram num_devices=$dev_num + if [ $? -ne 0 ]; then + echo "failed to insert zram module" + exit 1 + fi + + 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: OK" + 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)" + + local i=0 + for max_s in $zram_max_streams; do + local sys_path="/sys/block/zram${i}/max_comp_streams" + echo $max_s > $sys_path || \ + echo "FAIL failed to set '$max_s' to $sys_path" + sleep 1 + local max_streams=$(cat $sys_path) + + [ "$max_s" -ne "$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)" + done + + echo "zram max streams: OK" +} + +zram_compress_alg() +{ + echo "test that we can set compression algorithm" + + local algs=$(cat /sys/block/zram0/comp_algorithm) + 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 "FAIL can't set '$alg' to $sys_path" + i=$(($i + 1)) + echo "$sys_path = '$alg' ($i/$dev_num)" + done + + echo "zram set compression algorithm: OK" +} + +zram_set_disksizes() +{ + echo "set disk size to zram device(s)" + local i=0 + for ds in $zram_sizes; do + local sys_path="/sys/block/zram${i}/disksize" + echo "$ds" > $sys_path || \ + echo "FAIL can't set '$ds' to $sys_path" + + i=$(($i + 1)) + echo "$sys_path = '$ds' ($i/$dev_num)" + done + + echo "zram set disksizes: OK" +} + +zram_set_memlimit() +{ + echo "set memory limit to zram device(s)" + + local i=0 + for ds in $zram_mem_limits; do + local sys_path="/sys/block/zram${i}/mem_limit" + echo "$ds" > $sys_path || \ + echo "FAIL can't set '$ds' to $sys_path" + + i=$(($i + 1)) + echo "$sys_path = '$ds' ($i/$dev_num)" + done + + echo "zram set memory limit: OK" +} + +zram_makeswap() +{ + echo "make swap with zram device(s)" + local i=0 + for i in $(seq 0 $(($dev_num - 1))); do + mkswap /dev/zram$i > err.log 2>&1 + if [ $? -ne 0 ]; then + cat err.log + echo "FAIL mkswap /dev/zram$1 failed" + fi + + swapon /dev/zram$i > err.log 2>&1 + if [ $? -ne 0 ]; then + cat err.log + echo "FAIL swapon /dev/zram$1 failed" + fi + + echo "done with /dev/zram$i" + dev_makeswap=$i + done + + echo "zram making zram mkswap and swapon: OK" +} + +zram_swapoff() +{ + local i= + for i in $(seq 0 $dev_makeswap); do + swapoff /dev/zram$i > err.log 2>&1 + if [ $? -ne 0 ]; then + cat err.log + echo "FAIL swapoff /dev/zram$i failed" + fi + done + dev_makeswap=-1 + + echo "zram swapoff: OK" +} + +zram_makefs() +{ + local i=0 + for fs in $zram_filesystems; do + # if requested fs not supported default it to ext2 + which mkfs.$fs > /dev/null 2>&1 || fs=ext2 + + echo "make $fs filesystem on /dev/zram$i" + mkfs.$fs /dev/zram$i > err.log 2>&1 + if [ $? -ne 0 ]; then + cat err.log + echo "FAIL failed to make $fs on /dev/zram$i" + fi + i=$(($i + 1)) + echo "zram mkfs.$fs: OK" + done +} + +zram_mount() +{ + local i=0 + for i in $(seq 0 $(($dev_num - 1))); do + echo "mount /dev/zram$i" + mkdir zram$i + mount /dev/zram$i zram$i > /dev/null || \ + echo "FAIL mount /dev/zram$i failed" + dev_mounted=$i + done + + echo "zram mount of zram device(s): OK" +} -- cgit v1.2.3-58-ga151 From a7d0f078892ee5e737cbe79541353c630bc71651 Mon Sep 17 00:00:00 2001 From: Bamvor Jian Zhang Date: Fri, 14 Aug 2015 21:43:35 +0800 Subject: selftests: check before install When the test cases is not supported by the current architecture the install files(TEST_PROGS, TEST_PROGS_EXTENDED and TEST_FILES) will be empty. Check it before installation to dismiss a failure reported by install program. Signed-off-by: Bamvor Jian Zhang Signed-off-by: Shuah Khan --- tools/testing/selftests/Makefile | 1 - tools/testing/selftests/lib.mk | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 9763dd95b4c8..b2179587c8fe 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -72,7 +72,6 @@ ifdef INSTALL_PATH @# Ask all targets to install their files mkdir -p $(INSTALL_PATH) for TARGET in $(TARGETS); do \ - mkdir -p $(INSTALL_PATH)/$$TARGET ; \ make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ done; diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index ee412bab7ed4..97f1c6742066 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -12,11 +12,14 @@ run_tests: all $(RUN_TESTS) define INSTALL_RULE - mkdir -p $(INSTALL_PATH) - @for TEST_DIR in $(TEST_DIRS); do\ - cp -r $$TEST_DIR $(INSTALL_PATH); \ - done; - install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) + @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ + mkdir -p $(INSTALL_PATH); \ + for TEST_DIR in $(TEST_DIRS); do \ + cp -r $$TEST_DIR $(INSTALL_PATH); \ + done; \ + echo "install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)"; \ + install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES); \ + fi endef install: all -- cgit v1.2.3-58-ga151 From 9fae100cbd1049057bbc3e3180a6de339b9b73a9 Mon Sep 17 00:00:00 2001 From: Bamvor Jian Zhang Date: Fri, 14 Aug 2015 21:43:38 +0800 Subject: selftests: breakpoints: fix installing error on the architecture except x86 Signed-off-by: Bamvor Jian Zhang Signed-off-by: Shuah Khan --- tools/testing/selftests/breakpoints/Makefile | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'tools') diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile index 182235640209..d27108b4f208 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile @@ -1,22 +1,12 @@ # Taken from perf makefile uname_M := $(shell uname -m 2>/dev/null || echo not) -ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) -ifeq ($(ARCH),i386) - ARCH := x86 -endif -ifeq ($(ARCH),x86_64) - ARCH := x86 -endif +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) - -all: ifeq ($(ARCH),x86) - gcc breakpoint_test.c -o breakpoint_test -else - echo "Not an x86 target, can't build breakpoints selftests" +TEST_PROGS := breakpoint_test endif -TEST_PROGS := breakpoint_test +all: include ../lib.mk -- cgit v1.2.3-58-ga151 From 2dfb28e3410d775a687d429f5cadf88e795e7eb6 Mon Sep 17 00:00:00 2001 From: Naresh Kamboju Date: Mon, 31 Aug 2015 17:11:55 +0530 Subject: selftests/zram: must be run as root Adding new functionality check_prereqs() to check test must be run as root Signed-off-by: Naresh Kamboju Signed-off-by: Shuah Khan --- tools/testing/selftests/zram/zram.sh | 12 ++++++++++++ tools/testing/selftests/zram/zram01.sh | 1 + tools/testing/selftests/zram/zram02.sh | 1 + tools/testing/selftests/zram/zram_lib.sh | 10 ++++++++++ 4 files changed, 24 insertions(+) (limited to 'tools') diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh index 6ea4b6a5ccab..20de9a761269 100755 --- a/tools/testing/selftests/zram/zram.sh +++ b/tools/testing/selftests/zram/zram.sh @@ -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 diff --git a/tools/testing/selftests/zram/zram01.sh b/tools/testing/selftests/zram/zram01.sh index 2a2475d4b201..b9566a6478a9 100755 --- a/tools/testing/selftests/zram/zram01.sh +++ b/tools/testing/selftests/zram/zram01.sh @@ -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 diff --git a/tools/testing/selftests/zram/zram02.sh b/tools/testing/selftests/zram/zram02.sh index 96e82dcc195b..74569b883737 100755 --- a/tools/testing/selftests/zram/zram02.sh +++ b/tools/testing/selftests/zram/zram02.sh @@ -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 diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh index 3b6abf1942d7..424e68ed1487 100755 --- a/tools/testing/selftests/zram/zram_lib.sh +++ b/tools/testing/selftests/zram/zram_lib.sh @@ -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" -- cgit v1.2.3-58-ga151 From 7eba7d90d48217a97afc171a311b386bde965f39 Mon Sep 17 00:00:00 2001 From: Naresh Kamboju Date: Mon, 31 Aug 2015 17:11:56 +0530 Subject: selftests/zram: Makefile fix Do not override run_tests, The default rule will just run TEST_PROGS Signed-off-by: Naresh Kamboju Acked-by: Michael Ellerman Signed-off-by: Shuah Khan --- tools/testing/selftests/zram/Makefile | 3 --- 1 file changed, 3 deletions(-) (limited to 'tools') diff --git a/tools/testing/selftests/zram/Makefile b/tools/testing/selftests/zram/Makefile index ec45513c7303..29d80346e3eb 100644 --- a/tools/testing/selftests/zram/Makefile +++ b/tools/testing/selftests/zram/Makefile @@ -5,8 +5,5 @@ TEST_FILES := zram01.sh zram02.sh zram_lib.sh include ../lib.mk -run_tests: - @/bin/bash ./zram.sh - clean: $(RM) err.log -- cgit v1.2.3-58-ga151