summaryrefslogtreecommitdiffstats
path: root/testrunner/test_defs/test_suite.py
blob: d0bd9eef712a337bddcbcb567e339cf6e611e163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/python2.4
#
#
# Copyright 2009, The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Abstract Android test suite."""


class AbstractTestSuite(object):
  """Represents a generic test suite definition.

  TODO: rename this as AbstractTestDef.
  """

  def __init__(self):
    self._name = None
    self._build_path = None
    self._build_dependencies = []
    self._is_continuous = False
    self._suite = None
    self._description = ''
    self._extra_build_args = ''
    self._is_full_make = False

  def GetName(self):
    return self._name

  def SetName(self, name):
    self._name = name
    return self

  def GetBuildPath(self):
    """Returns the build path of this test, relative to source tree root."""
    return self._build_path

  def SetBuildPath(self, build_path):
    self._build_path = build_path
    return self

  def GetBuildDependencies(self, options):
    """Returns a list of dependent build paths."""
    return self._build_dependencies

  def SetBuildDependencies(self, build_dependencies):
    self._build_dependencies = build_dependencies
    return self

  def IsContinuous(self):
    """Returns true if test is part of the continuous test."""
    return self._is_continuous

  def SetContinuous(self, continuous):
    self._is_continuous = continuous
    return self._is_continuous

  def GetSuite(self):
    """Returns the name of test' suite, or None."""
    return self._suite

  def SetSuite(self, suite):
    self._suite = suite
    return self

  def GetDescription(self):
    """Returns a description if available, an empty string otherwise."""
    return self._description

  def SetDescription(self, desc):
    self._description = desc
    return self

  def GetExtraBuildArgs(self):
    """Returns the extra build args if available, an empty string otherwise."""
    return self._extra_build_args

  def SetExtraBuildArgs(self, build_args):
    self._extra_build_args = build_args
    return self

  def IsFullMake(self):
    return self._is_full_make

  def SetIsFullMake(self, full_make):
    self._is_full_make = full_make
    return self

  def Run(self, options, adb):
    """Runs the test.

    Subclasses must implement this.
    Args:
      options: global command line options
      adb: asdb_interface to device under test
    """
    raise NotImplementedError

class AbstractTestFactory(object):
  """generic test suite factory."""

  def __init__(self, test_root_path, build_path):
    """Creates a test suite factory.

    Args:
      test_root_path: the filesystem path to the tests build directory
      upstream_build_path: filesystem path for the directory
      to build when running tests, relative to the source tree root.
    """
    self._test_root_path = test_root_path
    self._build_path = build_path

  def GetBuildPath(self):
    return self._build_path

  def GetTestsRootPath(self):
    return self._test_root_path

  def CreateTests(self, sub_tests_path=None):
    """Creates the tests at given test_path.

    Subclasses must implement this.

    Args:
      sub_tests_path: the child path of test_root_path containing the tests to
        run. If unspecified will be set to test_root_path.

    Returns:
      an array of AbstractTestSuite, or empty AbstractTestSuite if no tests
      were defined
    """
    raise NotImplementedError