1########################################################################## 2# Copyright (c) 2009, 2010, 2011, ETH Zurich. 3# All rights reserved. 4# 5# This file is distributed under the terms in the attached LICENSE file. 6# If you do not find this file, copies can be found by writing to: 7# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8########################################################################## 9 10class Test(object): 11 name = None # should be overridden 12 13 def __init__(self, options): 14 pass 15 16 def setup(self, build, machine, testdir): 17 """Prepare the machine to run the test.""" 18 raise NotImplementedError 19 20 def run(self, build, machine, testdir): 21 """(Start to) run the test, raise StopIteration when it finishes. 22 Returns an iterator that will produce raw output lines from the machine. 23 """ 24 raise NotImplementedError 25 26 def cleanup(self, machine): 27 """Cleanup after running a (possibly failed) test.""" 28 raise NotImplementedError 29 30 def process_data(self, testdir, raw_iter): 31 """Given test directory and iterator for the raw output from a run, 32 return the results. 33 MAY RUN ON A DIFFERENT INSTANCE FROM THAT USED TO RUN THE TEST! 34 (therefore, this should be a pure function) 35 """ 36 raise NotImplementedError 37 38 39all_tests = [] 40 41def add_test(t): 42 all_tests.append(t) 43 return t 44 45## Import all tests 46import os 47for module in os.listdir(os.path.dirname(__file__)): 48 if module == '__init__.py' or module[-3:] != '.py': 49 continue 50 __import__(module[:-3], locals(), globals()) 51del module