harness_simple.py revision 570e93e712f838aa8044760b8810add7ebaf8ba4
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.job = job 25 self.status = os.fdopen(3, 'w') 26 27 28 def __send(self, msg): 29 if self.status: 30 self.status.write(msg.rstrip() + "\n") 31 self.status.flush() 32 33 34 def run_start(self): 35 """A run within this job is starting""" 36 self.__send("STATUS GOOD run starting") 37 38 39 def run_reboot(self): 40 """A run within this job is performing a reboot 41 (expect continue following reboot) 42 """ 43 self.__send("REBOOT") 44 45 # Give the server some time to get used to the idea that 46 # we are booting before we let the actual reboot kill it. 47 time.sleep(5) 48 49 50 def run_complete(self, status): 51 """A run within this job is completing (all done)""" 52 self.__send("STATUS GOOD run complete") 53 self.__send("DONE") 54 55 56 def test_status(self, status): 57 """A test within this job is completing""" 58 59 # Send the first line with the status code as a STATUS message. 60 lines = status.split("\n") 61 self.__send("STATUS " + lines[0]) 62