public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Alexey Kodanev <alexey.kodanev@oracle.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] commands/mkswap: Added new testcase to test mkswap(8).
Date: Wed, 11 Nov 2015 12:44:32 +0300	[thread overview]
Message-ID: <56430E00.1050708@oracle.com> (raw)
In-Reply-To: <1447056173-8979-1-git-send-email-fenggw-fnst@cn.fujitsu.com>

Hi,
On 11/09/2015 11:02 AM, Guangwen Feng wrote:
> Test mkswap(8) command with some basic options.
>
> Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> ---
>   runtest/commands                      |   1 +
>   testcases/commands/mkswap/Makefile    |  22 +++++
>   testcases/commands/mkswap/mkswap01.sh | 155 ++++++++++++++++++++++++++++++++++
>   3 files changed, 178 insertions(+)
>   create mode 100644 testcases/commands/mkswap/Makefile
>   create mode 100755 testcases/commands/mkswap/mkswap01.sh
...
> ...
> +
> +mkswap_verify()
> +{
> +	local mkswap_op=$1
> +	local op_arg=$2
> +	local device=$3
> +	local size=$4
> +
> +	local ret=0
> +
> +	local before=`free | grep "Swap" | awk '{print $2}'`
> +
> +	if [ -z "$size" ]; then
> +		local swapsize=$DEVICE_SIZE
> +	else
> +		local swapsize=$size
> +	fi

No need to check it here if you define single variable, i.e. 
size=${4:-$DEVICE_SIZE}

> +
> +	if [ "$mkswap_op" = "-p" ]; then
> +		local pagesize=$op_arg
> +	else
> +		local pagesize=$PAGE_SIZE
> +	fi
> +
> +	if [ "$mkswap_op" = "-L" ]; then
> +		local swap_op="-L"
> +		local swapfile=$op_arg
> +	elif [ "$mkswap_op" = "-U" ]; then
> +		local swap_op="-U"

'swap_op' var is redundant, instead just set "mkswap_op=" in the else 
branch below.

> +		local swapfile=$op_arg
> +	else
> +		local swap_op=""
> +		local swapfile=$device
> +	fi
> +

> +	swapon $swap_op $swapfile 2>/dev/null
> +	if [ $? -ne 0 ]; then
> +		tst_resm TINFO "can not do swapon on $swapfile."
> +		if [ $pagesize -ne $PAGE_SIZE ]; then
> +			return $ret
> +		fi
> +
> +		if [ $swapsize -gt $DEVICE_SIZE ]; then
> +			return $ret
> +		fi
> +	fi
> +

There are two conditions that returns 0 when swapon command fails. If it 
is expected result, could you provide more informative tst_resm message 
in each case. Other cases should return 1, right? But the test proceeds 
further.

Thanks,
Alexey

  parent reply	other threads:[~2015-11-11  9:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05  3:03 [LTP] [PATCH] commands/mkswap: Added new testcase to test mkswap(8) Guangwen Feng
2015-11-05 11:41 ` Alexey Kodanev
2015-11-06  5:17   ` Guangwen Feng
2015-11-06 11:54     ` Alexey Kodanev
2015-11-09  8:02       ` [LTP] [PATCH v2] " Guangwen Feng
2015-11-11  4:50         ` Lei Li
2015-11-12  3:32           ` Guangwen Feng
2015-11-11  9:44         ` Alexey Kodanev [this message]
2015-11-12  3:36           ` Guangwen Feng
2015-11-12  8:23             ` [LTP] [PATCH v3] " Guangwen Feng
2015-11-16 16:31               ` Cyril Hrubis
2015-11-17  2:22                 ` Guangwen Feng
2015-11-18  9:12                   ` [LTP] [PATCH v4] " Guangwen Feng
2015-11-19 13:41                     ` Cyril Hrubis
2015-11-20  5:36                       ` Guangwen Feng
2015-11-20  6:04                         ` [LTP] [PATCH v5] " Guangwen Feng
2015-11-24 16:26                           ` Cyril Hrubis
2015-11-09  2:00 ` [LTP] [PATCH] " Lei Li
2015-11-09  6:54   ` Guangwen Feng
2015-11-11  3:45     ` Lei Li
2015-11-12  3:27       ` Guangwen Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56430E00.1050708@oracle.com \
    --to=alexey.kodanev@oracle.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox