All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] commands/mkswap: Added new testcase to test mkswap(8).
Date: Fri, 6 Nov 2015 13:17:10 +0800	[thread overview]
Message-ID: <563C37D6.1050707@cn.fujitsu.com> (raw)
In-Reply-To: <563B404D.8040504@oracle.com>

Hi!
Thanks for your review!

On 2015/11/05 19:41, Alexey Kodanev wrote:
> Hi,
> On 11/05/2015 06:03 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    |  24 +++++
>>   testcases/commands/mkswap/mkswap01.sh | 196 ++++++++++++++++++++++++++++++++++
>>   3 files changed, 221 insertions(+)
>>   create mode 100644 testcases/commands/mkswap/Makefile
>>   create mode 100755 testcases/commands/mkswap/mkswap01.sh
>>
>> diff --git a/runtest/commands b/runtest/commands
>> index 6c0485b..ab600dc 100644
>> --- a/runtest/commands
>> +++ b/runtest/commands
>> @@ -38,3 +38,4 @@ mkfs01_minix mkfs01.sh -f minix
>>   mkfs01_msdos mkfs01.sh -f msdos
>>   mkfs01_vfat mkfs01.sh -f vfat
>>   mkfs01_ntfs mkfs01.sh -f ntfs
>> +mkswap01 mkswap01.sh
>> diff --git a/testcases/commands/mkswap/Makefile b/testcases/commands/mkswap/Makefile
>> new file mode 100644
>> index 0000000..39651c0
>> --- /dev/null
>> +++ b/testcases/commands/mkswap/Makefile
>> @@ -0,0 +1,24 @@
>> +#
>> +#    commands/mkswap testcases Makefile.
> 
> There is no need for such a comment.
> 

OK, got it.

>> +#
>> +#
>> +
>> +setup()
>> +{
>> +    tst_require_root
>> +
>> +    tst_check_cmds losetup free mkswap
>> +
>> +    tst_tmpdir
>> +
>> +    TST_CLEANUP=cleanup
>> +
>> +    tst_acquire_device
>> +
>> +    local path=`losetup -a | grep "$TMPDIR"  | awk '{print $3}' | \
>> +        cut -d '(' -f2 | cut -d ')' -f1`
> 
> Isn't it easier to get path with $(losetup -l | grep tmp | awk '{print $6}')
> 

Yes, it's easier to use losetup -l, but RHEL5.11GA does not support -l option,
so I would use losetup -a here.

>> +    DEVICE_SIZE=$((`ls -l $path | awk '{print $5}'`/1024))
>> +
>> +    PAGE_SIZE=`getconf PAGE_SIZE`
>> +}
>> +
>> +cleanup()
>> +{
>> +    tst_release_device
>> +
>> +    tst_rmdir
>> +}
>> +
>> +mkswap_verify()
>> +{
>> +    local ret=0
>> +
>> +    local before=`free | grep "Swap" | awk '{print $2}'`
>> +
>> +    if [ -z "$4" ]; then
>> +        local swapsize=$DEVICE_SIZE
>> +    else
>> +        local swapsize=$4
>> +    fi
>> +
>> +    if [ "$1" = "-p" ]; then
>> +        local pagesize=$2
> 
> I would name each parameter ($1,$2,...) in the begining of the function as of make them more informative.
> Or use "while getopts; do".
> 

Indeed, it needs to be more informative.
I will name them, thanks.

>> +
>> +mkswap_test()
>> +{
>> +    local mkswap_op=$1
>> +    local op_arg=$2
>> +    local device=$3
>> +    local size=$4
>> +
>> +    local mkswap_cmd="mkswap $mkswap_op $op_arg $device $size"
>> +
>> +    ${mkswap_cmd} >temp 2>&1
>> +    if [ $? -ne 0 ]; then
>> +        grep -q -E "unknown option|invalid option|Usage" temp
>> +        if [ $? -eq 0 ]; then
>> +            tst_resm TCONF "'${mkswap_cmd}' not supported."
>> +            return
>> +        else
> 
> Don't need 'else' after return.
> 

OK, got it.

>> +            tst_resm TFAIL "'${mkswap_cmd}' failed."
>> +            cat temp
>> +            return
>> +        fi
>> +    fi
>> +
>> +    if [ -n "$device" ]; then
>> +        mkswap_verify "$mkswap_op" "$op_arg" "$device" "$size"
>> +        if [ $? -ne 0 ]; then
>> +            tst_resm TFAIL "'${mkswap_cmd}' failed, not expected."
>> +            return
>> +        fi
>> +    fi
>> +
>> +    tst_resm TPASS "'${mkswap_cmd}' passed."
>> +}
>> +
>> +test1()
>> +{
>> +    mkswap_test "" "" "$TST_DEVICE"
>> +}
> 
> May be it would be better to call mkswap_test() without such wrappers and the for loop in the end.
> 

Sorry, do you mean just call mkswap_test() straightforward with different arguments for all these tests?

Best Regards,
Guangwen Feng

> Best regards,
> Alexey
> .
> 

  reply	other threads:[~2015-11-06  5:17 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 [this message]
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
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=563C37D6.1050707@cn.fujitsu.com \
    --to=fenggw-fnst@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.