harness_simple.py revision c9f67b51b0f133b82dcce3d8d01b2576589107b1
1""" 2The simple harness interface 3""" 4 5__author__ = """Copyright Andy Whitcroft, Martin J. Bligh 2006""" 6 7from autotest_utils import * 8import os, harness, time 9 10class harness_simple(harness.harness): 11 """ 12 The simple server harness 13 14 Properties: 15 job 16 The job object for this job 17 """ 18 19 def __init__(self, job): 20 """ 21 job 22 The job object for this job 23 """ 24 self.setup(job) 25 26 self.status = os.fdopen(3, 'w') 27 28 29 def __send(self, msg): 30 if self.status: 31 self.status.write(msg.rstrip() + "\n") 32 self.status.flush() 33 34 35 def run_start(self): 36 """A run within this job is starting""" 37 self.__send("STATUS\tGOOD\t----\trun starting") 38 39 40 def run_reboot(self): 41 """A run within this job is performing a reboot 42 (expect continue following reboot) 43 """ 44 self.__send("REBOOT") 45 46 # Give the server some time to get used to the idea that 47 # we are booting before we let the actual reboot kill it. 48 time.sleep(5) 49 50 51 def run_abort(self): 52 """A run within this job is aborting. It all went wrong""" 53 self.__send("STATUS\tABORT\t----\trun aborted") 54 self.__send("DONE") 55 56 57 def run_complete(self): 58 """A run within this job is completing (all done)""" 59 self.__send("STATUS\tGOOD\t----\trun complete") 60 self.__send("DONE") 61 62 63 def test_status(self, status): 64 """A test within this job is completing""" 65 66 # Send the first line with the status code as a STATUS message. 67 lines = status.split("\n") 68 self.__send("STATUS\t" + lines[0]) 69