On Tue, Jul 19, 2011 at 8:10 AM, Cleber Rosa <[email protected]> wrote:

> xfstests was originally developed to test SGI's XFS filesystem.
>
> Signed-off-by: Cleber Rosa <[email protected]>
> ---
>  client/tests/xfstests/README      |   33 ++++++++++++++
>  client/tests/xfstests/control     |   62 +++++++++++++++++++++++++
>  client/tests/xfstests/xfstests.py |   89
> +++++++++++++++++++++++++++++++++++++
>  3 files changed, 184 insertions(+), 0 deletions(-)
>  create mode 100644 client/tests/xfstests/README
>  create mode 100644 client/tests/xfstests/control
>  create mode 100644 client/tests/xfstests/xfstests.py
>
> diff --git a/client/tests/xfstests/README b/client/tests/xfstests/README
> new file mode 100644
> index 0000000..da49bcf
> --- /dev/null
> +++ b/client/tests/xfstests/README
> @@ -0,0 +1,33 @@
> +xfstests in autotest
> +====================
> +
> +This is simple wrapper for running xfstests inside autotest. The steps to
> get
> +started are really simple:
> +
> +1) Edit the configuration variables on the control file.
> +
> +1.1) The variables 'TEST_DEV' and 'TEST_DIR' are mandatory and should be
> set to
> +     a block device path and mount point path, respectively, that will be
> used
> +     *exclusively* for xfstests.
> +
> +     DO NOT USE A BLOCK DEVICE WITH IMPORTANT DATA!!!
> +
> +1.2) Set the range of tests you want to run setting the TEST_RANGE
> variable.
> +     Please notice that python's range() function may not work as you
> expect,
> +     that is, if you want a range from 0-255, use: range(0, 256)
> +
> +2) Run the tests (assuming autotest installed in /usr/local/autotest):
> +
> +   # cd /usr/local/autotest/client/tests/xfstests
> +   # ../../bin/autotest control
> +
> +3) Check the HTML report at
> /usr/local/autotest/client/results/default/job_report.html
> +
> +General notes
> +=============
> +
> +* As autotest includes a setup phase for client tests, this step is
> encapsulated in
> +a dummy xfstests number 000.
> +
> +* XFS utilities, system libraries and header files are checked early,
> before trying to
> +build xfstests. Make sure you resolve those dependencies.
> diff --git a/client/tests/xfstests/control b/client/tests/xfstests/control
> new file mode 100644
> index 0000000..4befa5e
> --- /dev/null
> +++ b/client/tests/xfstests/control
> @@ -0,0 +1,62 @@
> +TIME="SHORT"
> +AUTHOR = "Cleber Rosa <[email protected]>"
> +DOC = """
> +xfstests is a filesystem QA suite, originally developed to test SGI's XFS
> +filesystem.
> +"""
> +NAME = 'control'
>

this is wrong.  The NAME in the control file needs to be a unique name for
this test across all tests in autotest as it gets imported into the database
on an autotest server and is the name the test is referred to in the gui and
cli and generate_control_file rpc.

I suggest something like:

NAME = 'xfs filesystem test suite'.


> +TEST_CLASS = 'kernel'
> +TEST_CATEGORY = 'Functional'
> +TEST_TYPE = 'client'
> +
> +#
> +# Job configuration, instead of editing xfstests config files, set them
> +# right here as environment variables
> +#
> +
> +# TEST_DEV: "device containing TEST PARTITION"
> +os.environ['TEST_DEV'] = '/dev/null'
> +
> +# TEST_DIR: "mount point of TEST PARTITION"
> +os.environ['TEST_DIR'] = '/mnt/null'
> +
> +# SCRATCH_DEV "device containing SCRATCH PARTITION"
> +# os.environ['SCRATCH_DEV'] = ''
> +
> +# SCRATCH_MNT "mount point for SCRATCH PARTITION"
> +# os.environ['SCRATCH_MNT'] = ''
> +
> +# TAPE_DEV "tape device for testing xfsdump"
> +# os.environ['TAPE_DEV'] = ''
> +
> +# RMT_TAPE_DEV "remote tape device for testing xfsdump"
> +# os.environ['RMT_TAPE_DEV'] = ''
> +
> +# RMT_IRIXTAPE_DEV "remote IRIX tape device for testing xfsdump"
> +# os.environ['RMT_IRIXTAPE_DEV'] = ''
> +
> +# SCRATCH_LOGDEV "device for scratch-fs external log"
> +# os.environ['SCRATCH_LOGDEV'] = ''
> +
> +# SCRATCH_RTDEV "device for scratch-fs realtime data"
> +# os.environ['SCRATCH_RTDEV'] = ''
> +
> +# TEST_LOGDEV "device for test-fs external log"
> +# os.environ['TEST_LOGDEV'] = ''
> +
> +# TEST_RTDEV "device for test-fs realtime data"
> +# os.environ['TEST_RTDEV'] = ''
> +
> +# Whether UDF tests are disable
> +# os.environ['DISABLE_UDF_TEST'] = '1'
> +
> +#
> +# Adapt to the list of tests you want to run
> +#
> +TEST_RANGE = ['%03i' % t for t in range(0, 256)]
> +
> +#
> +# Finally, run the tests
> +#
> +for test in TEST_RANGE:
> +    result = job.run_test_detail('xfstests', test_number=test, tag=test)
> diff --git a/client/tests/xfstests/xfstests.py
> b/client/tests/xfstests/xfstests.py
> new file mode 100644
> index 0000000..1dea294
> --- /dev/null
> +++ b/client/tests/xfstests/xfstests.py
> @@ -0,0 +1,89 @@
> +import os, re, glob, logging
> +from autotest_lib.client.common_lib import error
> +from autotest_lib.client.bin import test, utils, os_dep
> +
> +class xfstests(test.test):
> +
> +    version = 1
> +
> +    PASSED_RE = re.compile(r'Passed all \d+ tests')
> +    FAILED_RE = re.compile(r'Failed \d+ of \d+ tests')
> +    NA_RE = re.compile(r'Passed all 0 tests')
> +    NA_DETAIL_RE = re.compile(r'(\d{3})\s*(\[not run\])\s*(.*)')
> +
> +
> +    def _get_available_tests(self):
> +        tests = glob.glob('???.out')
> +        tests_list = [t[:-4] for t in tests if os.path.exists(t[:-4])]
> +        tests_list.sort()
> +        return tests_list
> +
> +
> +    def _run_sub_test(self, test):
> +        os.chdir(self.srcdir)
> +        output = utils.system_output('./check %s' % test,
> +                                     ignore_status=True,
> +                                     retain_output=True)
> +        lines = output.split('\n')
> +        result_line = lines[-1]
> +
> +        if self.NA_RE.match(result_line):
> +            detail_line = lines[-3]
> +            match = self.NA_DETAIL_RE.match(detail_line)
> +            if match is not None:
> +                error_msg = match.groups()[2]
> +            else:
> +                error_msg = 'Test dependency failed, test not run'
> +            raise error.TestNAError(error_msg)
> +
> +        elif self.FAILED_RE.match(result_line):
> +            raise error.TestError('Test error, check debug logs for
> complete '
> +                                  'test output')
> +
> +        elif self.PASSED_RE.match(result_line):
> +            return
> +
> +        else:
> +            raise error.TestError('Could not assert test success or
> failure, '
> +                                  'assuming failure. Please check debug
> logs')
> +
> +
> +    def setup(self, tarball = 'xfstests.tar.bz2'):
> +        #
> +        # Anticipate failures due to missing devel tools, libraries,
> headers
> +        # and xfs commands
> +        #
> +        os_dep.command('autoconf')
> +        os_dep.command('autoheader')
> +        os_dep.command('libtool')
> +        os_dep.library('libuuid.so.1')
> +        os_dep.header('xfs/xfs.h')
> +        os_dep.header('attr/xattr.h')
> +        os_dep.header('sys/acl.h')
> +        os_dep.command('mkfs.xfs')
> +        os_dep.command('xfs_db')
> +        os_dep.command('xfs_bmap')
> +        os_dep.command('xfsdump')
> +
> +        self.job.require_gcc()
> +
> +        tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
> +        utils.extract_tarball_to_dir(tarball, self.srcdir)
> +        os.chdir(self.srcdir)
> +        utils.make()
> +
> +        logging.debug("Available tests in srcdir: %s" %
> +                      ", ".join(self._get_available_tests()))
> +
> +
> +    def run_once(self, test_number):
> +        os.chdir(self.srcdir)
> +        if test_number == '000':
> +            logging.debug('Dummy test to setup xfstests')
> +            return
> +
> +        if test_number not in self._get_available_tests():
> +            raise error.TestError('test file %s not found' % test_number)
> +
> +        logging.debug("Running test: %s" % test_number)
> +        self._run_sub_test(test_number)
> --
> 1.7.4.4
>
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to