1226584Sdim########################################################################## 2226584Sdim# Copyright (c) 2011, ETH Zurich. 3226584Sdim# All rights reserved. 4226584Sdim# 5226584Sdim# This file is distributed under the terms in the attached LICENSE file. 6226584Sdim# If you do not find this file, copies can be found by writing to: 7226584Sdim# ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8226584Sdim########################################################################## 9226584Sdimimport datetime 10226584Sdimimport re 11226584Sdimimport tests 12226584Sdimfrom common import TestCommon 13226584Sdimfrom results import PassFailResult 14226584Sdim 15226584SdimTIMERTEST_TIMEOUT = datetime.timedelta(minutes=5) 16226584Sdim 17226584Sdim@tests.add_test 18226584Sdimclass TimerTest(TestCommon): 19226584Sdim '''Timer test''' 20226584Sdim name = "timer" 21226584Sdim 22226584Sdim def __init__(self, options): 23226584Sdim super(TimerTest, self).__init__(options) 24249423Sdim self.saw_line_A = False 25249423Sdim self.saw_line_B = False 26226584Sdim 27226584Sdim def get_modules(self, build, machine): 28226584Sdim modules = super(TimerTest, self).get_modules(build, machine) 29226584Sdim modules.add_module("lpc_timer", ["auto"]) 30226584Sdim core_ids = machine.get_coreids() 31226584Sdim modules.add_module("timer_test",["core=%d" % core_ids[1]]) 32226584Sdim if len(core_ids) > 2: 33226584Sdim modules.add_module("timer_test", ["core=%d" % core_ids[2], "B"]) 34226584Sdim else: 35226584Sdim modules.add_module("timer_test", ["core=%d" % core_ids[1], "B"]) 36226584Sdim return modules 37226584Sdim 38226584Sdim def get_test_A_finish_string(self): 39226584Sdim return "Done with test for client_A" 40226584Sdim 41226584Sdim def get_test_B_finish_string(self): 42226584Sdim return "Done with test for client_B" 43226584Sdim 44226584Sdim def is_finished(self, line): 45226584Sdim if line.startswith(self.get_test_A_finish_string()): 46226584Sdim self.saw_line_A = True 47226584Sdim if line.startswith(self.get_test_B_finish_string()): 48226584Sdim self.saw_line_B = True 49226584Sdim return (self.saw_line_A and self.saw_line_B) or \ 50226584Sdim super(TimerTest, self).is_finished(line) 51226584Sdim 52226584Sdim 53226584Sdim 54226584Sdim def boot(self, *args): 55226584Sdim super(TimerTest, self).boot(*args) 56226584Sdim self.set_timeout(TIMERTEST_TIMEOUT) 57226584Sdim 58226584Sdim def process_data(self, testdir, rawiter): 59226584Sdim # the test passed iff it has lines from both test_A and test_B 60226584Sdim test_A_passed = False 61226584Sdim test_B_passed = False 62226584Sdim 63226584Sdim for line in rawiter: 64226584Sdim if line.startswith(self.get_test_A_finish_string()): 65226584Sdim test_A_passed = True 66226584Sdim if line.startswith(self.get_test_B_finish_string()): 67226584Sdim test_B_passed = True 68226584Sdim if test_A_passed and test_B_passed: 69226584Sdim return PassFailResult(True) 70226584Sdim 71226584Sdim return PassFailResult(test_A_passed and test_B_passed) 72226584Sdim