blob: d0bd9eef712a337bddcbcb567e339cf6e611e163 [file] [log] [blame]
Brett Chabot924c0892009-10-21 14:23:54 -07001#!/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
21class AbstractTestSuite(object):
Brett Chabot4a5d9f12010-02-18 20:01:11 -080022 """Represents a generic test suite definition.
23
24 TODO: rename this as AbstractTestDef.
25 """
Brett Chabot924c0892009-10-21 14:23:54 -070026
27 def __init__(self):
28 self._name = None
29 self._build_path = None
30 self._build_dependencies = []
31 self._is_continuous = False
Brett Chabot4a5d9f12010-02-18 20:01:11 -080032 self._suite = None
Brett Chabot924c0892009-10-21 14:23:54 -070033 self._description = ''
34 self._extra_build_args = ''
Brett Chabot8dc9eb82010-04-15 15:43:04 -070035 self._is_full_make = False
Brett Chabot924c0892009-10-21 14:23:54 -070036
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
Brett Chabot4a5d9f12010-02-18 20:01:11 -080068 def GetSuite(self):
69 """Returns the name of test' suite, or None."""
70 return self._suite
Brett Chabot924c0892009-10-21 14:23:54 -070071
Brett Chabot4a5d9f12010-02-18 20:01:11 -080072 def SetSuite(self, suite):
73 self._suite = suite
Brett Chabot924c0892009-10-21 14:23:54 -070074 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
Brett Chabot8dc9eb82010-04-15 15:43:04 -070092 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
Brett Chabot924c0892009-10-21 14:23:54 -070099 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
Brett Chabotbb5918e2011-06-17 17:07:12 -0700108
109class AbstractTestFactory(object):
110 """generic test suite factory."""
111
Brett Chabotb0fd2cf2011-08-01 16:11:43 -0700112 def __init__(self, test_root_path, build_path):
Brett Chabotbb5918e2011-06-17 17:07:12 -0700113 """Creates a test suite factory.
114
115 Args:
116 test_root_path: the filesystem path to the tests build directory
Brett Chabotb0fd2cf2011-08-01 16:11:43 -0700117 upstream_build_path: filesystem path for the directory
118 to build when running tests, relative to the source tree root.
Brett Chabotbb5918e2011-06-17 17:07:12 -0700119 """
120 self._test_root_path = test_root_path
Brett Chabotb0fd2cf2011-08-01 16:11:43 -0700121 self._build_path = build_path
Brett Chabotbb5918e2011-06-17 17:07:12 -0700122
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