apw | 00a69a6 | 2006-10-10 08:35:33 +0000 | [diff] [blame] | 1 | """The ABAT harness interface |
| 2 | |
| 3 | The interface as required for ABAT. |
| 4 | """ |
| 5 | |
| 6 | __author__ = """Copyright Andy Whitcroft 2006""" |
| 7 | |
| 8 | from autotest_utils import * |
apw | 2e33c6a | 2006-11-02 00:22:26 +0000 | [diff] [blame] | 9 | import os, harness, time |
apw | 00a69a6 | 2006-10-10 08:35:33 +0000 | [diff] [blame] | 10 | |
| 11 | class 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 | |
apw | 2e33c6a | 2006-11-02 00:22:26 +0000 | [diff] [blame] | 43 | 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 | |
apw | 00a69a6 | 2006-10-10 08:35:33 +0000 | [diff] [blame] | 55 | 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) |