[LTP] [PATCH v2] commands/mkswap: Added new testcase to test mkswap(8).
Alexey Kodanev
alexey.kodanev@oracle.com
Wed Nov 11 10:44:32 CET 2015
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
More information about the Ltp
mailing list