blob: 4ea145f152da42b129791a54f574f26d965e254e [file] [log] [blame]
apw00a69a62006-10-10 08:35:33 +00001"""The ABAT harness interface
2
3The interface as required for ABAT.
4"""
5
6__author__ = """Copyright Andy Whitcroft 2006"""
7
8from autotest_utils import *
apw2e33c6a2006-11-02 00:22:26 +00009import os, harness, time
apw00a69a62006-10-10 08:35:33 +000010
11class harness_ABAT(harness.harness):
12 """The ABAT 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
26 if 'ABAT_STATUS' in os.environ:
27 self.status = file(os.environ['ABAT_STATUS'], "w")
28 else:
29 self.status = None
30
31 def __send(self, msg):
32 if self.status:
33 msg = msg.rstrip()
34 self.status.write(msg + "\n")
35 self.status.flush()
36
37
38 def run_start(self):
39 """A run within this job is starting"""
40 self.__send("STATUS GOOD run starting")
41
42
apw2e33c6a2006-11-02 00:22:26 +000043 def run_reboot(self):
44 """A run within this job is performing a reboot
45 (expect continue following reboot)
46 """
47 self.__send("REBOOT")
48
49 # Give lamb-payload some time to get used to the
50 # idea we are booting before we let the actual reboot
51 # kill it.
52 time.sleep(5)
53
54
apw00a69a62006-10-10 08:35:33 +000055 def run_complete(self, status):
56 """A run within this job is completing (all done)"""
57 self.__send("STATUS GOOD run complete")
58 self.__send("DONE")
59
60
61 def test_status(self, status):
62 """A test within this job is completing"""
63
64 # Send the first line with the status code as a STATUS message.
65 lines = status.split("\n")
66 self.__send("STATUS " + lines[0])
67
68 # Strip the status code and send the whole thing as
69 # SUMMARY messages.
70 (status, mesg) = lines[0].split(' ', 1)
71 lines[0] = mesg
72 for line in lines:
73 self.__send("SUMMARY :" + line)