blob: 273c157d41e78bdab0c8cc90bb06379886478363 [file] [log] [blame]
lmrd19e5002009-06-08 17:39:53 +00001import os, shutil, glob, logging
mbligh2bbfa962009-03-17 17:55:32 +00002from autotest_lib.client.bin import test, utils
3from autotest_lib.client.common_lib import error
4
Eric Lice1b0622011-05-16 14:28:45 -07005
6class ctcs(test.test):
mbligh2bbfa962009-03-17 17:55:32 +00007 """
Eric Lice1b0622011-05-16 14:28:45 -07008 This autotest module runs CTCS (Cerberus Test Control System), that is being
9 maintained on a new location, since both CTCS and CTCS2 on sourceforge
10 were abandoned.
mbligh2bbfa962009-03-17 17:55:32 +000011
lmr519bc0d2009-09-29 15:24:57 +000012 The original test suite (Cerberus Test Control System) was developed for
13 the now extinct VA Linux's manufacturing system it has several hardware
14 and software stress tests that can be run in parallel. It does have a
15 control file system that allows testers to specify the sorts of tests that
16 they want to see executed. It's an excelent stress test for hardware and
17 kernel.
18
19 @author Manas Kumar Nayak (maknayak@in.ibm.com) (original code)
20 @author Lucas Meneghel Rodrigues (lucasmr@br.ibm.com) (rewrite - ctcs)
21 @author Cao, Chen (kcao@redhat.com) (use ctcs2 and port it to 64)
Eric Lice1b0622011-05-16 14:28:45 -070022 @author Lucas Meneghel Rodrigues (lmr@redhat.com) (use ctcs new source repo)
23 @see: https://github.com/autotest/ctcs
mbligh2bbfa962009-03-17 17:55:32 +000024 """
Eric Lice1b0622011-05-16 14:28:45 -070025 version = 3
mbligh2bbfa962009-03-17 17:55:32 +000026
mbligh2bbfa962009-03-17 17:55:32 +000027 def initialize(self):
28 """
29 Sets the overall failure counter for the test.
30 """
31 self.nfail = 0
32
33
Eric Lice1b0622011-05-16 14:28:45 -070034 def setup(self, tarball='ctcs.tar.bz2', length='4h', tc_opt='-k',
mbligh2bbfa962009-03-17 17:55:32 +000035 tcf_contents=None):
36 """
37 Builds the test suite, and sets up the control file that is going to
Eric Lice1b0622011-05-16 14:28:45 -070038 be processed by the ctcs engine.
39 @param tarball: CTCS tarball
lmr519bc0d2009-09-29 15:24:57 +000040 @param length: The amount of time we'll run the test suite
41 @param tcf_contents: If the user wants to specify the contents of
Eric Lice1b0622011-05-16 14:28:45 -070042 the CTCS control file, he could do so trough this parameter.
43 If this parameter is provided, length is ignored.
mbligh2bbfa962009-03-17 17:55:32 +000044 """
Eric Lice1b0622011-05-16 14:28:45 -070045 ctcs_tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
46 utils.extract_tarball_to_dir(ctcs_tarball, self.srcdir)
mbligh2bbfa962009-03-17 17:55:32 +000047
48 os.chdir(self.srcdir)
Eric Li6f27d4f2010-09-29 10:55:17 -070049 utils.make()
mbligh2bbfa962009-03-17 17:55:32 +000050
51 # Here we define the cerberus suite control file that will be used.
52 # It will be kept on the debug directory for further analysis.
53 self.tcf_path = os.path.join(self.debugdir, 'autotest.tcf')
54
55 if not tcf_contents:
Eric Lice1b0622011-05-16 14:28:45 -070056 logging.info('Generating CTCS control file')
mbligh2bbfa962009-03-17 17:55:32 +000057 # Note about the control file generation command - we are creating
58 # a control file with the default tests, except for the kernel
59 # compilation test (flag -k).
Eric Lice1b0622011-05-16 14:28:45 -070060 g_cmd = ('./newburn-generator %s %s> %s' %
61 (tc_opt, length, self.tcf_path))
mbligh2bbfa962009-03-17 17:55:32 +000062 utils.system(g_cmd)
63 else:
lmrd19e5002009-06-08 17:39:53 +000064 logging.debug('TCF file contents supplied, ignoring test length'
65 ' altogether')
mbligh2bbfa962009-03-17 17:55:32 +000066 tcf = open(self.tcf_path, 'w')
67 tcf.write(tcf_contents)
68
Eric Lice1b0622011-05-16 14:28:45 -070069 logging.debug('Contents of the control file that will be passed to '
70 'CTCS:')
mbligh2bbfa962009-03-17 17:55:32 +000071 tcf = open(self.tcf_path, 'r')
72 buf = tcf.read()
lmrd19e5002009-06-08 17:39:53 +000073 logging.debug(buf)
mbligh2bbfa962009-03-17 17:55:32 +000074
75
76 def run_once(self):
77 """
78 Runs the test, with the appropriate control file.
79 """
80 os.chdir(self.srcdir)
81 try:
82 utils.system('./run %s' % self.tcf_path)
83 except:
84 self.nfail += 1
mbligh2bbfa962009-03-17 17:55:32 +000085 log_base_path = os.path.join(self.srcdir, 'log')
mbligh1ef218d2009-08-03 16:57:56 +000086 log_dir = glob.glob(os.path.join(log_base_path,
mbligh2bbfa962009-03-17 17:55:32 +000087 'autotest.tcf.log.*'))[0]
lmrd19e5002009-06-08 17:39:53 +000088 logging.debug('Copying %s log directory to results dir', log_dir)
mbligh2bbfa962009-03-17 17:55:32 +000089 dst = os.path.join(self.resultsdir, os.path.basename(log_dir))
90 shutil.move(log_dir, dst)
91
92
93 def cleanup(self):
94 """
95 Cleans up source directory and raises on failure.
96 """
97 if os.path.isdir(self.srcdir):
98 shutil.rmtree(self.srcdir)
99 if self.nfail != 0:
Eric Lice1b0622011-05-16 14:28:45 -0700100 raise error.TestFail('CTCS execution failed')