3 Copyright (c) 2011-2016 ARM Limited
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
17 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
21 from sys
import stdout
26 """! Test results set by host tests """
29 return type(
'Enum', (), enums)
33 RESULT_SUCCESS =
'success',
34 RESULT_FAILURE =
'failure',
35 RESULT_ERROR =
'error',
37 RESULT_UNDEF =
'undefined',
38 RESULT_TIMEOUT =
'timeout',
39 RESULT_IOERR_COPY =
"ioerr_copy",
40 RESULT_IOERR_DISK =
"ioerr_disk",
41 RESULT_IO_SERIAL =
'ioerr_serial',
42 RESULT_NO_IMAGE =
'no_image',
43 RESULT_NOT_DETECTED =
"not_detected",
44 RESULT_MBED_ASSERT =
"mbed_assert",
45 RESULT_PASSIVE =
"passive",
46 RESULT_BUILD_FAILED =
'build_failed',
47 RESULT_SYNC_FAILED =
'sync_failed'
53 if attr.startswith(
'RESULT_'):
54 setattr(self, attr, self.
TestResultsTestResults.__dict__[attr])
77 """! Maps test result string to unique integer """
83 """! Returns numerical result code """
88 """ Base class for host test's test runner
93 HostTestResults.__init__(self)
97 """ Test runner for host test. This function will start executing
98 test and forward test result via serial port to test suite
103 """! Setup and check if configuration for test is correct.
104 @details This function can for example check if serial port is already opened
109 """! On screen notification function
110 @param msg Text message sent to stdout directly
116 """! Test result unified printing function
117 @param result Should be a member of HostTestResults.RESULT_* enums
119 self.
notifynotify(
"{{%s}}\n"% result)
120 self.
notifynotify(
"{{%s}}\n"% self.RESULT_END)
123 """ dctor for this class, finishes tasks and closes resources
128 """ Hello string used as first print
130 pkg =
'mbed-host-tests'
131 version = pkg_resources.require(pkg)[0].version
132 return "host test executor ver. " + version
136 """! Test class with serial port initialization
137 @details This is a base for other test selectors, initializes
140 Test.__init__(self, options=options)
Test class with serial port initialization.
def __init__(self, options)
Test results set by host tests.
def __getitem__(self, test_result_str)
Returns numerical result code.
def get_test_result_int(self, test_result_str)
Maps test result string to unique integer.
def get_hello_string(self)
def notify(self, msg)
On screen notification function.
def print_result(self, result)
Test result unified printing function.
def setup(self)
Setup and check if configuration for test is correct.
def __init__(self, options)
Base class for a host driven test.