• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import os, shutil, glob, logging
2from autotest_lib.client.bin import test, utils
3from autotest_lib.client.common_lib import error
4
5
6class connectathon(test.test):
7    """
8    Connectathon test is an nfs testsuite which can run on
9    both BSD and System V based systems. The tests.init file
10    has to be modified based on the OS in which this test is run.
11
12    The tar file in this dir has an init file which works for Linux
13    platform.
14
15    @see www.connectathon.org
16    @author Poornima.Nayak (Poornima.Nayak@in.ibm.com)(original code)
17    """
18    version = 1
19    def initialize(self):
20        """
21        Sets the overall failure counter for the test.
22        """
23        self.nfail = 0
24
25
26    def setup(self, tarball='connectathon.tar.bz2'):
27        connectathon_tarball = utils.unmap_url(self.bindir, tarball,
28                                               self.tmpdir)
29        utils.extract_tarball_to_dir(connectathon_tarball, self.srcdir)
30
31        os.chdir(self.srcdir)
32        utils.system('make clean')
33        utils.system('make')
34
35
36    def run_once(self, testdir=None, args='', cthon_iterations=1):
37        """
38        Runs the test, with the appropriate control file.
39        """
40        os.chdir(self.srcdir)
41
42        if testdir is None:
43            testdir = self.tmpdir
44
45        self.results_path = os.path.join(self.resultsdir,
46                                         'raw_output_%s' % self.iteration)
47
48        try:
49            if not args:
50                # run basic test
51                args = "-b -t"
52
53            self.results = utils.system_output('./runtests -N %s %s %s' %
54                                              (cthon_iterations, args, testdir))
55            utils.open_write_close(self.results_path, self.results)
56
57        except error.CmdError, e:
58            self.nfail += 1
59            logging.error("Test failed: %s", e)
60
61
62    def postprocess(self):
63        """
64        Raises on failure.
65        """
66        if self.nfail != 0:
67            raise error.TestFail('Connectathon test suite failed.')
68