blob: d77991c6558f07ac88fc0f993cd8afbcc8d7b1be [file] [log] [blame]
mblighc86b0b42006-07-28 17:35:28 +00001"""The main job wrapper
mbligha2508052006-05-28 21:29:53 +00002
mblighc86b0b42006-07-28 17:35:28 +00003This is the core infrastructure.
4"""
5
6__author__ = """Copyright Andy Whitcroft, Martin J. Bligh 2006"""
mbligha2508052006-05-28 21:29:53 +00007
mbligh8f243ec2006-10-10 05:55:49 +00008# standard stuff
apw8fef4ac2006-10-10 22:53:37 +00009import os, sys, re, pickle, shutil
mbligh8f243ec2006-10-10 05:55:49 +000010# autotest stuff
mblighf4c35322006-03-13 01:01:10 +000011from autotest_utils import *
apw8fef4ac2006-10-10 22:53:37 +000012from parallel import *
mbligh8baa2ea2006-12-17 23:01:24 +000013import kernel, xen, test, profilers, barrier, filesystem, fd_stack, boottool
apw059e1b12006-10-12 17:18:26 +000014import harness, config
mblighf4c35322006-03-13 01:01:10 +000015
16class job:
mblighc86b0b42006-07-28 17:35:28 +000017 """The actual job against which we do everything.
18
19 Properties:
mbligh72b88fc2006-12-16 18:41:35 +000020 autodir
mblighc86b0b42006-07-28 17:35:28 +000021 The top level autotest directory (/usr/local/autotest).
22 Comes from os.environ['AUTODIR'].
mbligh72b88fc2006-12-16 18:41:35 +000023 bindir
mblighc86b0b42006-07-28 17:35:28 +000024 <autodir>/bin/
mbligh72b88fc2006-12-16 18:41:35 +000025 testdir
mblighc86b0b42006-07-28 17:35:28 +000026 <autodir>/tests/
27 profdir
28 <autodir>/profilers/
29 tmpdir
30 <autodir>/tmp/
31 resultdir
32 <autodir>/results/<jobtag>
33 stdout
34 fd_stack object for stdout
35 stderr
36 fd_stack object for stderr
37 profilers
38 the profilers object for this job
apw504a7dd2006-10-12 17:18:37 +000039 harness
40 the server harness object for this job
apw059e1b12006-10-12 17:18:26 +000041 config
42 the job configuration for this job
mblighc86b0b42006-07-28 17:35:28 +000043 """
44
mbligh362ab3d2007-08-30 11:24:04 +000045 def __init__(self, control, jobtag, cont, harness_type=None):
mblighc86b0b42006-07-28 17:35:28 +000046 """
47 control
48 The control file (pathname of)
49 jobtag
50 The job tag string (eg "default")
apw96da1a42006-11-02 00:23:18 +000051 cont
52 If this is the continuation of this job
apwe68a7132006-12-01 11:21:37 +000053 harness_type
54 An alternative server harness
mblighc86b0b42006-07-28 17:35:28 +000055 """
mblighf4c35322006-03-13 01:01:10 +000056 self.autodir = os.environ['AUTODIR']
mbligh06743772006-05-18 21:30:19 +000057 self.bindir = self.autodir + '/bin'
mbligh82641862006-04-23 06:21:36 +000058 self.testdir = self.autodir + '/tests'
mbligha2508052006-05-28 21:29:53 +000059 self.profdir = self.autodir + '/profilers'
mblighf4c35322006-03-13 01:01:10 +000060 self.tmpdir = self.autodir + '/tmp'
mbligh24f7da02006-04-23 06:32:18 +000061 self.resultdir = self.autodir + '/results/' + jobtag
mbligha2508052006-05-28 21:29:53 +000062
apw96da1a42006-11-02 00:23:18 +000063 if not cont:
64 if os.path.exists(self.tmpdir):
mbligh09f288a2007-09-18 21:34:57 +000065 system('umount -f %s > /dev/null 2> /dev/null'%\
66 self.tmpdir, ignorestatus=True)
apw96da1a42006-11-02 00:23:18 +000067 system('rm -rf ' + self.tmpdir)
68 os.mkdir(self.tmpdir)
69
mblighfbfb77d2007-02-15 18:54:03 +000070 if not os.path.exists(self.autodir + '/results'):
71 os.mkdir(self.autodir + '/results')
72
apwf3d28622007-09-25 16:49:17 +000073 download = os.path.join(self.testdir, 'download')
74 if os.path.exists(download):
75 system('rm -rf ' + download)
76 os.mkdir(download)
77
apw96da1a42006-11-02 00:23:18 +000078 if os.path.exists(self.resultdir):
79 system('rm -rf ' + self.resultdir)
80 os.mkdir(self.resultdir)
81
82 os.mkdir(self.resultdir + "/debug")
83 os.mkdir(self.resultdir + "/analysis")
84 os.mkdir(self.resultdir + "/sysinfo")
mblighd9223fc2006-11-26 17:19:54 +000085 shutil.copyfile(control, self.resultdir + "/control")
mbligh4b089662006-06-14 22:34:58 +000086
apwecf41b72006-03-31 14:00:55 +000087 self.control = control
mblighf4c35322006-03-13 01:01:10 +000088 self.jobtab = jobtag
89
mbligh56f1fbb2006-10-01 15:10:56 +000090 self.stdout = fd_stack.fd_stack(1, sys.stdout)
91 self.stderr = fd_stack.fd_stack(2, sys.stderr)
mbligh88ab90f2007-08-29 15:52:49 +000092 self.record_prefix = ''
mblighf4c35322006-03-13 01:01:10 +000093
apw059e1b12006-10-12 17:18:26 +000094 self.config = config.config(self)
95
apwd27e55f2006-12-01 11:22:08 +000096 self.harness = harness.select(harness_type, self)
97
mbligha35553b2006-04-23 15:52:25 +000098 self.profilers = profilers.profilers(self)
mbligh72905562006-05-25 01:30:49 +000099
mblighcaa605c2006-10-02 00:37:35 +0000100 try:
apw90154af2006-12-01 11:23:36 +0000101 tool = self.config_get('boottool.executable')
102 self.bootloader = boottool.boottool(tool)
mblighcaa605c2006-10-02 00:37:35 +0000103 except:
104 pass
105
mbligh72b88fc2006-12-16 18:41:35 +0000106 pwd = os.getcwd()
mbligh06743772006-05-18 21:30:19 +0000107 os.chdir(self.resultdir + "/sysinfo")
108 system(self.bindir + '/sysinfo.py')
mblighe21abaf2007-07-26 16:17:30 +0000109 system('dmesg -c > dmesg', ignorestatus=1)
mbligh06743772006-05-18 21:30:19 +0000110 os.chdir(pwd)
mbligh3a6d6ca2006-04-23 15:50:24 +0000111
apw357f50f2006-12-01 11:22:39 +0000112 self.harness.run_start()
113
mbligh0692e472007-08-30 16:07:53 +0000114
115 def relative_path(self, path):
116 """\
117 Return a patch relative to the job results directory
118 """
mbligh1c250ca2007-08-30 16:31:38 +0000119 head = len(self.resultdir) + 1 # remove the / inbetween
120 return path[head:]
mbligh0692e472007-08-30 16:07:53 +0000121
122
mbligh362ab3d2007-08-30 11:24:04 +0000123 def control_get(self):
124 return self.control
125
mblighcaa605c2006-10-02 00:37:35 +0000126
apwde1503a2006-10-10 08:34:21 +0000127 def harness_select(self, which):
128 self.harness = harness.select(which, self)
129
130
apw059e1b12006-10-12 17:18:26 +0000131 def config_set(self, name, value):
132 self.config.set(name, value)
133
134
135 def config_get(self, name):
136 return self.config.get(name)
137
mbligh8baa2ea2006-12-17 23:01:24 +0000138 def setup_dirs(self, results_dir, tmp_dir):
mbligh1e8858e2006-11-24 22:18:35 +0000139 if not tmp_dir:
140 tmp_dir = self.tmpdir + '/build'
141 if not os.path.exists(tmp_dir):
142 os.mkdir(tmp_dir)
143 if not os.path.isdir(tmp_dir):
144 raise "Temp dir (%s) is not a dir - args backwards?" \
145 % self.tmpdir
146
147 # We label the first build "build" and then subsequent ones
148 # as "build.2", "build.3", etc. Whilst this is a little bit
149 # inconsistent, 99.9% of jobs will only have one build
150 # (that's not done as kernbench, sparse, or buildtest),
151 # so it works out much cleaner. One of life's comprimises.
152 if not results_dir:
153 results_dir = os.path.join(self.resultdir, 'build')
154 i = 2
155 while os.path.exists(results_dir):
156 results_dir = os.path.join(self.resultdir, 'build.%d' % i)
mblighd9223fc2006-11-26 17:19:54 +0000157 i += 1
mbligh1e8858e2006-11-24 22:18:35 +0000158 if not os.path.exists(results_dir):
159 os.mkdir(results_dir)
mbligh72b88fc2006-12-16 18:41:35 +0000160
mbligh8baa2ea2006-12-17 23:01:24 +0000161 return (results_dir, tmp_dir)
162
163
164 def xen(self, base_tree, results_dir = '', tmp_dir = '', leave = False, \
165 kjob = None ):
166 """Summon a xen object"""
167 (results_dir, tmp_dir) = self.setup_dirs(results_dir, tmp_dir)
168 build_dir = 'xen'
169 return xen.xen(self, base_tree, results_dir, tmp_dir, build_dir, leave, kjob)
170
171
172 def kernel(self, base_tree, results_dir = '', tmp_dir = '', leave = False):
173 """Summon a kernel object"""
174 (results_dir, tmp_dir) = self.setup_dirs(results_dir, tmp_dir)
175 build_dir = 'linux'
176 return kernel.kernel(self, base_tree, results_dir, tmp_dir, build_dir, leave)
mblighf4c35322006-03-13 01:01:10 +0000177
mblighcaa605c2006-10-02 00:37:35 +0000178
mblighfadca202006-09-23 04:40:01 +0000179 def barrier(self, *args):
180 """Create a barrier object"""
181 return barrier.barrier(*args)
182
mblighcaa605c2006-10-02 00:37:35 +0000183
mbligh4b089662006-06-14 22:34:58 +0000184 def setup_dep(self, deps):
mblighc86b0b42006-07-28 17:35:28 +0000185 """Set up the dependencies for this test.
186
187 deps is a list of libraries required for this test.
188 """
mbligh4b089662006-06-14 22:34:58 +0000189 for dep in deps:
190 try:
191 os.chdir(self.autodir + '/deps/' + dep)
192 system('./' + dep + '.py')
193 except:
194 error = "setting up dependency " + dep + "\n"
mbligh72b88fc2006-12-16 18:41:35 +0000195 raise UnhandledError(error)
mbligh4b089662006-06-14 22:34:58 +0000196
197
mbligh72b88fc2006-12-16 18:41:35 +0000198 def __runtest(self, url, tag, args, dargs):
199 try:
mblighd016ecc2006-11-25 21:41:07 +0000200 test.runtest(self, url, tag, args, dargs)
mbligh72b88fc2006-12-16 18:41:35 +0000201 except AutotestError:
202 raise
203 except:
204 raise UnhandledError('running test ' + \
205 self.__class__.__name__ + "\n")
apwf1a81162006-04-25 10:10:29 +0000206
mblighcaa605c2006-10-02 00:37:35 +0000207
mblighd016ecc2006-11-25 21:41:07 +0000208 def runtest(self, tag, url, *args):
209 raise "Deprecated call to job.runtest. Use run_test instead"
210
211
212 def run_test(self, url, *args, **dargs):
mblighc86b0b42006-07-28 17:35:28 +0000213 """Summon a test object and run it.
214
215 tag
216 tag to add to testname
mbligh12a7df72006-10-06 03:54:33 +0000217 url
218 url of the test to run
mblighc86b0b42006-07-28 17:35:28 +0000219 """
mbligh12a7df72006-10-06 03:54:33 +0000220
mblighd016ecc2006-11-25 21:41:07 +0000221 if not url:
222 raise "Test name is invalid. Switched arguments?"
mbligh09f288a2007-09-18 21:34:57 +0000223 (group, testname) = test.testname(url)
mblighd016ecc2006-11-25 21:41:07 +0000224 tag = None
mbligh09f288a2007-09-18 21:34:57 +0000225 subdir = testname
mblighd016ecc2006-11-25 21:41:07 +0000226 if dargs.has_key('tag'):
227 tag = dargs['tag']
228 del dargs['tag']
apw5a7335c2007-03-12 20:32:40 +0000229 if tag:
mbligh09f288a2007-09-18 21:34:57 +0000230 subdir += '.' + tag
apwf1a81162006-04-25 10:10:29 +0000231 try:
232 try:
mblighd016ecc2006-11-25 21:41:07 +0000233 self.__runtest(url, tag, args, dargs)
apwf1a81162006-04-25 10:10:29 +0000234 except Exception, detail:
mbligh09f288a2007-09-18 21:34:57 +0000235 self.record('FAIL', subdir, testname, \
236 detail.__str__())
apwf1a81162006-04-25 10:10:29 +0000237
238 raise
239 else:
mbligh09f288a2007-09-18 21:34:57 +0000240 self.record('GOOD', subdir, testname, \
241 'completed successfully')
apwf1a81162006-04-25 10:10:29 +0000242 except TestError:
243 return 0
244 except:
245 raise
246 else:
247 return 1
apw0865f482006-03-30 18:50:19 +0000248
mblighd7fb4a62006-10-01 00:57:53 +0000249
mbligh88ab90f2007-08-29 15:52:49 +0000250 def run_group(self, function, *args):
251 """\
252 function:
253 subroutine to run
254 *args:
255 arguments for the function
256 """
257
258 name = function.__name__
259 # if tag:
260 # name += '.' + tag
261 old_record_prefix = self.record_prefix
262 try:
263 try:
mbligh09f288a2007-09-18 21:34:57 +0000264 self.record('START', None, name)
mbligh88ab90f2007-08-29 15:52:49 +0000265 self.record_prefix += '\t'
266 function(*args)
267 self.record_prefix = old_record_prefix
mbligh09f288a2007-09-18 21:34:57 +0000268 self.record('END GOOD', None, name)
mbligh88ab90f2007-08-29 15:52:49 +0000269 except:
270 self.record_prefix = old_record_prefix
mbligh09f288a2007-09-18 21:34:57 +0000271 self.record('END FAIL', None, name, format_error())
mbligh88ab90f2007-08-29 15:52:49 +0000272 # We don't want to raise up an error higher if it's just
273 # a TestError - we want to carry on to other tests. Hence
274 # this outer try/except block.
275 except TestError:
276 pass
277 except:
278 raise TestError(name + ' failed\n' + format_error())
279
280
mblighc2359852007-08-28 18:11:48 +0000281 def filesystem(self, device, mountpoint = None, loop_size = 0):
mblighd7fb4a62006-10-01 00:57:53 +0000282 if not mountpoint:
283 mountpoint = self.tmpdir
mblighc2359852007-08-28 18:11:48 +0000284 return filesystem.filesystem(self, device, mountpoint,loop_size)
mblighd7fb4a62006-10-01 00:57:53 +0000285
mblighcaa605c2006-10-02 00:37:35 +0000286
287 def reboot(self, tag='autotest'):
apwde1503a2006-10-10 08:34:21 +0000288 self.harness.run_reboot()
mblighcaa605c2006-10-02 00:37:35 +0000289 self.bootloader.boot_once(tag)
290 system("reboot")
apw0778a2f2006-10-06 03:11:40 +0000291 self.quit()
mblighcaa605c2006-10-02 00:37:35 +0000292
293
apw0865f482006-03-30 18:50:19 +0000294 def noop(self, text):
295 print "job: noop: " + text
296
mblighcaa605c2006-10-02 00:37:35 +0000297
apw0865f482006-03-30 18:50:19 +0000298 # Job control primatives.
mblighc86b0b42006-07-28 17:35:28 +0000299
apw8fef4ac2006-10-10 22:53:37 +0000300 def __parallel_execute(self, func, *args):
301 func(*args)
302
303
mblighc86b0b42006-07-28 17:35:28 +0000304 def parallel(self, *tasklist):
305 """Run tasks in parallel"""
apw8fef4ac2006-10-10 22:53:37 +0000306
307 pids = []
308 for task in tasklist:
309 pids.append(fork_start(self.resultdir,
310 lambda: self.__parallel_execute(*task)))
311 for pid in pids:
312 fork_waitfor(self.resultdir, pid)
apw0865f482006-03-30 18:50:19 +0000313
mblighcaa605c2006-10-02 00:37:35 +0000314
apw0865f482006-03-30 18:50:19 +0000315 def quit(self):
mblighc86b0b42006-07-28 17:35:28 +0000316 # XXX: should have a better name.
apwde1503a2006-10-10 08:34:21 +0000317 self.harness.run_pause()
apwf2c66602006-04-27 14:11:25 +0000318 raise JobContinue("more to come")
apw0865f482006-03-30 18:50:19 +0000319
mblighcaa605c2006-10-02 00:37:35 +0000320
apw0865f482006-03-30 18:50:19 +0000321 def complete(self, status):
mblighc86b0b42006-07-28 17:35:28 +0000322 """Clean up and exit"""
apw0865f482006-03-30 18:50:19 +0000323 # We are about to exit 'complete' so clean up the control file.
324 try:
apwecf41b72006-03-31 14:00:55 +0000325 os.unlink(self.control + '.state')
apw0865f482006-03-30 18:50:19 +0000326 except:
327 pass
mbligh61a6c1a2006-12-25 01:26:38 +0000328 self.harness.run_complete()
apw1b021902006-04-03 17:02:56 +0000329 sys.exit(status)
apw0865f482006-03-30 18:50:19 +0000330
mblighcaa605c2006-10-02 00:37:35 +0000331
apw0865f482006-03-30 18:50:19 +0000332 steps = []
333 def next_step(self, step):
mblighc86b0b42006-07-28 17:35:28 +0000334 """Define the next step"""
apw83f8d772006-04-27 14:12:56 +0000335 step[0] = step[0].__name__
apw0865f482006-03-30 18:50:19 +0000336 self.steps.append(step)
apwecf41b72006-03-31 14:00:55 +0000337 pickle.dump(self.steps, open(self.control + '.state', 'w'))
apw0865f482006-03-30 18:50:19 +0000338
mblighcaa605c2006-10-02 00:37:35 +0000339
mbligh237bed32007-09-05 13:05:57 +0000340 def next_step_prepend(self, step):
341 """Insert a new step, executing first"""
342 step[0] = step[0].__name__
343 self.steps.insert(0, step)
344 pickle.dump(self.steps, open(self.control + '.state', 'w'))
345
346
apw83f8d772006-04-27 14:12:56 +0000347 def step_engine(self):
mblighc86b0b42006-07-28 17:35:28 +0000348 """the stepping engine -- if the control file defines
349 step_init we will be using this engine to drive multiple runs.
350 """
351 """Do the next step"""
apw83f8d772006-04-27 14:12:56 +0000352 lcl = dict({'job': self})
353
354 str = """
355from error import *
356from autotest_utils import *
357"""
358 exec(str, lcl, lcl)
359 execfile(self.control, lcl, lcl)
360
mblighd9223fc2006-11-26 17:19:54 +0000361 state = self.control + '.state'
apw0865f482006-03-30 18:50:19 +0000362 # If there is a mid-job state file load that in and continue
363 # where it indicates. Otherwise start stepping at the passed
364 # entry.
365 try:
mblighd9223fc2006-11-26 17:19:54 +0000366 self.steps = pickle.load(open(state, 'r'))
apw0865f482006-03-30 18:50:19 +0000367 except:
apw83f8d772006-04-27 14:12:56 +0000368 if lcl.has_key('step_init'):
369 self.next_step([lcl['step_init']])
apw0865f482006-03-30 18:50:19 +0000370
371 # Run the step list.
372 while len(self.steps) > 0:
apwfd922bb2006-04-04 07:47:00 +0000373 step = self.steps.pop(0)
mblighd9223fc2006-11-26 17:19:54 +0000374 pickle.dump(self.steps, open(state, 'w'))
apw0865f482006-03-30 18:50:19 +0000375
376 cmd = step.pop(0)
apw83f8d772006-04-27 14:12:56 +0000377 cmd = lcl[cmd]
378 lcl['__cmd'] = cmd
379 lcl['__args'] = step
380 exec("__cmd(*__args)", lcl, lcl)
apw0865f482006-03-30 18:50:19 +0000381
mblighcaa605c2006-10-02 00:37:35 +0000382
mbligh09f288a2007-09-18 21:34:57 +0000383 def record(self, status_code, subdir, operation, status = ''):
384 """
385 Record job-level status
apw7db8d0b2006-10-09 08:10:25 +0000386
mbligh09f288a2007-09-18 21:34:57 +0000387 The intent is to make this file both machine parseable and
388 human readable. That involves a little more complexity, but
389 really isn't all that bad ;-)
390
391 Format is <status code>\t<subdir>\t<operation>\t<status>
392
393 status code: (GOOD|WARN|FAIL|ABORT)
394 or START
395 or END (GOOD|WARN|FAIL|ABORT)
396
397 subdir: MUST be a relevant subdirectory in the results,
398 or None, which will be represented as '----'
399
400 operation: description of what you ran (e.g. "dbench", or
401 "mkfs -t foobar /dev/sda9")
402
403 status: error message or "completed sucessfully"
404
405 ------------------------------------------------------------
406
407 Initial tabs indicate indent levels for grouping, and is
408 governed by self.record_prefix
409
410 multiline messages have secondary lines prefaced by a double
411 space (' ')
412 """
413
mblighb0570ad2007-09-19 18:18:11 +0000414 if subdir:
415 if re.match(r'[\n\t]', subdir):
416 raise "Invalid character in subdir string"
417 substr = subdir
418 else:
419 substr = '----'
mbligh09f288a2007-09-18 21:34:57 +0000420
421 if not re.match(r'(START|(END )?(GOOD|WARN|FAIL|ABORT))$', \
422 status_code):
423 raise "Invalid status code supplied: %s" % status_code
424 if re.match(r'[\n\t]', operation):
425 raise "Invalid character in operation string"
426 operation = operation.rstrip()
427 status = status.rstrip()
428 status = re.sub(r"\t", " ", status)
apw7db8d0b2006-10-09 08:10:25 +0000429 # Ensure any continuation lines are marked so we can
430 # detect them in the status file to ensure it is parsable.
mbligh09f288a2007-09-18 21:34:57 +0000431 status = re.sub(r"\n", "\n" + self.record_prefix + " ", status)
432
mblighb0570ad2007-09-19 18:18:11 +0000433 msg = '%s\t%s\t%s\t%s' %(status_code, substr, operation, status)
apw7db8d0b2006-10-09 08:10:25 +0000434
apwde1503a2006-10-10 08:34:21 +0000435 self.harness.test_status(msg)
apwf1a81162006-04-25 10:10:29 +0000436 print msg
mbligh09f288a2007-09-18 21:34:57 +0000437 status_file = os.path.join(self.resultdir, 'status')
mblighb0570ad2007-09-19 18:18:11 +0000438 open(status_file, "a").write(self.record_prefix + msg + "\n")
439 if subdir:
440 status_file = os.path.join(self.resultdir, subdir, 'status')
441 open(status_file, "a").write(msg + "\n")
apwce9abe92006-04-27 14:14:04 +0000442
443
mbligh570e93e2006-11-26 05:15:56 +0000444def runjob(control, cont = False, tag = "default", harness_type = ''):
mblighc86b0b42006-07-28 17:35:28 +0000445 """The main interface to this module
446
mbligh72b88fc2006-12-16 18:41:35 +0000447 control
mblighc86b0b42006-07-28 17:35:28 +0000448 The control file to use for this job.
449 cont
450 Whether this is the continuation of a previously started job
451 """
mblighb4eef242007-07-23 18:22:49 +0000452 control = os.path.abspath(control)
apwce9abe92006-04-27 14:14:04 +0000453 state = control + '.state'
454
455 # instantiate the job object ready for the control file.
456 myjob = None
457 try:
458 # Check that the control file is valid
459 if not os.path.exists(control):
460 raise JobError(control + ": control file not found")
461
462 # When continuing, the job is complete when there is no
463 # state file, ensure we don't try and continue.
mblighf3fef462006-09-13 16:05:05 +0000464 if cont and not os.path.exists(state):
apwce9abe92006-04-27 14:14:04 +0000465 sys.exit(1)
mblighf3fef462006-09-13 16:05:05 +0000466 if cont == False and os.path.exists(state):
apwce9abe92006-04-27 14:14:04 +0000467 os.unlink(state)
468
mbligh570e93e2006-11-26 05:15:56 +0000469 myjob = job(control, tag, cont, harness_type)
apwce9abe92006-04-27 14:14:04 +0000470
471 # Load in the users control file, may do any one of:
472 # 1) execute in toto
473 # 2) define steps, and select the first via next_step()
474 myjob.step_engine()
475
apwce9abe92006-04-27 14:14:04 +0000476 except JobContinue:
477 sys.exit(5)
478
479 except JobError, instance:
480 print "JOB ERROR: " + instance.args[0]
481 if myjob != None:
mbligh09f288a2007-09-18 21:34:57 +0000482 myjob.record('ABORT', None, instance.args[0])
apwce9abe92006-04-27 14:14:04 +0000483 myjob.complete(1)
484
485 except:
mblighfbfb77d2007-02-15 18:54:03 +0000486 if myjob:
487 myjob.harness.run_abort()
apwce9abe92006-04-27 14:14:04 +0000488 # Ensure we cannot continue this job, it is in rictus.
489 if os.path.exists(state):
490 os.unlink(state)
491 raise
mbligh892d37f2007-03-01 17:03:25 +0000492
493 # If we get here, then we assume the job is complete and good.
494 myjob.complete(0)
495