public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: DAN LI <li.dan@cn.fujitsu.com>
Cc: LTP list <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH 1/2] Add support for xfs quota tests
Date: Wed, 17 Jul 2013 14:05:22 +0200	[thread overview]
Message-ID: <20130717120522.GB25145@rei> (raw)
In-Reply-To: <51E6272B.3020509@cn.fujitsu.com>

Hi!
> Add support for xfs quota tests:
> 
>   *Create a xfs block device
> 
>   *Define HAVE_XFS_QUOTA to show if xfs quota is available
> 
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
> ---
>  configure.ac        |  1 +
>  m4/ltp-xfs_quota.m4 | 39 +++++++++++++++++++++++++++++++++++++
>  runltp              | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 95 insertions(+), 1 deletion(-)
>  create mode 100644 m4/ltp-xfs_quota.m4
> 
> diff --git a/configure.ac b/configure.ac
> index f0fc6b0..1f95603 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -168,5 +168,6 @@ LTP_CHECK_ACL_SUPPORT
>  LTP_CHECK_FS_IOC_FLAGS
>  LTP_CHECK_MREMAP_FIXED
>  LTP_CHECK_KERNEL_DEVEL
> +LTP_CHECK_XFS_QUOTACTL
> 
>  AC_OUTPUT
> diff --git a/m4/ltp-xfs_quota.m4 b/m4/ltp-xfs_quota.m4
> new file mode 100644
> index 0000000..a17d4d9
> --- /dev/null
> +++ b/m4/ltp-xfs_quota.m4
> @@ -0,0 +1,39 @@
> +dnl
> +dnl Copyright (c) 2013 Fujitsu Ltd.
> +dnl Author: DAN LI <li.dan@cn.fujitsu.com>
> +dnl
> +dnl This program is free software;  you can redistribute it and/or modify
> +dnl it under the terms of the GNU General Public License as published by
> +dnl the Free Software Foundation; either version 2 of the License, or
> +dnl (at your option) any later version.
> +dnl
> +dnl This program is distributed in the hope that it will be useful,
> +dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +dnl the GNU General Public License for more details.
> +dnl
> +dnl You should have received a copy of the GNU General Public License
> +dnl along with this program;  if not, write to the Free Software
> +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> +dnl
> +
> +dnl
> +dnl LTP_CHECK_XFS_QUOTACTL
> +dnl ----------------------------
> +dnl
> +AC_DEFUN([LTP_CHECK_XFS_QUOTACTL],[dnl
> +	AC_LINK_IFELSE([AC_LANG_SOURCE([
> +#include <xfs/xqm.h>
> +#include <sys/quota.h>
> +int main(void) {
> +	struct fs_quota_stat qstat;
> +	return quotactl(QCMD(Q_XGETQSTAT, USRQUOTA), (const char *) "/dev/null",
> +			geteuid(), (caddr_t) &qstat);

Why the (const char *) and (caddr_t) casts?

> +}])],[has_xfs_quota="yes"])
> +
> +if test "x$has_xfs_quota" = xyes; then
> +	AC_DEFINE(HAVE_XFS_QUOTA,1,[Define to 1 if you have xfs quota])
> +else
> +	AC_MSG_WARN(No xfs quota support)
> +fi
> +])
> diff --git a/runltp b/runltp
> index 28e6bed..210a332 100755
> --- a/runltp
> +++ b/runltp
> @@ -163,6 +163,7 @@ usage()
>      -b DEVICE       Some tests require an unmounted block device
>                      to run correctly.
>      -B DEVICE_FS_TYPE The file system of test block devices.
> +    -X XFS_DEVICE   Some tests require an unmounted xfs-format block device
> 
> 
>      example: ${0##*/} -c 2 -i 2 -m 2,4,10240,1 -D 2,10,10240,1 -p -q  -l /tmp/result-log.$$ -o /tmp/result-output.$$ -C
> /tmp/result-failed.$$ -d ${PWD}
> @@ -211,7 +212,7 @@ main()
> 
>      version_date=$(cat "$LTPROOT/Version")
> 
> -    while getopts a:c:C:d:D:f:F:ehi:K:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B: arg
> +    while getopts a:c:C:d:D:f:F:ehi:K:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B:X: arg
>      do  case $arg in
>          a)  EMAIL_TO=$OPTARG
>              ALT_EMAIL_OUT=1;;
> @@ -424,6 +425,7 @@ main()
>              INSTANCES="-x $OPTARG";;
>          b) DEVICE=$OPTARG;;
>          B) DEVICE_FS_TYPE=$OPTARG;;
> +        X) XFS_DEVICE=$OPTARG;;
>          \?) usage;;
>          esac
>      done
> @@ -679,6 +681,24 @@ main()
>      }
>      }
> 
> +    if [ -n "$XFS_DEVICE" ]; then
> +        sed -i "s|XFS_DEVICE|$XFS_DEVICE|"  ${TMP}/alltests
> +        RC=$?
> +    else
> +        create_xfs_block
> +        if [ $? -eq 0 ]; then
> +            sed -i "s|XFS_DEVICE|$XFS_DEVICE|"  ${TMP}/alltests
> +            RC=$?
> +        else
> +            echo "No xfs-format block device was specified on commandline."
> +            echo "Block device could not be created using loopback device"
> +            echo "Tests which require xfs block device are disabled."
> +            echo "You can specify it with option -X"
> +            sed -i "/XFS_DEVICE/d"  ${TMP}/alltests
> +            RC=$?
> +        fi
> +    fi
> +
>      if [ -n "$DEVICE" ]; then
>          sed -i "s|DEVICE|$DEVICE|"  ${TMP}/alltests
>          RC=$?
> @@ -1019,9 +1039,43 @@ create_block()
>      fi
>  }
> 
> +create_xfs_block()
> +{
> +    #create a block device with xfs filesystem.
> +    dd if=/dev/zero of=${TMP}/xfstest.img bs=1kB count=20480
> +    if [ $? -ne 0 ]; then
> +        echo "Failed to create loopback device image, please check disk space and re-run"
> +        return 1
> +    else
> +        ##search for an unused loop dev
> +        LOOP_DEV_XFS=$(losetup -f)
> +        if [ $? -ne 0 ]; then
> +            echo "no unused loop device is found"
> +            return 1
> +        else
> +            ##attach the created file to loop dev.
> +            losetup $LOOP_DEV_XFS ${TMP}/xfstest.img
> +            if [ $? -ne 0 ]; then
> +                echo "losetup failed to create block device"
> +                return 1
> +            else
> +                mkfs.xfs $LOOP_DEV_XFS
> +                if [ $? -ne 0 ]; then
> +                    echo "creating an xfs block device failed."
> +                    return 1
> +                fi
> +
> +                XFS_DEVICE=$LOOP_DEV_XFS
> +                return 0
> +            fi
> +        fi
> +    fi
> +}


Now this is getting a bit out of hand.

What about we change the tests (we have) to take only device to work
with and let each test prepare the filesystem it needs? This will
simplify the runltp script to only prepare loop device.

If we agree on that I can write the tst_mkfs() function and convert
current usages.

Or has anbody better idea?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  parent reply	other threads:[~2013-07-17 12:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17  5:10 [LTP] [PATCH 1/2] Add support for xfs quota tests DAN LI
2013-07-17  5:17 ` [LTP] [PATCH 2/2] quotactl/quotactl02.c: create a case to test basic flags of quotactl(2) DAN LI
2013-07-17 12:22   ` chrubis
2013-07-17 12:05 ` chrubis [this message]
     [not found]   ` <51FA290E.1040804@cn.fujitsu.com>
2013-08-01 11:41     ` [LTP] [PATCH 1/2] Add support for xfs quota tests chrubis
2013-08-12 11:53     ` chrubis
     [not found]       ` <52158F02.9000105@cn.fujitsu.com>
2013-08-22  9:22         ` chrubis

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=20130717120522.GB25145@rei \
    --to=chrubis@suse.cz \
    --cc=li.dan@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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