1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Defines the test controller base library.
7 This module is the basis on which test controllers are built and executed.
13 #pylint: disable=relative-import
15 import task_controller
16 import task_registration_server
19 class TestController(object):
20 """The base test controller class."""
23 self
._registration
_server
= (
24 task_registration_server
.TaskRegistrationServer())
27 """Setup method used by the subclass."""
31 """Main test method used by the subclass."""
32 raise NotImplementedError()
35 """Teardown method used by the subclass."""
38 def CreateNewTask(self
, *args
, **kwargs
):
39 task
= task_controller
.TaskController(*args
, **kwargs
)
40 self
._registration
_server
.RegisterTaskCallback(
41 task
.otp
, task
.OnConnect
)
44 def RunController(self
):
45 """Main entry point for the controller."""
46 print ' '.join(sys
.argv
)
47 common_lib
.InitLogging()
48 self
._registration
_server
.Start()
55 except Exception as e
:
56 # Defer raising exceptions until after TearDown is called.
58 tb
= sys
.exc_info()[-1]
61 except Exception as e
:
64 tb
= sys
.exc_info()[-1]
66 self
._registration
_server
.Shutdown()
67 task_controller
.TaskController
.ReleaseAllTasks()
69 raise error
, None, tb
#pylint: disable=raising-bad-type