1# Copyright 2014 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6class TestRun: 7 """An execution of a particular test on a particular device. 8 9 This is expected to handle all logic that is specific to the combination of 10 environment and test type. 11 12 Examples include: 13 - local gtests 14 - local instrumentation tests 15 """ 16 17 def __init__(self, env, test_instance): 18 self._env = env 19 self._test_instance = test_instance 20 21 # Some subclasses have different teardown behavior on receiving SIGTERM. 22 self._received_sigterm = False 23 24 def TestPackage(self): 25 raise NotImplementedError 26 27 def SetUp(self): 28 raise NotImplementedError 29 30 def RunTests(self, results, raw_logs_fh=None): 31 """Runs Tests and populates |results|. 32 33 Args: 34 results: An array that should be populated with 35 |base_test_result.TestRunResults| objects. 36 raw_logs_fh: An optional file handle to write raw logs to. 37 """ 38 raise NotImplementedError 39 40 def GetTestsForListing(self): 41 """Returns a list of test names.""" 42 raise NotImplementedError 43 44 def TearDown(self): 45 raise NotImplementedError 46 47 def __enter__(self): 48 self.SetUp() 49 return self 50 51 def __exit__(self, exc_type, exc_val, exc_tb): 52 self.TearDown() 53 54 def ReceivedSigterm(self): 55 self._received_sigterm = True 56