1 #!/usr/bin/python2.4 2 # 3 # 4 # Copyright 2009, The Android Open Source Project 5 # 6 # Licensed under the Apache License, Version 2.0 (the "License"); 7 # you may not use this file except in compliance with the License. 8 # You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 18 """Abstract Android test suite.""" 19 20 21 class AbstractTestSuite(object): 22 """Represents a generic test suite definition. 23 24 TODO: rename this as AbstractTestDef. 25 """ 26 27 def __init__(self): 28 self._name = None 29 self._build_path = None 30 self._build_dependencies = [] 31 self._is_continuous = False 32 self._suite = None 33 self._description = '' 34 self._extra_build_args = '' 35 self._is_full_make = False 36 37 def GetName(self): 38 return self._name 39 40 def SetName(self, name): 41 self._name = name 42 return self 43 44 def GetBuildPath(self): 45 """Returns the build path of this test, relative to source tree root.""" 46 return self._build_path 47 48 def SetBuildPath(self, build_path): 49 self._build_path = build_path 50 return self 51 52 def GetBuildDependencies(self, options): 53 """Returns a list of dependent build paths.""" 54 return self._build_dependencies 55 56 def SetBuildDependencies(self, build_dependencies): 57 self._build_dependencies = build_dependencies 58 return self 59 60 def IsContinuous(self): 61 """Returns true if test is part of the continuous test.""" 62 return self._is_continuous 63 64 def SetContinuous(self, continuous): 65 self._is_continuous = continuous 66 return self._is_continuous 67 68 def GetSuite(self): 69 """Returns the name of test' suite, or None.""" 70 return self._suite 71 72 def SetSuite(self, suite): 73 self._suite = suite 74 return self 75 76 def GetDescription(self): 77 """Returns a description if available, an empty string otherwise.""" 78 return self._description 79 80 def SetDescription(self, desc): 81 self._description = desc 82 return self 83 84 def GetExtraBuildArgs(self): 85 """Returns the extra build args if available, an empty string otherwise.""" 86 return self._extra_build_args 87 88 def SetExtraBuildArgs(self, build_args): 89 self._extra_build_args = build_args 90 return self 91 92 def IsFullMake(self): 93 return self._is_full_make 94 95 def SetIsFullMake(self, full_make): 96 self._is_full_make = full_make 97 return self 98 99 def Run(self, options, adb): 100 """Runs the test. 101 102 Subclasses must implement this. 103 Args: 104 options: global command line options 105 adb: asdb_interface to device under test 106 """ 107 raise NotImplementedError 108 109 class AbstractTestFactory(object): 110 """generic test suite factory.""" 111 112 def __init__(self, test_root_path, build_path): 113 """Creates a test suite factory. 114 115 Args: 116 test_root_path: the filesystem path to the tests build directory 117 upstream_build_path: filesystem path for the directory 118 to build when running tests, relative to the source tree root. 119 """ 120 self._test_root_path = test_root_path 121 self._build_path = build_path 122 123 def GetBuildPath(self): 124 return self._build_path 125 126 def GetTestsRootPath(self): 127 return self._test_root_path 128 129 def CreateTests(self, sub_tests_path=None): 130 """Creates the tests at given test_path. 131 132 Subclasses must implement this. 133 134 Args: 135 sub_tests_path: the child path of test_root_path containing the tests to 136 run. If unspecified will be set to test_root_path. 137 138 Returns: 139 an array of AbstractTestSuite, or empty AbstractTestSuite if no tests 140 were defined 141 """ 142 raise NotImplementedError 143