From patchwork Fri Jan 29 19:41:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1433484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DS75h5NYLz9sSs for ; Sat, 30 Jan 2021 06:42:13 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2DAB13C77FA for ; Fri, 29 Jan 2021 20:42:03 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 723CA3C100E for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 1275D601D55 for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8A416B115; Fri, 29 Jan 2021 19:41:59 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 29 Jan 2021 20:41:39 +0100 Message-Id: <20210129194144.31299-2-pvorel@suse.cz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210129194144.31299-1-pvorel@suse.cz> References: <20210129194144.31299-1-pvorel@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v2 1/6] zram: Calculate dev_num variable X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Instead of requiring to be set. Reviewed-by: Cyril Hrubis Signed-off-by: Petr Vorel --- changes v1->v2: Added paranoid check: + if [ $dev_num -le 0 ]; then + tst_brk TBROK "dev_num must be > 0" + fi Kind regards, Petr testcases/kernel/device-drivers/zram/zram01.sh | 8 +++----- testcases/kernel/device-drivers/zram/zram02.sh | 8 +++----- testcases/kernel/device-drivers/zram/zram_lib.sh | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh index 8de2c0cad..a795ff89f 100755 --- a/testcases/kernel/device-drivers/zram/zram01.sh +++ b/testcases/kernel/device-drivers/zram/zram01.sh @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. -# Copyright (c) 2019 Petr Vorel +# Copyright (c) 2019-2021 Petr Vorel # Author: Alexey Kodanev # # Test creates several zram devices with different filesystems on them. @@ -11,10 +11,8 @@ TST_TESTFUNC="do_test" TST_NEEDS_CMDS="awk bc dd" . zram_lib.sh -# Test will create the following number of zram devices: -dev_num=4 -# This is a list of parameters for zram devices. -# Number of items must be equal to 'dev_num' parameter. +# List of parameters for zram devices. +# For each number the test creates own zram device. zram_max_streams="2 3 5 8" FS_SIZE="402653184" diff --git a/testcases/kernel/device-drivers/zram/zram02.sh b/testcases/kernel/device-drivers/zram/zram02.sh index f97cf646c..b4d706568 100755 --- a/testcases/kernel/device-drivers/zram/zram02.sh +++ b/testcases/kernel/device-drivers/zram/zram02.sh @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. -# Copyright (c) 2019 Petr Vorel +# Copyright (c) 2019-2021 Petr Vorel # Author: Alexey Kodanev # # Test checks that we can create swap zram device. @@ -9,10 +9,8 @@ TST_CNT=5 TST_TESTFUNC="do_test" . 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. +# List of parameters for zram devices. +# For each number the test creates own zram device. zram_max_streams="2" # The zram sysfs node 'disksize' value can be either in bytes, diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh index 6fa6552ca..a7e8b9f5b 100755 --- a/testcases/kernel/device-drivers/zram/zram_lib.sh +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh @@ -34,7 +34,19 @@ zram_cleanup() zram_load() { + local tmp + + dev_num=0 + for tmp in $zram_max_streams; do + dev_num=$((dev_num+1)) + done + + if [ $dev_num -le 0 ]; then + tst_brk TBROK "dev_num must be > 0" + fi + tst_res TINFO "create '$dev_num' zram device(s)" + modprobe zram num_devices=$dev_num || \ tst_brk TBROK "failed to insert zram module" @@ -42,9 +54,9 @@ zram_load() if [ "$dev_num_created" -ne "$dev_num" ]; then tst_brk TFAIL "unexpected num of devices: $dev_num_created" - else - tst_res TPASS "test succeeded" fi + + tst_res TPASS "all zram devices successfully created" } zram_max_streams() From patchwork Fri Jan 29 19:41:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1433489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DS76S6KYjz9sSC for ; Sat, 30 Jan 2021 06:42:56 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 530163C7841 for ; Fri, 29 Jan 2021 20:42:54 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 2B5F63C77F8 for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 288891A00900 for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BEE1AB117; Fri, 29 Jan 2021 19:41:59 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 29 Jan 2021 20:41:40 +0100 Message-Id: <20210129194144.31299-3-pvorel@suse.cz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210129194144.31299-1-pvorel@suse.cz> References: <20210129194144.31299-1-pvorel@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=LOTS_OF_MONEY,SPF_HELO_NONE, SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v2 2/6] zram01.sh: Generate test setup variables in setup X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Generate variables in setup, based on output of tst_supported_fs. This is more clean approach and it fixes various things: * Error when there is no filesystem support and also mkfs.ext2 (fallback) not installed: /opt/ltp/testcases/bin/zram01.sh: line 198: mkfs.ext2: not found Instead quit if there is no fs support. But this can lead to skipping zram_compress_alg(), it will be solved next commit by moving zram_compress_alg() to zram02.sh. * Having ext2 as fallback could lead to run it more than once. There is no much point to do that. * Drop tst_require_cmds mkfs check, because mkfs is not actually needed. Improvements: * Test all suitable filesystems (will need increase timeout). Signed-off-by: Petr Vorel Reviewed-by: Cyril Hrubis --- changes v1->v2: Completely rewritten. .../kernel/device-drivers/zram/zram01.sh | 62 ++++++++++++++----- .../kernel/device-drivers/zram/zram_lib.sh | 18 +++--- 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh index a795ff89f..c5d4a3e51 100755 --- a/testcases/kernel/device-drivers/zram/zram01.sh +++ b/testcases/kernel/device-drivers/zram/zram01.sh @@ -8,23 +8,25 @@ TST_CNT=7 TST_TESTFUNC="do_test" -TST_NEEDS_CMDS="awk bc dd" +TST_NEEDS_CMDS="awk bc dd grep" . zram_lib.sh +TST_SETUP="setup" -# List of parameters for zram devices. -# For each number the test creates own zram device. -zram_max_streams="2 3 5 8" - -FS_SIZE="402653184" -FS_TYPE="btrfs" +get_btrfs_size() +{ + local ram_size -RAM_SIZE=$(awk '/MemTotal:/ {print $2}' /proc/meminfo) -if [ "$RAM_SIZE" -lt 1048576 ]; then - tst_res TINFO "not enough space for Btrfs" - FS_SIZE="26214400" - FS_TYPE="ext2" -fi + ram_size=$(awk '/MemTotal:/ {print $2}' /proc/meminfo) + if [ "$ram_size" -lt 1048576 ]; then + tst_res TINFO "not enough space for Btrfs" + return 1 + fi + return 0 +} +# List of parameters for zram devices. +# For each number the test creates own zram device. +# NOTE about size: # 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 @@ -32,9 +34,37 @@ fi # 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="26214400 26214400 26214400 $FS_SIZE" -zram_mem_limits="25M 25M 25M $((FS_SIZE/1024/1024))M" -zram_filesystems="ext3 ext4 xfs $FS_TYPE" +generate_vars() +{ + local fs limit size stream=-1 + dev_num=0 + + for fs in $(tst_supported_fs | grep -v -e fat -e ntfs -e fuse); do + size="26214400" + limit="25M" + if [ "$fs" = "btrfs" ]; then + get_btrfs_size || continue + size="402653184" + limit="$((size/1024/1024))M" + fi + + stream=$((stream+3)) + dev_num=$((dev_num+1)) + zram_filesystems="$zram_filesystems $fs" + zram_mem_limits="$zram_mem_limits $limit" + zram_sizes="$zram_sizes $size" + zram_max_streams="$zram_max_streams $stream" + done + + [ $dev_num -eq 0 ] && \ + tst_brk TCONF "no suitable filesystem" +} + +setup() +{ + generate_vars + zram_load +} zram_fill_fs() { diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh index a7e8b9f5b..d4aaf0c3e 100755 --- a/testcases/kernel/device-drivers/zram/zram_lib.sh +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh @@ -36,10 +36,12 @@ zram_load() { local tmp - dev_num=0 - for tmp in $zram_max_streams; do - dev_num=$((dev_num+1)) - done + if [ -z "$dev_num" ]; then + dev_num=0 + for tmp in $zram_max_streams; do + dev_num=$((dev_num+1)) + done + fi if [ $dev_num -le 0 ]; then tst_brk TBROK "dev_num must be > 0" @@ -129,6 +131,7 @@ zram_set_disksizes() i=$(($i + 1)) tst_res TINFO "$sys_path = '$ds' ($i/$dev_num)" + [ $i -eq $dev_num ] && break done tst_res TPASS "test succeeded" @@ -155,6 +158,7 @@ zram_set_memlimit() i=$(($i + 1)) tst_res TINFO "$sys_path = '$ds' ($i/$dev_num)" + [ $i -eq $dev_num ] && break done tst_res TPASS "test succeeded" @@ -191,13 +195,10 @@ zram_swapoff() zram_makefs() { - tst_require_cmds mkfs local i=0 + local fs for fs in $zram_filesystems; do - # if requested fs not supported default it to ext2 - tst_supported_fs $fs 2> /dev/null || fs=ext2 - tst_res TINFO "make $fs filesystem on /dev/zram$i" mkfs.$fs /dev/zram$i > err.log 2>&1 if [ $? -ne 0 ]; then @@ -206,6 +207,7 @@ zram_makefs() fi i=$(($i + 1)) + [ $i -eq $dev_num ] && break done tst_res TPASS "zram_makefs succeeded" From patchwork Fri Jan 29 19:41:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1433486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DS75s3h78z9sSC for ; Sat, 30 Jan 2021 06:42:25 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id F19553C7801 for ; Fri, 29 Jan 2021 20:42:22 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 946F13C100E for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 5B6A21A00924 for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 01B1EB118; Fri, 29 Jan 2021 19:42:00 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 29 Jan 2021 20:41:41 +0100 Message-Id: <20210129194144.31299-4-pvorel@suse.cz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210129194144.31299-1-pvorel@suse.cz> References: <20210129194144.31299-1-pvorel@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v2 3/6] zram: Move zram_compress_alg() to zram02.sh X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Quit at setup in case there is no fs support (change in previous commit) can lead to skipping zram_compress_alg(). Move to zram02.sh where is no such limitation. Signed-off-by: Petr Vorel --- The same as in v1. testcases/kernel/device-drivers/zram/zram01.sh | 13 ++++++------- testcases/kernel/device-drivers/zram/zram02.sh | 11 ++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh index c5d4a3e51..5e99f8bb8 100755 --- a/testcases/kernel/device-drivers/zram/zram01.sh +++ b/testcases/kernel/device-drivers/zram/zram01.sh @@ -6,7 +6,7 @@ # Test creates several zram devices with different filesystems on them. # It fills each device with zeros and checks that compression works. -TST_CNT=7 +TST_CNT=6 TST_TESTFUNC="do_test" TST_NEEDS_CMDS="awk bc dd grep" . zram_lib.sh @@ -108,12 +108,11 @@ do_test() { case $1 in 1) zram_max_streams;; - 2) zram_compress_alg;; - 3) zram_set_disksizes;; - 4) zram_set_memlimit;; - 5) zram_makefs;; - 6) zram_mount;; - 7) zram_fill_fs;; + 2) zram_set_disksizes;; + 3) zram_set_memlimit;; + 4) zram_makefs;; + 5) zram_mount;; + 6) zram_fill_fs;; esac } diff --git a/testcases/kernel/device-drivers/zram/zram02.sh b/testcases/kernel/device-drivers/zram/zram02.sh index b4d706568..d09977ec1 100755 --- a/testcases/kernel/device-drivers/zram/zram02.sh +++ b/testcases/kernel/device-drivers/zram/zram02.sh @@ -5,7 +5,7 @@ # # Test checks that we can create swap zram device. -TST_CNT=5 +TST_CNT=6 TST_TESTFUNC="do_test" . zram_lib.sh @@ -27,10 +27,11 @@ do_test() { case $1 in 1) zram_max_streams;; - 2) zram_set_disksizes;; - 3) zram_set_memlimit;; - 4) zram_makeswap;; - 5) zram_swapoff;; + 2) zram_compress_alg;; + 3) zram_set_disksizes;; + 4) zram_set_memlimit;; + 5) zram_makeswap;; + 6) zram_swapoff;; esac } From patchwork Fri Jan 29 19:41:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1433488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DS76G1xH4z9sSC for ; Sat, 30 Jan 2021 06:42:46 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8003B3C77F3 for ; Fri, 29 Jan 2021 20:42:43 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id 204823C5A22 for ; Fri, 29 Jan 2021 20:42:01 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 8609D1400550 for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2B0F2B119; Fri, 29 Jan 2021 19:42:00 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 29 Jan 2021 20:41:42 +0100 Message-Id: <20210129194144.31299-5-pvorel@suse.cz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210129194144.31299-1-pvorel@suse.cz> References: <20210129194144.31299-1-pvorel@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v2 4/6] zram: Move test specific functions out of zram_lib.sh X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Refactoring, as code is confusing enough, when use global variables and functions which are single test specific + there is zram_fill_fs already in zram01.sh. Signed-off-by: Petr Vorel --- The same as in v1. .../kernel/device-drivers/zram/zram01.sh | 34 +++++++ .../kernel/device-drivers/zram/zram02.sh | 58 ++++++++++++ .../kernel/device-drivers/zram/zram_lib.sh | 92 ------------------- 3 files changed, 92 insertions(+), 92 deletions(-) diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh index 5e99f8bb8..695de14a1 100755 --- a/testcases/kernel/device-drivers/zram/zram01.sh +++ b/testcases/kernel/device-drivers/zram/zram01.sh @@ -66,6 +66,40 @@ setup() zram_load } +zram_makefs() +{ + local i=0 + local fs + + for fs in $zram_filesystems; do + tst_res TINFO "make $fs filesystem on /dev/zram$i" + mkfs.$fs /dev/zram$i > err.log 2>&1 + if [ $? -ne 0 ]; then + cat err.log + tst_brk TFAIL "failed to make $fs on /dev/zram$i" + fi + + i=$(($i + 1)) + [ $i -eq $dev_num ] && break + done + + tst_res TPASS "zram_makefs succeeded" +} + +zram_mount() +{ + local i=0 + + for i in $(seq 0 $(($dev_num - 1))); do + tst_res TINFO "mount /dev/zram$i" + mkdir zram$i + ROD mount /dev/zram$i zram$i + dev_mounted=$i + done + + tst_res TPASS "mount of zram device(s) succeeded" +} + zram_fill_fs() { for i in $(seq 0 $(($dev_num - 1))); do diff --git a/testcases/kernel/device-drivers/zram/zram02.sh b/testcases/kernel/device-drivers/zram/zram02.sh index d09977ec1..803b8dc29 100755 --- a/testcases/kernel/device-drivers/zram/zram02.sh +++ b/testcases/kernel/device-drivers/zram/zram02.sh @@ -23,6 +23,64 @@ zram_max_streams="2" zram_sizes="107374182400" # 100GB zram_mem_limits="1M" +zram_compress_alg() +{ + if tst_kvcmp -lt "3.15"; then + tst_res TCONF "device attribute comp_algorithm is"\ + "introduced since kernel v3.15, the running kernel"\ + "does not support it" + return + fi + + local i=0 + + tst_res TINFO "test that we can set compression algorithm" + local algs="$(sed 's/[][]//g' /sys/block/zram0/comp_algorithm)" + tst_res TINFO "supported algs: $algs" + + local dev_max=$(($dev_num - 1)) + + for i in $(seq 0 $dev_max); do + for alg in $algs; do + local sys_path="/sys/block/zram${i}/comp_algorithm" + echo "$alg" > $sys_path || \ + tst_brk TFAIL "can't set '$alg' to $sys_path" + tst_res TINFO "$sys_path = '$alg' ($i/$dev_max)" + done + done + + tst_res TPASS "test succeeded" +} + +zram_makeswap() +{ + tst_res TINFO "make swap with zram device(s)" + tst_require_cmds mkswap swapon swapoff + local i=0 + + for i in $(seq 0 $(($dev_num - 1))); do + ROD mkswap /dev/zram$i + ROD swapon /dev/zram$i + tst_res TINFO "done with /dev/zram$i" + dev_makeswap=$i + done + + tst_res TPASS "making zram swap succeeded" +} + +zram_swapoff() +{ + tst_require_cmds swapoff + local i + + for i in $(seq 0 $dev_makeswap); do + ROD swapoff /dev/zram$i + done + dev_makeswap=-1 + + tst_res TPASS "swapoff completed" +} + do_test() { case $1 in diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh index d4aaf0c3e..26ed1846b 100755 --- a/testcases/kernel/device-drivers/zram/zram_lib.sh +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh @@ -89,35 +89,6 @@ zram_max_streams() tst_res TPASS "test succeeded" } -zram_compress_alg() -{ - if tst_kvcmp -lt "3.15"; then - tst_res TCONF "device attribute comp_algorithm is"\ - "introduced since kernel v3.15, the running kernel"\ - "does not support it" - return - fi - - local i=0 - - tst_res TINFO "test that we can set compression algorithm" - local algs="$(sed 's/[][]//g' /sys/block/zram0/comp_algorithm)" - tst_res TINFO "supported algs: $algs" - - local dev_max=$(($dev_num - 1)) - - for i in $(seq 0 $dev_max); do - for alg in $algs; do - local sys_path="/sys/block/zram${i}/comp_algorithm" - echo "$alg" > $sys_path || \ - tst_brk TFAIL "can't set '$alg' to $sys_path" - tst_res TINFO "$sys_path = '$alg' ($i/$dev_max)" - done - done - - tst_res TPASS "test succeeded" -} - zram_set_disksizes() { local i=0 @@ -163,66 +134,3 @@ zram_set_memlimit() tst_res TPASS "test succeeded" } - -zram_makeswap() -{ - tst_res TINFO "make swap with zram device(s)" - tst_require_cmds mkswap swapon swapoff - local i=0 - - for i in $(seq 0 $(($dev_num - 1))); do - ROD mkswap /dev/zram$i - ROD swapon /dev/zram$i - tst_res TINFO "done with /dev/zram$i" - dev_makeswap=$i - done - - tst_res TPASS "making zram swap succeeded" -} - -zram_swapoff() -{ - tst_require_cmds swapoff - local i - - for i in $(seq 0 $dev_makeswap); do - ROD swapoff /dev/zram$i - done - dev_makeswap=-1 - - tst_res TPASS "swapoff completed" -} - -zram_makefs() -{ - local i=0 - local fs - - for fs in $zram_filesystems; do - tst_res TINFO "make $fs filesystem on /dev/zram$i" - mkfs.$fs /dev/zram$i > err.log 2>&1 - if [ $? -ne 0 ]; then - cat err.log - tst_brk TFAIL "failed to make $fs on /dev/zram$i" - fi - - i=$(($i + 1)) - [ $i -eq $dev_num ] && break - done - - tst_res TPASS "zram_makefs succeeded" -} - -zram_mount() -{ - local i=0 - - for i in $(seq 0 $(($dev_num - 1))); do - tst_res TINFO "mount /dev/zram$i" - mkdir zram$i - ROD mount /dev/zram$i zram$i - dev_mounted=$i - done - - tst_res TPASS "mount of zram device(s) succeeded" -} From patchwork Fri Jan 29 19:41:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1433487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DS7624DbRz9sSC for ; Sat, 30 Jan 2021 06:42:34 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EB04D3C7813 for ; Fri, 29 Jan 2021 20:42:31 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id ECC503C100E for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id B69C5601D5D for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5AA75B11A; Fri, 29 Jan 2021 19:42:00 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 29 Jan 2021 20:41:43 +0100 Message-Id: <20210129194144.31299-6-pvorel@suse.cz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210129194144.31299-1-pvorel@suse.cz> References: <20210129194144.31299-1-pvorel@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [RFC PATCH v2 5/6] tst_test.sh: Run _tst_setup_timer after $TST_SETUP X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Postpone starting timer a bit after the execution allow to setup timer in test setup. This is useful if test length depends on input decided during setup. Signed-off-by: Petr Vorel --- New in v2. Hi, I'm ok, if you consider this risky. Next commit can be then changed to have TST_TIMEOUT=-1. Kind regards, Petr doc/test-writing-guidelines.txt | 5 ++++- testcases/lib/tst_test.sh | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index f3a55cf26..61dccd400 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -2398,7 +2398,10 @@ simply by setting right '$TST_NEEDS_FOO'. | 'TST_TIMEOUT' | Maximum timeout set for the test in sec. Must be int >= 1, or -1 (special value to disable timeout), default is 300. Variable is meant be set in tests, not by user. - It's equivalent of `tst_test.timeout` in C. + It's equivalent of `tst_test.timeout` in C, but (unlike + the C API) it can be set also in the setup function. + This is useful if test length depends on input decided + during setup. |============================================================================= NOTE: Network tests (see testcases/network/README.md) use additional variables diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index 69f007d89..4fa1674cd 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -552,8 +552,6 @@ tst_run() tst_brk TCONF "test requires kernel $TST_MIN_KVER+" fi - _tst_setup_timer - [ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1 if [ "$TST_NEEDS_TMPDIR" = 1 ]; then @@ -594,6 +592,8 @@ tst_run() fi fi + _tst_setup_timer + #TODO check that test reports some results for each test function call while [ $TST_ITERATIONS -gt 0 ]; do if [ -n "$TST_TEST_DATA" ]; then From patchwork Fri Jan 29 19:41:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1433490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DS76d52ytz9sSs for ; Sat, 30 Jan 2021 06:43:05 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3DBE53C5E65 for ; Fri, 29 Jan 2021 20:43:03 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 4D8B83C77FE for ; Fri, 29 Jan 2021 20:42:01 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id E5C5B1A00ED8 for ; Fri, 29 Jan 2021 20:42:00 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 871B3B11B; Fri, 29 Jan 2021 19:42:00 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 29 Jan 2021 20:41:44 +0100 Message-Id: <20210129194144.31299-7-pvorel@suse.cz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210129194144.31299-1-pvorel@suse.cz> References: <20210129194144.31299-1-pvorel@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v2 6/6] zram: Increase timeout according to used devices X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" to avoid unexpected timeout, which occurred even on just 4 devices. Default setup is 300, using 200 should be safe. Signed-off-by: Petr Vorel --- New in v2. testcases/kernel/device-drivers/zram/zram_lib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh index 26ed1846b..c24b83cfc 100755 --- a/testcases/kernel/device-drivers/zram/zram_lib.sh +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh @@ -47,6 +47,8 @@ zram_load() tst_brk TBROK "dev_num must be > 0" fi + TST_TIMEOUT=$((dev_num*200)) + tst_res TINFO "create '$dev_num' zram device(s)" modprobe zram num_devices=$dev_num || \