mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 1 | """The main job wrapper |
mbligh | a250805 | 2006-05-28 21:29:53 +0000 | [diff] [blame] | 2 | |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 3 | This is the core infrastructure. |
| 4 | """ |
| 5 | |
| 6 | __author__ = """Copyright Andy Whitcroft, Martin J. Bligh 2006""" |
mbligh | a250805 | 2006-05-28 21:29:53 +0000 | [diff] [blame] | 7 | |
mbligh | 8f243ec | 2006-10-10 05:55:49 +0000 | [diff] [blame] | 8 | # standard stuff |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 9 | import os, sys, re, pickle, shutil, time, traceback, types, copy |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 10 | |
mbligh | 8f243ec | 2006-10-10 05:55:49 +0000 | [diff] [blame] | 11 | # autotest stuff |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 12 | from autotest_lib.client.bin import autotest_utils |
| 13 | from autotest_lib.client.common_lib import error, barrier, logging |
| 14 | |
| 15 | import parallel, kernel, xen, test, profilers, filesystem, fd_stack, boottool |
| 16 | import harness, config, sysinfo, cpuset |
| 17 | |
mbligh | f4c3532 | 2006-03-13 01:01:10 +0000 | [diff] [blame] | 18 | |
mbligh | 12a04cb | 2008-04-25 16:07:20 +0000 | [diff] [blame] | 19 | |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 20 | JOB_PREAMBLE = """ |
| 21 | from common.error import * |
| 22 | from autotest_utils import * |
| 23 | """ |
| 24 | |
| 25 | |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 26 | class StepError(error.AutotestError): |
mbligh | 12a04cb | 2008-04-25 16:07:20 +0000 | [diff] [blame] | 27 | pass |
| 28 | |
| 29 | |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 30 | class base_job: |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 31 | """The actual job against which we do everything. |
| 32 | |
| 33 | Properties: |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 34 | autodir |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 35 | The top level autotest directory (/usr/local/autotest). |
| 36 | Comes from os.environ['AUTODIR']. |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 37 | bindir |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 38 | <autodir>/bin/ |
mbligh | d5a3883 | 2008-01-25 18:15:39 +0000 | [diff] [blame] | 39 | libdir |
| 40 | <autodir>/lib/ |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 41 | testdir |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 42 | <autodir>/tests/ |
mbligh | 84bafdb | 2008-01-26 19:43:34 +0000 | [diff] [blame] | 43 | site_testdir |
| 44 | <autodir>/site_tests/ |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 45 | profdir |
| 46 | <autodir>/profilers/ |
| 47 | tmpdir |
| 48 | <autodir>/tmp/ |
| 49 | resultdir |
| 50 | <autodir>/results/<jobtag> |
| 51 | stdout |
| 52 | fd_stack object for stdout |
| 53 | stderr |
| 54 | fd_stack object for stderr |
| 55 | profilers |
| 56 | the profilers object for this job |
apw | 504a7dd | 2006-10-12 17:18:37 +0000 | [diff] [blame] | 57 | harness |
| 58 | the server harness object for this job |
apw | 059e1b1 | 2006-10-12 17:18:26 +0000 | [diff] [blame] | 59 | config |
| 60 | the job configuration for this job |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 61 | """ |
| 62 | |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 63 | DEFAULT_LOG_FILENAME = "status" |
| 64 | |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 65 | def __init__(self, control, jobtag, cont, harness_type=None, |
| 66 | use_external_logging = False): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 67 | """ |
| 68 | control |
| 69 | The control file (pathname of) |
| 70 | jobtag |
| 71 | The job tag string (eg "default") |
apw | 96da1a4 | 2006-11-02 00:23:18 +0000 | [diff] [blame] | 72 | cont |
| 73 | If this is the continuation of this job |
apw | e68a713 | 2006-12-01 11:21:37 +0000 | [diff] [blame] | 74 | harness_type |
| 75 | An alternative server harness |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 76 | """ |
mbligh | f4c3532 | 2006-03-13 01:01:10 +0000 | [diff] [blame] | 77 | self.autodir = os.environ['AUTODIR'] |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 78 | self.bindir = os.path.join(self.autodir, 'bin') |
mbligh | d5a3883 | 2008-01-25 18:15:39 +0000 | [diff] [blame] | 79 | self.libdir = os.path.join(self.autodir, 'lib') |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 80 | self.testdir = os.path.join(self.autodir, 'tests') |
mbligh | 84bafdb | 2008-01-26 19:43:34 +0000 | [diff] [blame] | 81 | self.site_testdir = os.path.join(self.autodir, 'site_tests') |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 82 | self.profdir = os.path.join(self.autodir, 'profilers') |
| 83 | self.tmpdir = os.path.join(self.autodir, 'tmp') |
| 84 | self.resultdir = os.path.join(self.autodir, 'results', jobtag) |
mbligh | 0fb8397 | 2008-01-10 16:30:02 +0000 | [diff] [blame] | 85 | self.sysinfodir = os.path.join(self.resultdir, 'sysinfo') |
mbligh | 8d83cdc | 2007-12-03 18:09:18 +0000 | [diff] [blame] | 86 | self.control = os.path.abspath(control) |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 87 | self.state_file = self.control + '.state' |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 88 | self.__load_state() |
mbligh | a250805 | 2006-05-28 21:29:53 +0000 | [diff] [blame] | 89 | |
apw | 96da1a4 | 2006-11-02 00:23:18 +0000 | [diff] [blame] | 90 | if not cont: |
mbligh | c1cbc99 | 2008-05-27 20:01:45 +0000 | [diff] [blame^] | 91 | """ |
| 92 | Don't cleanup the tmp dir (which contains the lockfile) |
| 93 | in the constructor, this would be a problem for multiple |
| 94 | jobs starting at the same time on the same client. Instead |
| 95 | do the delete at the server side. We simply create the tmp |
| 96 | directory here if it does not already exist. |
| 97 | """ |
| 98 | if not os.path.exists(self.tmpdir): |
| 99 | os.mkdir(self.tmpdir) |
apw | 96da1a4 | 2006-11-02 00:23:18 +0000 | [diff] [blame] | 100 | |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 101 | results = os.path.join(self.autodir, 'results') |
| 102 | if not os.path.exists(results): |
| 103 | os.mkdir(results) |
mbligh | fbfb77d | 2007-02-15 18:54:03 +0000 | [diff] [blame] | 104 | |
apw | f3d2862 | 2007-09-25 16:49:17 +0000 | [diff] [blame] | 105 | download = os.path.join(self.testdir, 'download') |
mbligh | c1cbc99 | 2008-05-27 20:01:45 +0000 | [diff] [blame^] | 106 | if not os.path.exists(download): |
| 107 | os.mkdir(download) |
| 108 | |
apw | 96da1a4 | 2006-11-02 00:23:18 +0000 | [diff] [blame] | 109 | if os.path.exists(self.resultdir): |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 110 | autotest_utils.system('rm -rf ' |
| 111 | + self.resultdir) |
apw | 96da1a4 | 2006-11-02 00:23:18 +0000 | [diff] [blame] | 112 | os.mkdir(self.resultdir) |
mbligh | 0fb8397 | 2008-01-10 16:30:02 +0000 | [diff] [blame] | 113 | os.mkdir(self.sysinfodir) |
apw | 96da1a4 | 2006-11-02 00:23:18 +0000 | [diff] [blame] | 114 | |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 115 | os.mkdir(os.path.join(self.resultdir, 'debug')) |
| 116 | os.mkdir(os.path.join(self.resultdir, 'analysis')) |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 117 | |
mbligh | 8d83cdc | 2007-12-03 18:09:18 +0000 | [diff] [blame] | 118 | shutil.copyfile(self.control, |
| 119 | os.path.join(self.resultdir, 'control')) |
mbligh | f4ca14f | 2008-03-03 16:03:05 +0000 | [diff] [blame] | 120 | |
mbligh | 4b08966 | 2006-06-14 22:34:58 +0000 | [diff] [blame] | 121 | |
apw | ecf41b7 | 2006-03-31 14:00:55 +0000 | [diff] [blame] | 122 | self.control = control |
mbligh | 2711360 | 2007-10-31 21:07:51 +0000 | [diff] [blame] | 123 | self.jobtag = jobtag |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 124 | self.log_filename = self.DEFAULT_LOG_FILENAME |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 125 | self.container = None |
mbligh | f4c3532 | 2006-03-13 01:01:10 +0000 | [diff] [blame] | 126 | |
mbligh | 56f1fbb | 2006-10-01 15:10:56 +0000 | [diff] [blame] | 127 | self.stdout = fd_stack.fd_stack(1, sys.stdout) |
| 128 | self.stderr = fd_stack.fd_stack(2, sys.stderr) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 129 | |
| 130 | self._init_group_level() |
mbligh | f4c3532 | 2006-03-13 01:01:10 +0000 | [diff] [blame] | 131 | |
apw | 059e1b1 | 2006-10-12 17:18:26 +0000 | [diff] [blame] | 132 | self.config = config.config(self) |
| 133 | |
apw | d27e55f | 2006-12-01 11:22:08 +0000 | [diff] [blame] | 134 | self.harness = harness.select(harness_type, self) |
| 135 | |
mbligh | a35553b | 2006-04-23 15:52:25 +0000 | [diff] [blame] | 136 | self.profilers = profilers.profilers(self) |
mbligh | 7290556 | 2006-05-25 01:30:49 +0000 | [diff] [blame] | 137 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 138 | try: |
apw | 90154af | 2006-12-01 11:23:36 +0000 | [diff] [blame] | 139 | tool = self.config_get('boottool.executable') |
| 140 | self.bootloader = boottool.boottool(tool) |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 141 | except: |
| 142 | pass |
| 143 | |
mbligh | 0fb8397 | 2008-01-10 16:30:02 +0000 | [diff] [blame] | 144 | sysinfo.log_per_reboot_data(self.sysinfodir) |
mbligh | 3a6d6ca | 2006-04-23 15:50:24 +0000 | [diff] [blame] | 145 | |
mbligh | 3027030 | 2007-11-05 20:33:52 +0000 | [diff] [blame] | 146 | if not cont: |
mbligh | c343016 | 2007-11-14 23:57:19 +0000 | [diff] [blame] | 147 | self.record('START', None, None) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 148 | self._increment_group_level() |
apw | 357f50f | 2006-12-01 11:22:39 +0000 | [diff] [blame] | 149 | |
apw | f91efaf | 2007-11-24 17:32:13 +0000 | [diff] [blame] | 150 | self.harness.run_start() |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 151 | |
| 152 | if use_external_logging: |
| 153 | self.enable_external_logging() |
apw | f91efaf | 2007-11-24 17:32:13 +0000 | [diff] [blame] | 154 | |
jadmanski | 8415f96 | 2008-05-06 20:38:53 +0000 | [diff] [blame] | 155 | # load the max disk usage rate - default to no monitoring |
| 156 | self.max_disk_usage_rate = self.get_state('__monitor_disk', |
| 157 | default=0.0) |
| 158 | |
| 159 | |
| 160 | def monitor_disk_usage(self, max_rate): |
| 161 | """\ |
| 162 | Signal that the job should monitor disk space usage on / |
| 163 | and generate a warning if a test uses up disk space at a |
| 164 | rate exceeding 'max_rate'. |
| 165 | |
| 166 | Parameters: |
| 167 | max_rate - the maximium allowed rate of disk consumption |
| 168 | during a test, in MB/hour, or 0 to indicate |
| 169 | no limit. |
| 170 | """ |
| 171 | self.set_state('__monitor_disk', max_rate) |
| 172 | self.max_disk_usage_rate = max_rate |
| 173 | |
mbligh | 0692e47 | 2007-08-30 16:07:53 +0000 | [diff] [blame] | 174 | |
| 175 | def relative_path(self, path): |
| 176 | """\ |
| 177 | Return a patch relative to the job results directory |
| 178 | """ |
mbligh | 1c250ca | 2007-08-30 16:31:38 +0000 | [diff] [blame] | 179 | head = len(self.resultdir) + 1 # remove the / inbetween |
| 180 | return path[head:] |
mbligh | 0692e47 | 2007-08-30 16:07:53 +0000 | [diff] [blame] | 181 | |
| 182 | |
mbligh | 362ab3d | 2007-08-30 11:24:04 +0000 | [diff] [blame] | 183 | def control_get(self): |
| 184 | return self.control |
| 185 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 186 | |
mbligh | 8d83cdc | 2007-12-03 18:09:18 +0000 | [diff] [blame] | 187 | def control_set(self, control): |
| 188 | self.control = os.path.abspath(control) |
| 189 | |
| 190 | |
apw | de1503a | 2006-10-10 08:34:21 +0000 | [diff] [blame] | 191 | def harness_select(self, which): |
| 192 | self.harness = harness.select(which, self) |
| 193 | |
| 194 | |
apw | 059e1b1 | 2006-10-12 17:18:26 +0000 | [diff] [blame] | 195 | def config_set(self, name, value): |
| 196 | self.config.set(name, value) |
| 197 | |
| 198 | |
| 199 | def config_get(self, name): |
| 200 | return self.config.get(name) |
| 201 | |
mbligh | 8baa2ea | 2006-12-17 23:01:24 +0000 | [diff] [blame] | 202 | def setup_dirs(self, results_dir, tmp_dir): |
mbligh | 1e8858e | 2006-11-24 22:18:35 +0000 | [diff] [blame] | 203 | if not tmp_dir: |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 204 | tmp_dir = os.path.join(self.tmpdir, 'build') |
mbligh | 1e8858e | 2006-11-24 22:18:35 +0000 | [diff] [blame] | 205 | if not os.path.exists(tmp_dir): |
| 206 | os.mkdir(tmp_dir) |
| 207 | if not os.path.isdir(tmp_dir): |
mbligh | 642b03e | 2008-01-14 16:53:15 +0000 | [diff] [blame] | 208 | e_msg = "Temp dir (%s) is not a dir - args backwards?" % self.tmpdir |
| 209 | raise ValueError(e_msg) |
mbligh | 1e8858e | 2006-11-24 22:18:35 +0000 | [diff] [blame] | 210 | |
| 211 | # We label the first build "build" and then subsequent ones |
| 212 | # as "build.2", "build.3", etc. Whilst this is a little bit |
| 213 | # inconsistent, 99.9% of jobs will only have one build |
| 214 | # (that's not done as kernbench, sparse, or buildtest), |
| 215 | # so it works out much cleaner. One of life's comprimises. |
| 216 | if not results_dir: |
| 217 | results_dir = os.path.join(self.resultdir, 'build') |
| 218 | i = 2 |
| 219 | while os.path.exists(results_dir): |
| 220 | results_dir = os.path.join(self.resultdir, 'build.%d' % i) |
mbligh | d9223fc | 2006-11-26 17:19:54 +0000 | [diff] [blame] | 221 | i += 1 |
mbligh | 1e8858e | 2006-11-24 22:18:35 +0000 | [diff] [blame] | 222 | if not os.path.exists(results_dir): |
| 223 | os.mkdir(results_dir) |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 224 | |
mbligh | 8baa2ea | 2006-12-17 23:01:24 +0000 | [diff] [blame] | 225 | return (results_dir, tmp_dir) |
| 226 | |
| 227 | |
| 228 | def xen(self, base_tree, results_dir = '', tmp_dir = '', leave = False, \ |
| 229 | kjob = None ): |
| 230 | """Summon a xen object""" |
| 231 | (results_dir, tmp_dir) = self.setup_dirs(results_dir, tmp_dir) |
| 232 | build_dir = 'xen' |
| 233 | return xen.xen(self, base_tree, results_dir, tmp_dir, build_dir, leave, kjob) |
| 234 | |
| 235 | |
| 236 | def kernel(self, base_tree, results_dir = '', tmp_dir = '', leave = False): |
| 237 | """Summon a kernel object""" |
mbligh | 669caa1 | 2007-11-05 18:32:13 +0000 | [diff] [blame] | 238 | (results_dir, tmp_dir) = self.setup_dirs(results_dir, tmp_dir) |
mbligh | 8baa2ea | 2006-12-17 23:01:24 +0000 | [diff] [blame] | 239 | build_dir = 'linux' |
mbligh | 6ee7ee0 | 2007-11-13 23:49:05 +0000 | [diff] [blame] | 240 | return kernel.auto_kernel(self, base_tree, results_dir, |
| 241 | tmp_dir, build_dir, leave) |
mbligh | f4c3532 | 2006-03-13 01:01:10 +0000 | [diff] [blame] | 242 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 243 | |
mbligh | 6b504ff | 2007-12-12 21:03:49 +0000 | [diff] [blame] | 244 | def barrier(self, *args, **kwds): |
mbligh | fadca20 | 2006-09-23 04:40:01 +0000 | [diff] [blame] | 245 | """Create a barrier object""" |
mbligh | 6b504ff | 2007-12-12 21:03:49 +0000 | [diff] [blame] | 246 | return barrier.barrier(*args, **kwds) |
mbligh | fadca20 | 2006-09-23 04:40:01 +0000 | [diff] [blame] | 247 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 248 | |
mbligh | 4b08966 | 2006-06-14 22:34:58 +0000 | [diff] [blame] | 249 | def setup_dep(self, deps): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 250 | """Set up the dependencies for this test. |
| 251 | |
| 252 | deps is a list of libraries required for this test. |
| 253 | """ |
mbligh | 4b08966 | 2006-06-14 22:34:58 +0000 | [diff] [blame] | 254 | for dep in deps: |
| 255 | try: |
apw | 870988b | 2007-09-25 16:50:53 +0000 | [diff] [blame] | 256 | os.chdir(os.path.join(self.autodir, 'deps', dep)) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 257 | autotest_utils.system('./' + dep + '.py') |
mbligh | 4b08966 | 2006-06-14 22:34:58 +0000 | [diff] [blame] | 258 | except: |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 259 | err = "setting up dependency " + dep + "\n" |
| 260 | raise error.UnhandledError(err) |
mbligh | 4b08966 | 2006-06-14 22:34:58 +0000 | [diff] [blame] | 261 | |
| 262 | |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 263 | def __runtest(self, url, tag, args, dargs): |
| 264 | try: |
mbligh | 53c4150 | 2007-10-23 20:45:04 +0000 | [diff] [blame] | 265 | l = lambda : test.runtest(self, url, tag, args, dargs) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 266 | pid = parallel.fork_start(self.resultdir, l) |
| 267 | parallel.fork_waitfor(self.resultdir, pid) |
| 268 | except error.AutotestError: |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 269 | raise |
| 270 | except: |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 271 | raise error.UnhandledError('running test ' + \ |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 272 | self.__class__.__name__ + "\n") |
apw | f1a8116 | 2006-04-25 10:10:29 +0000 | [diff] [blame] | 273 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 274 | |
mbligh | d016ecc | 2006-11-25 21:41:07 +0000 | [diff] [blame] | 275 | def run_test(self, url, *args, **dargs): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 276 | """Summon a test object and run it. |
| 277 | |
| 278 | tag |
| 279 | tag to add to testname |
mbligh | 12a7df7 | 2006-10-06 03:54:33 +0000 | [diff] [blame] | 280 | url |
| 281 | url of the test to run |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 282 | """ |
mbligh | 12a7df7 | 2006-10-06 03:54:33 +0000 | [diff] [blame] | 283 | |
mbligh | d016ecc | 2006-11-25 21:41:07 +0000 | [diff] [blame] | 284 | if not url: |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 285 | raise TypeError("Test name is invalid. " |
| 286 | "Switched arguments?") |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 287 | (group, testname) = test.testname(url) |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 288 | tag = dargs.pop('tag', None) |
mbligh | 65938a2 | 2007-12-10 16:58:52 +0000 | [diff] [blame] | 289 | container = dargs.pop('container', None) |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 290 | subdir = testname |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 291 | if tag: |
| 292 | subdir += '.' + tag |
| 293 | |
mbligh | 65938a2 | 2007-12-10 16:58:52 +0000 | [diff] [blame] | 294 | if container: |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 295 | cname = container.get('name', None) |
| 296 | if not cname: # get old name |
| 297 | cname = container.get('container_name', None) |
| 298 | mbytes = container.get('mbytes', None) |
| 299 | if not mbytes: # get old name |
| 300 | mbytes = container.get('mem', None) |
| 301 | cpus = container.get('cpus', None) |
| 302 | if not cpus: # get old name |
| 303 | cpus = container.get('cpu', None) |
jadmanski | 87cbc7f | 2008-05-13 18:17:10 +0000 | [diff] [blame] | 304 | root = container.get('root', None) |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 305 | self.new_container(mbytes=mbytes, cpus=cpus, |
| 306 | root=root, name=cname) |
mbligh | 65938a2 | 2007-12-10 16:58:52 +0000 | [diff] [blame] | 307 | # We are running in a container now... |
| 308 | |
jadmanski | 8415f96 | 2008-05-06 20:38:53 +0000 | [diff] [blame] | 309 | def log_warning(reason): |
| 310 | self.record("WARN", subdir, testname, reason) |
| 311 | @disk_usage_monitor.watch(log_warning, "/", |
| 312 | self.max_disk_usage_rate) |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 313 | def group_func(): |
apw | f1a8116 | 2006-04-25 10:10:29 +0000 | [diff] [blame] | 314 | try: |
mbligh | d016ecc | 2006-11-25 21:41:07 +0000 | [diff] [blame] | 315 | self.__runtest(url, tag, args, dargs) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 316 | except error.TestNAError, detail: |
| 317 | self.record('TEST_NA', subdir, testname, |
| 318 | str(detail)) |
| 319 | raise |
apw | f1a8116 | 2006-04-25 10:10:29 +0000 | [diff] [blame] | 320 | except Exception, detail: |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 321 | self.record('FAIL', subdir, testname, |
| 322 | str(detail)) |
apw | f1a8116 | 2006-04-25 10:10:29 +0000 | [diff] [blame] | 323 | raise |
| 324 | else: |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 325 | self.record('GOOD', subdir, testname, |
| 326 | 'completed successfully') |
jadmanski | 8415f96 | 2008-05-06 20:38:53 +0000 | [diff] [blame] | 327 | |
mbligh | cfc6dd3 | 2007-11-20 00:44:35 +0000 | [diff] [blame] | 328 | result, exc_info = self.__rungroup(subdir, group_func) |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 329 | if container: |
| 330 | self.release_container() |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 331 | if exc_info and isinstance(exc_info[1], error.TestError): |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 332 | return False |
| 333 | elif exc_info: |
mbligh | 71ea249 | 2008-01-15 20:35:52 +0000 | [diff] [blame] | 334 | raise exc_info[0], exc_info[1], exc_info[2] |
apw | f1a8116 | 2006-04-25 10:10:29 +0000 | [diff] [blame] | 335 | else: |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 336 | return True |
| 337 | |
| 338 | |
| 339 | def __rungroup(self, name, function, *args, **dargs): |
| 340 | """\ |
| 341 | name: |
| 342 | name of the group |
| 343 | function: |
| 344 | subroutine to run |
| 345 | *args: |
| 346 | arguments for the function |
| 347 | |
| 348 | Returns a 2-tuple (result, exc_info) where result |
| 349 | is the return value of function, and exc_info is |
| 350 | the sys.exc_info() of the exception thrown by the |
| 351 | function (which may be None). |
| 352 | """ |
| 353 | |
| 354 | result, exc_info = None, None |
| 355 | try: |
| 356 | self.record('START', None, name) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 357 | self._increment_group_level() |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 358 | result = function(*args, **dargs) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 359 | self._decrement_group_level() |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 360 | self.record('END GOOD', None, name) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 361 | except error.TestNAError, e: |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 362 | self._decrement_group_level() |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 363 | self.record('END TEST_NA', None, name, str(e)) |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 364 | except Exception, e: |
| 365 | exc_info = sys.exc_info() |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 366 | self._decrement_group_level() |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 367 | err_msg = str(e) + '\n' + traceback.format_exc() |
mbligh | 51144e0 | 2007-11-20 20:38:18 +0000 | [diff] [blame] | 368 | self.record('END FAIL', None, name, err_msg) |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 369 | |
| 370 | return result, exc_info |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 371 | |
mbligh | d7fb4a6 | 2006-10-01 00:57:53 +0000 | [diff] [blame] | 372 | |
apw | 1da244b | 2007-09-27 17:18:01 +0000 | [diff] [blame] | 373 | def run_group(self, function, *args, **dargs): |
mbligh | 88ab90f | 2007-08-29 15:52:49 +0000 | [diff] [blame] | 374 | """\ |
| 375 | function: |
| 376 | subroutine to run |
| 377 | *args: |
| 378 | arguments for the function |
| 379 | """ |
| 380 | |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 381 | # Allow the tag for the group to be specified |
mbligh | 88ab90f | 2007-08-29 15:52:49 +0000 | [diff] [blame] | 382 | name = function.__name__ |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 383 | tag = dargs.pop('tag', None) |
| 384 | if tag: |
| 385 | name = tag |
apw | 1da244b | 2007-09-27 17:18:01 +0000 | [diff] [blame] | 386 | |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 387 | result, exc_info = self.__rungroup(name, function, |
| 388 | *args, **dargs) |
apw | 1da244b | 2007-09-27 17:18:01 +0000 | [diff] [blame] | 389 | |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 390 | # if there was a non-TestError exception, raise it |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 391 | if exc_info and not isinstance(exc_info[1], error.TestError): |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 392 | err = ''.join(traceback.format_exception(*exc_info)) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 393 | raise error.TestError(name + ' failed\n' + err) |
mbligh | 88ab90f | 2007-08-29 15:52:49 +0000 | [diff] [blame] | 394 | |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 395 | # pass back the actual return value from the function |
apw | 08403ca | 2007-09-27 17:17:22 +0000 | [diff] [blame] | 396 | return result |
| 397 | |
mbligh | 88ab90f | 2007-08-29 15:52:49 +0000 | [diff] [blame] | 398 | |
jadmanski | 87cbc7f | 2008-05-13 18:17:10 +0000 | [diff] [blame] | 399 | def new_container(self, mbytes=None, cpus=None, root=None, name=None): |
mbligh | 8ea61e2 | 2008-05-09 18:09:37 +0000 | [diff] [blame] | 400 | if not autotest_utils.grep('cpuset', '/proc/filesystems'): |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 401 | print "Containers not enabled by latest reboot" |
| 402 | return # containers weren't enabled in this kernel boot |
| 403 | pid = os.getpid() |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 404 | if not name: |
| 405 | name = 'test%d' % pid # make arbitrary unique name |
| 406 | self.container = cpuset.cpuset(name, job_size=mbytes, |
mbligh | 337bb76 | 2008-04-16 21:23:10 +0000 | [diff] [blame] | 407 | job_pid=pid, cpus=cpus, root=root) |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 408 | # This job's python shell is now running in the new container |
| 409 | # and all forked test processes will inherit that container |
| 410 | |
| 411 | |
| 412 | def release_container(self): |
| 413 | if self.container: |
mbligh | 337bb76 | 2008-04-16 21:23:10 +0000 | [diff] [blame] | 414 | self.container.release() |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 415 | self.container = None |
| 416 | |
| 417 | |
| 418 | def cpu_count(self): |
| 419 | if self.container: |
| 420 | return len(self.container.cpus) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 421 | return autotest_utils.count_cpus() # use total system count |
mbligh | 6811958 | 2008-01-25 18:16:41 +0000 | [diff] [blame] | 422 | |
| 423 | |
apw | ce73d89 | 2007-09-25 16:53:05 +0000 | [diff] [blame] | 424 | # Check the passed kernel identifier against the command line |
| 425 | # and the running kernel, abort the job on missmatch. |
mbligh | 38a4a11 | 2008-03-19 13:11:34 +0000 | [diff] [blame] | 426 | def kernel_check_ident(self, expected_when, expected_id, subdir, |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 427 | type = 'src', patches=[]): |
mbligh | 38a4a11 | 2008-03-19 13:11:34 +0000 | [diff] [blame] | 428 | print (("POST BOOT: checking booted kernel " + |
| 429 | "mark=%d identity='%s' type='%s'") % |
| 430 | (expected_when, expected_id, type)) |
apw | ce73d89 | 2007-09-25 16:53:05 +0000 | [diff] [blame] | 431 | |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 432 | running_id = autotest_utils.running_os_ident() |
apw | ce73d89 | 2007-09-25 16:53:05 +0000 | [diff] [blame] | 433 | |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 434 | cmdline = autotest_utils.read_one_line("/proc/cmdline") |
apw | ce73d89 | 2007-09-25 16:53:05 +0000 | [diff] [blame] | 435 | |
| 436 | find_sum = re.compile(r'.*IDENT=(\d+)') |
| 437 | m = find_sum.match(cmdline) |
| 438 | cmdline_when = -1 |
| 439 | if m: |
| 440 | cmdline_when = int(m.groups()[0]) |
| 441 | |
| 442 | # We have all the facts, see if they indicate we |
| 443 | # booted the requested kernel or not. |
| 444 | bad = False |
mbligh | da0311e | 2007-10-25 16:03:33 +0000 | [diff] [blame] | 445 | if (type == 'src' and expected_id != running_id or |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 446 | type == 'rpm' and |
| 447 | not running_id.startswith(expected_id + '::')): |
apw | ce73d89 | 2007-09-25 16:53:05 +0000 | [diff] [blame] | 448 | print "check_kernel_ident: kernel identifier mismatch" |
| 449 | bad = True |
| 450 | if expected_when != cmdline_when: |
| 451 | print "check_kernel_ident: kernel command line mismatch" |
| 452 | bad = True |
| 453 | |
| 454 | if bad: |
| 455 | print " Expected Ident: " + expected_id |
| 456 | print " Running Ident: " + running_id |
| 457 | print " Expected Mark: %d" % (expected_when) |
| 458 | print "Command Line Mark: %d" % (cmdline_when) |
| 459 | print " Command Line: " + cmdline |
| 460 | |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 461 | raise error.JobError("boot failure", "reboot.verify") |
apw | ce73d89 | 2007-09-25 16:53:05 +0000 | [diff] [blame] | 462 | |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 463 | kernel_info = {'kernel': expected_id} |
| 464 | for i, patch in enumerate(patches): |
| 465 | kernel_info["patch%d" % i] = patch |
mbligh | b7fd270 | 2008-03-25 14:57:08 +0000 | [diff] [blame] | 466 | self.record('GOOD', subdir, 'reboot.verify', expected_id) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 467 | self._decrement_group_level() |
| 468 | self.record('END GOOD', subdir, 'reboot', |
| 469 | optional_fields=kernel_info) |
apw | ce73d89 | 2007-09-25 16:53:05 +0000 | [diff] [blame] | 470 | |
| 471 | |
mbligh | c235985 | 2007-08-28 18:11:48 +0000 | [diff] [blame] | 472 | def filesystem(self, device, mountpoint = None, loop_size = 0): |
mbligh | d7fb4a6 | 2006-10-01 00:57:53 +0000 | [diff] [blame] | 473 | if not mountpoint: |
| 474 | mountpoint = self.tmpdir |
mbligh | c235985 | 2007-08-28 18:11:48 +0000 | [diff] [blame] | 475 | return filesystem.filesystem(self, device, mountpoint,loop_size) |
mbligh | d7fb4a6 | 2006-10-01 00:57:53 +0000 | [diff] [blame] | 476 | |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 477 | |
| 478 | def enable_external_logging(self): |
| 479 | pass |
| 480 | |
| 481 | |
| 482 | def disable_external_logging(self): |
| 483 | pass |
| 484 | |
| 485 | |
| 486 | def reboot_setup(self): |
| 487 | pass |
| 488 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 489 | |
| 490 | def reboot(self, tag='autotest'): |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 491 | self.reboot_setup() |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 492 | self.record('START', None, 'reboot') |
| 493 | self._increment_group_level() |
mbligh | 3027030 | 2007-11-05 20:33:52 +0000 | [diff] [blame] | 494 | self.record('GOOD', None, 'reboot.start') |
apw | de1503a | 2006-10-10 08:34:21 +0000 | [diff] [blame] | 495 | self.harness.run_reboot() |
apw | 11985b7 | 2007-10-04 15:44:47 +0000 | [diff] [blame] | 496 | default = self.config_get('boot.set_default') |
| 497 | if default: |
| 498 | self.bootloader.set_default(tag) |
| 499 | else: |
| 500 | self.bootloader.boot_once(tag) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 501 | cmd = "(sleep 5; reboot) </dev/null >/dev/null 2>&1 &" |
| 502 | autotest_utils.system(cmd) |
apw | 0778a2f | 2006-10-06 03:11:40 +0000 | [diff] [blame] | 503 | self.quit() |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 504 | |
| 505 | |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 506 | def noop(self, text): |
| 507 | print "job: noop: " + text |
| 508 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 509 | |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 510 | def parallel(self, *tasklist): |
| 511 | """Run tasks in parallel""" |
apw | 8fef4ac | 2006-10-10 22:53:37 +0000 | [diff] [blame] | 512 | |
| 513 | pids = [] |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 514 | old_log_filename = self.log_filename |
| 515 | for i, task in enumerate(tasklist): |
| 516 | self.log_filename = old_log_filename + (".%d" % i) |
| 517 | task_func = lambda: task[0](*task[1:]) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 518 | pids.append(parallel.fork_start(self.resultdir, |
| 519 | task_func)) |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 520 | |
| 521 | old_log_path = os.path.join(self.resultdir, old_log_filename) |
| 522 | old_log = open(old_log_path, "a") |
mbligh | d509b71 | 2008-01-14 17:41:25 +0000 | [diff] [blame] | 523 | exceptions = [] |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 524 | for i, pid in enumerate(pids): |
| 525 | # wait for the task to finish |
mbligh | d509b71 | 2008-01-14 17:41:25 +0000 | [diff] [blame] | 526 | try: |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 527 | parallel.fork_waitfor(self.resultdir, pid) |
mbligh | d509b71 | 2008-01-14 17:41:25 +0000 | [diff] [blame] | 528 | except Exception, e: |
| 529 | exceptions.append(e) |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 530 | # copy the logs from the subtask into the main log |
| 531 | new_log_path = old_log_path + (".%d" % i) |
| 532 | if os.path.exists(new_log_path): |
| 533 | new_log = open(new_log_path) |
| 534 | old_log.write(new_log.read()) |
| 535 | new_log.close() |
| 536 | old_log.flush() |
| 537 | os.remove(new_log_path) |
| 538 | old_log.close() |
| 539 | |
| 540 | self.log_filename = old_log_filename |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 541 | |
mbligh | d509b71 | 2008-01-14 17:41:25 +0000 | [diff] [blame] | 542 | # handle any exceptions raised by the parallel tasks |
| 543 | if exceptions: |
| 544 | msg = "%d task(s) failed" % len(exceptions) |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 545 | raise error.JobError(msg, str(exceptions), exceptions) |
mbligh | d509b71 | 2008-01-14 17:41:25 +0000 | [diff] [blame] | 546 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 547 | |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 548 | def quit(self): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 549 | # XXX: should have a better name. |
apw | de1503a | 2006-10-10 08:34:21 +0000 | [diff] [blame] | 550 | self.harness.run_pause() |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 551 | raise error.JobContinue("more to come") |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 552 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 553 | |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 554 | def complete(self, status): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 555 | """Clean up and exit""" |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 556 | # We are about to exit 'complete' so clean up the control file. |
| 557 | try: |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 558 | os.unlink(self.state_file) |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 559 | except: |
| 560 | pass |
mbligh | c0b10d3 | 2008-03-03 16:03:28 +0000 | [diff] [blame] | 561 | |
mbligh | 61a6c1a | 2006-12-25 01:26:38 +0000 | [diff] [blame] | 562 | self.harness.run_complete() |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 563 | self.disable_external_logging() |
apw | 1b02190 | 2006-04-03 17:02:56 +0000 | [diff] [blame] | 564 | sys.exit(status) |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 565 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 566 | |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 567 | def set_state(self, var, val): |
| 568 | # Deep copies make sure that the state can't be altered |
| 569 | # without it being re-written. Perf wise, deep copies |
| 570 | # are overshadowed by pickling/loading. |
| 571 | self.state[var] = copy.deepcopy(val) |
| 572 | pickle.dump(self.state, open(self.state_file, 'w')) |
| 573 | |
| 574 | |
| 575 | def __load_state(self): |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 576 | assert not hasattr(self, "state") |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 577 | try: |
| 578 | self.state = pickle.load(open(self.state_file, 'r')) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 579 | self.state_existed = True |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 580 | except Exception: |
| 581 | print "Initializing the state engine." |
| 582 | self.state = {} |
mbligh | f1ae0a4 | 2008-04-25 16:09:20 +0000 | [diff] [blame] | 583 | self.set_state('__steps', []) # writes pickle file |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 584 | self.state_existed = False |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 585 | |
| 586 | |
| 587 | def get_state(self, var, default=None): |
| 588 | if var in self.state or default == None: |
| 589 | val = self.state[var] |
| 590 | else: |
| 591 | val = default |
| 592 | return copy.deepcopy(val) |
| 593 | |
| 594 | |
mbligh | 12a04cb | 2008-04-25 16:07:20 +0000 | [diff] [blame] | 595 | def __create_step_tuple(self, fn, args, dargs): |
| 596 | # Legacy code passes in an array where the first arg is |
| 597 | # the function or its name. |
| 598 | if isinstance(fn, list): |
| 599 | assert(len(args) == 0) |
| 600 | assert(len(dargs) == 0) |
| 601 | args = fn[1:] |
| 602 | fn = fn[0] |
| 603 | # Pickling actual functions is harry, thus we have to call |
| 604 | # them by name. Unfortunately, this means only functions |
| 605 | # defined globally can be used as a next step. |
| 606 | if isinstance(fn, types.FunctionType): |
| 607 | fn = fn.__name__ |
| 608 | if not isinstance(fn, types.StringTypes): |
| 609 | raise StepError("Next steps must be functions or " |
| 610 | "strings containing the function name") |
| 611 | return (fn, args, dargs) |
| 612 | |
| 613 | |
mbligh | 12a04cb | 2008-04-25 16:07:20 +0000 | [diff] [blame] | 614 | def next_step(self, fn, *args, **dargs): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 615 | """Define the next step""" |
mbligh | f1ae0a4 | 2008-04-25 16:09:20 +0000 | [diff] [blame] | 616 | steps = self.get_state('__steps') |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 617 | steps.append(self.__create_step_tuple(fn, args, dargs)) |
mbligh | f1ae0a4 | 2008-04-25 16:09:20 +0000 | [diff] [blame] | 618 | self.set_state('__steps', steps) |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 619 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 620 | |
mbligh | 12a04cb | 2008-04-25 16:07:20 +0000 | [diff] [blame] | 621 | def next_step_prepend(self, fn, *args, **dargs): |
mbligh | 237bed3 | 2007-09-05 13:05:57 +0000 | [diff] [blame] | 622 | """Insert a new step, executing first""" |
mbligh | f1ae0a4 | 2008-04-25 16:09:20 +0000 | [diff] [blame] | 623 | steps = self.get_state('__steps') |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 624 | steps.insert(0, self.__create_step_tuple(fn, args, dargs)) |
mbligh | f1ae0a4 | 2008-04-25 16:09:20 +0000 | [diff] [blame] | 625 | self.set_state('__steps', steps) |
mbligh | 237bed3 | 2007-09-05 13:05:57 +0000 | [diff] [blame] | 626 | |
| 627 | |
apw | 83f8d77 | 2006-04-27 14:12:56 +0000 | [diff] [blame] | 628 | def step_engine(self): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 629 | """the stepping engine -- if the control file defines |
| 630 | step_init we will be using this engine to drive multiple runs. |
| 631 | """ |
| 632 | """Do the next step""" |
apw | 83f8d77 | 2006-04-27 14:12:56 +0000 | [diff] [blame] | 633 | |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 634 | # Set up the environment and then interpret the control file. |
| 635 | # Some control files will have code outside of functions, |
| 636 | # which means we need to have our state engine initialized |
| 637 | # before reading in the file. |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 638 | lcl = {'job': self} |
| 639 | exec(JOB_PREAMBLE, lcl, lcl) |
apw | 83f8d77 | 2006-04-27 14:12:56 +0000 | [diff] [blame] | 640 | execfile(self.control, lcl, lcl) |
| 641 | |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 642 | # If we loaded in a mid-job state file, then we presumably |
| 643 | # know what steps we have yet to run. |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 644 | if not self.state_existed: |
apw | 83f8d77 | 2006-04-27 14:12:56 +0000 | [diff] [blame] | 645 | if lcl.has_key('step_init'): |
| 646 | self.next_step([lcl['step_init']]) |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 647 | |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 648 | # Iterate through the steps. If we reboot, we'll simply |
| 649 | # continue iterating on the next step. |
mbligh | f1ae0a4 | 2008-04-25 16:09:20 +0000 | [diff] [blame] | 650 | while len(self.get_state('__steps')) > 0: |
| 651 | steps = self.get_state('__steps') |
mbligh | 366ff1b | 2008-04-25 16:07:56 +0000 | [diff] [blame] | 652 | (fn, args, dargs) = steps.pop(0) |
mbligh | f1ae0a4 | 2008-04-25 16:09:20 +0000 | [diff] [blame] | 653 | self.set_state('__steps', steps) |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 654 | |
mbligh | 12a04cb | 2008-04-25 16:07:20 +0000 | [diff] [blame] | 655 | lcl['__args'] = args |
| 656 | lcl['__dargs'] = dargs |
| 657 | exec(fn + "(*__args, **__dargs)", lcl, lcl) |
apw | 0865f48 | 2006-03-30 18:50:19 +0000 | [diff] [blame] | 658 | |
mbligh | caa605c | 2006-10-02 00:37:35 +0000 | [diff] [blame] | 659 | |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 660 | def _init_group_level(self): |
| 661 | self.group_level = self.get_state("__group_level", default=0) |
| 662 | |
| 663 | |
| 664 | def _increment_group_level(self): |
| 665 | self.group_level += 1 |
| 666 | self.set_state("__group_level", self.group_level) |
| 667 | |
| 668 | |
| 669 | def _decrement_group_level(self): |
| 670 | self.group_level -= 1 |
| 671 | self.set_state("__group_level", self.group_level) |
| 672 | |
| 673 | |
| 674 | def record(self, status_code, subdir, operation, status = '', |
| 675 | optional_fields=None): |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 676 | """ |
| 677 | Record job-level status |
apw | 7db8d0b | 2006-10-09 08:10:25 +0000 | [diff] [blame] | 678 | |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 679 | The intent is to make this file both machine parseable and |
| 680 | human readable. That involves a little more complexity, but |
| 681 | really isn't all that bad ;-) |
| 682 | |
| 683 | Format is <status code>\t<subdir>\t<operation>\t<status> |
| 684 | |
| 685 | status code: (GOOD|WARN|FAIL|ABORT) |
| 686 | or START |
| 687 | or END (GOOD|WARN|FAIL|ABORT) |
| 688 | |
| 689 | subdir: MUST be a relevant subdirectory in the results, |
| 690 | or None, which will be represented as '----' |
| 691 | |
| 692 | operation: description of what you ran (e.g. "dbench", or |
| 693 | "mkfs -t foobar /dev/sda9") |
| 694 | |
| 695 | status: error message or "completed sucessfully" |
| 696 | |
| 697 | ------------------------------------------------------------ |
| 698 | |
| 699 | Initial tabs indicate indent levels for grouping, and is |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 700 | governed by self.group_level |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 701 | |
| 702 | multiline messages have secondary lines prefaced by a double |
| 703 | space (' ') |
| 704 | """ |
| 705 | |
mbligh | b0570ad | 2007-09-19 18:18:11 +0000 | [diff] [blame] | 706 | if subdir: |
| 707 | if re.match(r'[\n\t]', subdir): |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 708 | raise ValueError("Invalid character in " |
| 709 | "subdir string") |
mbligh | b0570ad | 2007-09-19 18:18:11 +0000 | [diff] [blame] | 710 | substr = subdir |
| 711 | else: |
| 712 | substr = '----' |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 713 | |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 714 | if not logging.is_valid_status(status_code): |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 715 | raise ValueError("Invalid status code supplied: %s" % |
| 716 | status_code) |
mbligh | 9c5ac32 | 2007-10-31 18:01:59 +0000 | [diff] [blame] | 717 | if not operation: |
| 718 | operation = '----' |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 719 | |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 720 | if re.match(r'[\n\t]', operation): |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 721 | raise ValueError("Invalid character in " |
| 722 | "operation string") |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 723 | operation = operation.rstrip() |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 724 | |
| 725 | if not optional_fields: |
| 726 | optional_fields = {} |
| 727 | |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 728 | status = status.rstrip() |
| 729 | status = re.sub(r"\t", " ", status) |
apw | 7db8d0b | 2006-10-09 08:10:25 +0000 | [diff] [blame] | 730 | # Ensure any continuation lines are marked so we can |
| 731 | # detect them in the status file to ensure it is parsable. |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 732 | status = re.sub(r"\n", "\n" + "\t" * self.group_level + " ", |
| 733 | status) |
mbligh | 09f288a | 2007-09-18 21:34:57 +0000 | [diff] [blame] | 734 | |
mbligh | 3027030 | 2007-11-05 20:33:52 +0000 | [diff] [blame] | 735 | # Generate timestamps for inclusion in the logs |
| 736 | epoch_time = int(time.time()) # seconds since epoch, in UTC |
| 737 | local_time = time.localtime(epoch_time) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 738 | optional_fields["timestamp"] = str(epoch_time) |
| 739 | optional_fields["localtime"] = time.strftime("%b %d %H:%M:%S", |
| 740 | local_time) |
mbligh | 3027030 | 2007-11-05 20:33:52 +0000 | [diff] [blame] | 741 | |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 742 | fields = [status_code, substr, operation] |
| 743 | fields += ["%s=%s" % x for x in optional_fields.iteritems()] |
| 744 | fields.append(status) |
| 745 | |
| 746 | msg = '\t'.join(str(x) for x in fields) |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 747 | msg = '\t' * self.group_level + msg |
apw | 7db8d0b | 2006-10-09 08:10:25 +0000 | [diff] [blame] | 748 | |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 749 | msg_tag = "" |
| 750 | if "." in self.log_filename: |
| 751 | msg_tag = self.log_filename.split(".", 1)[1] |
| 752 | |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 753 | self.harness.test_status_detail(status_code, substr, |
| 754 | operation, status, msg_tag) |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 755 | self.harness.test_status(msg, msg_tag) |
| 756 | |
| 757 | # log to stdout (if enabled) |
| 758 | #if self.log_filename == self.DEFAULT_LOG_FILENAME: |
apw | f1a8116 | 2006-04-25 10:10:29 +0000 | [diff] [blame] | 759 | print msg |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 760 | |
| 761 | # log to the "root" status log |
| 762 | status_file = os.path.join(self.resultdir, self.log_filename) |
mbligh | 7dd510c | 2007-11-13 17:11:22 +0000 | [diff] [blame] | 763 | open(status_file, "a").write(msg + "\n") |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 764 | |
| 765 | # log to the subdir status log (if subdir is set) |
mbligh | b0570ad | 2007-09-19 18:18:11 +0000 | [diff] [blame] | 766 | if subdir: |
mbligh | adff6ca | 2008-01-22 16:38:25 +0000 | [diff] [blame] | 767 | dir = os.path.join(self.resultdir, subdir) |
| 768 | if not os.path.exists(dir): |
| 769 | os.mkdir(dir) |
| 770 | |
| 771 | status_file = os.path.join(dir, |
mbligh | d528d30 | 2007-12-19 16:19:05 +0000 | [diff] [blame] | 772 | self.DEFAULT_LOG_FILENAME) |
mbligh | b0570ad | 2007-09-19 18:18:11 +0000 | [diff] [blame] | 773 | open(status_file, "a").write(msg + "\n") |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 774 | |
| 775 | |
jadmanski | 8415f96 | 2008-05-06 20:38:53 +0000 | [diff] [blame] | 776 | class disk_usage_monitor: |
| 777 | def __init__(self, logging_func, device, max_mb_per_hour): |
| 778 | self.func = logging_func |
| 779 | self.device = device |
| 780 | self.max_mb_per_hour = max_mb_per_hour |
| 781 | |
| 782 | |
| 783 | def start(self): |
| 784 | self.initial_space = autotest_utils.freespace(self.device) |
| 785 | self.start_time = time.time() |
| 786 | |
| 787 | |
| 788 | def stop(self): |
| 789 | # if no maximum usage rate was set, we don't need to |
| 790 | # generate any warnings |
| 791 | if not self.max_mb_per_hour: |
| 792 | return |
| 793 | |
| 794 | final_space = autotest_utils.freespace(self.device) |
| 795 | used_space = self.initial_space - final_space |
| 796 | stop_time = time.time() |
| 797 | total_time = stop_time - self.start_time |
| 798 | # round up the time to one minute, to keep extremely short |
| 799 | # tests from generating false positives due to short, badly |
| 800 | # timed bursts of activity |
| 801 | total_time = max(total_time, 60.0) |
| 802 | |
| 803 | # determine the usage rate |
| 804 | bytes_per_sec = used_space / total_time |
| 805 | mb_per_sec = bytes_per_sec / 1024**2 |
| 806 | mb_per_hour = mb_per_sec * 60 * 60 |
| 807 | |
| 808 | if mb_per_hour > self.max_mb_per_hour: |
| 809 | msg = ("disk space on %s was consumed at a rate of " |
| 810 | "%.2f MB/hour") |
| 811 | msg %= (self.device, mb_per_hour) |
| 812 | self.func(msg) |
| 813 | |
| 814 | |
| 815 | @classmethod |
| 816 | def watch(cls, *monitor_args, **monitor_dargs): |
| 817 | """ Generic decorator to wrap a function call with the |
| 818 | standard create-monitor -> start -> call -> stop idiom.""" |
| 819 | def decorator(func): |
| 820 | def watched_func(*args, **dargs): |
| 821 | monitor = cls(*monitor_args, **monitor_dargs) |
| 822 | monitor.start() |
| 823 | try: |
| 824 | func(*args, **dargs) |
| 825 | finally: |
| 826 | monitor.stop() |
| 827 | return watched_func |
| 828 | return decorator |
| 829 | |
| 830 | |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 831 | def runjob(control, cont = False, tag = "default", harness_type = '', |
| 832 | use_external_logging = False): |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 833 | """The main interface to this module |
| 834 | |
mbligh | 72b88fc | 2006-12-16 18:41:35 +0000 | [diff] [blame] | 835 | control |
mbligh | c86b0b4 | 2006-07-28 17:35:28 +0000 | [diff] [blame] | 836 | The control file to use for this job. |
| 837 | cont |
| 838 | Whether this is the continuation of a previously started job |
| 839 | """ |
mbligh | b4eef24 | 2007-07-23 18:22:49 +0000 | [diff] [blame] | 840 | control = os.path.abspath(control) |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 841 | state = control + '.state' |
| 842 | |
| 843 | # instantiate the job object ready for the control file. |
| 844 | myjob = None |
| 845 | try: |
| 846 | # Check that the control file is valid |
| 847 | if not os.path.exists(control): |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 848 | raise error.JobError(control + |
| 849 | ": control file not found") |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 850 | |
| 851 | # When continuing, the job is complete when there is no |
| 852 | # state file, ensure we don't try and continue. |
mbligh | f3fef46 | 2006-09-13 16:05:05 +0000 | [diff] [blame] | 853 | if cont and not os.path.exists(state): |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 854 | raise error.JobComplete("all done") |
mbligh | f3fef46 | 2006-09-13 16:05:05 +0000 | [diff] [blame] | 855 | if cont == False and os.path.exists(state): |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 856 | os.unlink(state) |
| 857 | |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 858 | myjob = job(control, tag, cont, harness_type, |
| 859 | use_external_logging) |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 860 | |
| 861 | # Load in the users control file, may do any one of: |
| 862 | # 1) execute in toto |
| 863 | # 2) define steps, and select the first via next_step() |
| 864 | myjob.step_engine() |
| 865 | |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 866 | except error.JobContinue: |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 867 | sys.exit(5) |
| 868 | |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 869 | except error.JobComplete: |
apw | b832e1b | 2007-11-24 20:24:38 +0000 | [diff] [blame] | 870 | sys.exit(1) |
| 871 | |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 872 | except error.JobError, instance: |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 873 | print "JOB ERROR: " + instance.args[0] |
mbligh | 9c5ac32 | 2007-10-31 18:01:59 +0000 | [diff] [blame] | 874 | if myjob: |
mbligh | 3027030 | 2007-11-05 20:33:52 +0000 | [diff] [blame] | 875 | command = None |
| 876 | if len(instance.args) > 1: |
| 877 | command = instance.args[1] |
| 878 | myjob.record('ABORT', None, command, instance.args[0]) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 879 | myjob._decrement_group_level() |
mbligh | c343016 | 2007-11-14 23:57:19 +0000 | [diff] [blame] | 880 | myjob.record('END ABORT', None, None) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 881 | assert(myjob.group_level == 0) |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 882 | myjob.complete(1) |
apw | b832e1b | 2007-11-24 20:24:38 +0000 | [diff] [blame] | 883 | else: |
| 884 | sys.exit(1) |
apw | ce9abe9 | 2006-04-27 14:14:04 +0000 | [diff] [blame] | 885 | |
mbligh | c343016 | 2007-11-14 23:57:19 +0000 | [diff] [blame] | 886 | except Exception, e: |
mbligh | 302482e | 2008-05-01 20:06:16 +0000 | [diff] [blame] | 887 | msg = str(e) + '\n' + traceback.format_exc() |
mbligh | c343016 | 2007-11-14 23:57:19 +0000 | [diff] [blame] | 888 | print "JOB ERROR: " + msg |
mbligh | fbfb77d | 2007-02-15 18:54:03 +0000 | [diff] [blame] | 889 | if myjob: |
mbligh | c343016 | 2007-11-14 23:57:19 +0000 | [diff] [blame] | 890 | myjob.record('ABORT', None, None, msg) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 891 | myjob._decrement_group_level() |
mbligh | c343016 | 2007-11-14 23:57:19 +0000 | [diff] [blame] | 892 | myjob.record('END ABORT', None, None) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 893 | assert(myjob.group_level == 0) |
mbligh | 9c5ac32 | 2007-10-31 18:01:59 +0000 | [diff] [blame] | 894 | myjob.complete(1) |
apw | b832e1b | 2007-11-24 20:24:38 +0000 | [diff] [blame] | 895 | else: |
| 896 | sys.exit(1) |
mbligh | 892d37f | 2007-03-01 17:03:25 +0000 | [diff] [blame] | 897 | |
mbligh | 0144e5a | 2008-03-07 18:17:53 +0000 | [diff] [blame] | 898 | # If we get here, then we assume the job is complete and good. |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 899 | myjob._decrement_group_level() |
mbligh | 0144e5a | 2008-03-07 18:17:53 +0000 | [diff] [blame] | 900 | myjob.record('END GOOD', None, None) |
jadmanski | a9c75c4 | 2008-05-01 22:05:31 +0000 | [diff] [blame] | 901 | assert(myjob.group_level == 0) |
mbligh | 0144e5a | 2008-03-07 18:17:53 +0000 | [diff] [blame] | 902 | |
mbligh | 892d37f | 2007-03-01 17:03:25 +0000 | [diff] [blame] | 903 | myjob.complete(0) |
mbligh | caa62c2 | 2008-04-07 21:51:17 +0000 | [diff] [blame] | 904 | |
| 905 | |
| 906 | # site_job.py may be non-existant or empty, make sure that an appropriate |
| 907 | # site_job class is created nevertheless |
| 908 | try: |
| 909 | from site_job import site_job |
| 910 | except ImportError: |
| 911 | class site_job(base_job): |
| 912 | pass |
| 913 | |
| 914 | class job(site_job): |
| 915 | pass |
jadmanski | 87cbc7f | 2008-05-13 18:17:10 +0000 | [diff] [blame] | 916 | |