Add missing documentation and fix file doc strings

This commit is contained in:
Azim Khan 2017-08-02 14:47:13 +01:00 committed by Mohammad Azim Khan
parent 9540261a76
commit f0e42fbd1f
3 changed files with 213 additions and 162 deletions

View File

@ -1,46 +1,44 @@
# Test suites code generator.
#
# Copyright (C) 2006-2017, ARM Limited, All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
# This file is part of mbed TLS (https://tls.mbed.org)
""" """
Test suites code generator. Test Suite code generator.
Copyright (C) 2006-2017, ARM Limited, All Rights Reserved Generates a test source file using following input files:
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may test_suite_xyz.function - Read test functions from test suite functions file.
not use this file except in compliance with the License. test_suite_xyz.data - Read test functions and their dependencies to generate
You may obtain a copy of the License at dispatch and dependency check code.
main template - Substitute generated test function dispatch code, dependency
http://www.apache.org/licenses/LICENSE-2.0 checking code.
platform .function - Read host or target platform implementation for
Unless required by applicable law or agreed to in writing, software dispatching test cases from .data file.
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT helper .function - Read common reusable functions.
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file is part of mbed TLS (https://tls.mbed.org)
""" """
import os import os
import re import re
import argparse import argparse
import shutil import shutil
"""
Generates code in following structure.
<output dir>/
|-- mbedtls/
| |-- <test suite #1>/
| | |-- main.c
| | |-- *.data files
| ...
| |-- <test suite #n>/
| | |-- main.c
| | |-- *.data files
| |
"""
BEGIN_HEADER_REGEX = '/\*\s*BEGIN_HEADER\s*\*/' BEGIN_HEADER_REGEX = '/\*\s*BEGIN_HEADER\s*\*/'
END_HEADER_REGEX = '/\*\s*END_HEADER\s*\*/' END_HEADER_REGEX = '/\*\s*END_HEADER\s*\*/'
@ -67,7 +65,7 @@ class FileWrapper(file):
""" """
Init file handle. Init file handle.
:param file_name: :param file_name: File path to open.
""" """
super(FileWrapper, self).__init__(file_name, 'r') super(FileWrapper, self).__init__(file_name, 'r')
self.line_no = 0 self.line_no = 0
@ -75,7 +73,7 @@ class FileWrapper(file):
def next(self): def next(self):
""" """
Iterator return impl. Iterator return impl.
:return: :return: Line read from file.
""" """
line = super(FileWrapper, self).next() line = super(FileWrapper, self).next()
if line: if line:
@ -86,13 +84,19 @@ class FileWrapper(file):
""" """
Wrap the base class readline. Wrap the base class readline.
:param limit: :param limit: limit to match file.readline([limit])
:return: :return: Line read from file.
""" """
return self.next() return self.next()
def split_dep(dep): def split_dep(dep):
"""
Split NOT character '!' from dependency. Used by gen_deps()
:param dep: Dependency list
:return: list of tuples where index 0 has '!' if there was a '!' before the dependency string
"""
return ('!', dep[1:]) if dep[0] == '!' else ('', dep) return ('!', dep[1:]) if dep[0] == '!' else ('', dep)
@ -100,8 +104,8 @@ def gen_deps(deps):
""" """
Generates dependency i.e. if def and endif code Generates dependency i.e. if def and endif code
:param deps: :param deps: List of dependencies.
:return: :return: if defined and endif code with macro annotations for readability.
""" """
dep_start = ''.join(['#if %sdefined(%s)\n' % split_dep(x) for x in deps]) dep_start = ''.join(['#if %sdefined(%s)\n' % split_dep(x) for x in deps])
dep_end = ''.join(['#endif /* %s */\n' % x for x in reversed(deps)]) dep_end = ''.join(['#endif /* %s */\n' % x for x in reversed(deps)])
@ -113,8 +117,8 @@ def gen_deps_one_line(deps):
""" """
Generates dependency checks in one line. Useful for writing code in #else case. Generates dependency checks in one line. Useful for writing code in #else case.
:param deps: :param deps: List of dependencies.
:return: :return: ifdef code
""" """
defines = ('#if ' if len(deps) else '') + ' && '.join(['%sdefined(%s)' % split_dep(x) for x in deps]) defines = ('#if ' if len(deps) else '') + ' && '.join(['%sdefined(%s)' % split_dep(x) for x in deps])
return defines return defines
@ -122,12 +126,12 @@ def gen_deps_one_line(deps):
def gen_function_wrapper(name, locals, args_dispatch): def gen_function_wrapper(name, locals, args_dispatch):
""" """
Creates test function code Creates test function wrapper code. A wrapper has the code to unpack parameters from parameters[] array.
:param name: :param name: Test function name
:param locals: :param locals: Local variables declaration code
:param args_dispatch: :param args_dispatch: List of dispatch arguments. Ex: ['(char *)params[0]', '*((int *)params[1])']
:return: :return: Test function wrapper.
""" """
# Then create the wrapper # Then create the wrapper
wrapper = ''' wrapper = '''
@ -145,11 +149,11 @@ void {name}_wrapper( void ** params )
def gen_dispatch(name, deps): def gen_dispatch(name, deps):
""" """
Generates dispatch condition for the functions. Generates dispatch code for the test function table.
:param name: :param name: Test function name
:param deps: :param deps: List of dependencies
:return: :return: Dispatch code.
""" """
if len(deps): if len(deps):
ifdef = gen_deps_one_line(deps) ifdef = gen_deps_one_line(deps)
@ -172,8 +176,8 @@ def parse_suite_headers(funcs_f):
""" """
Parses function headers. Parses function headers.
:param funcs_f: :param funcs_f: file object for .functions file
:return: :return: Test suite headers code
""" """
headers = '#line %d "%s"\n' % (funcs_f.line_no + 1, funcs_f.name) headers = '#line %d "%s"\n' % (funcs_f.line_no + 1, funcs_f.name)
for line in funcs_f: for line in funcs_f:
@ -188,10 +192,10 @@ def parse_suite_headers(funcs_f):
def parse_suite_deps(funcs_f): def parse_suite_deps(funcs_f):
""" """
Parses function dependencies. Parses test suite dependencies.
:param funcs_f: :param funcs_f: file object for .functions file
:return: :return: List of test suite dependencies.
""" """
deps = [] deps = []
for line in funcs_f: for line in funcs_f:
@ -208,9 +212,10 @@ def parse_suite_deps(funcs_f):
def parse_function_deps(line): def parse_function_deps(line):
""" """
Parses function dependencies.
:param line: :param line: Line from .functions file that has dependencies.
:return: :return: List of dependencies.
""" """
deps = [] deps = []
m = re.search(BEGIN_CASE_REGEX, line) m = re.search(BEGIN_CASE_REGEX, line)
@ -226,8 +231,8 @@ def parse_function_signature(line):
""" """
Parsing function signature Parsing function signature
:param line: :param line: Line from .functions file that has a function signature.
:return: :return: function name, argument list, local variables for wrapper function and argument dispatch code.
""" """
args = [] args = []
locals = '' locals = ''
@ -265,12 +270,12 @@ def parse_function_signature(line):
def parse_function_code(funcs_f, deps, suite_deps): def parse_function_code(funcs_f, deps, suite_deps):
""" """
Parses out a function from function file object and generates function and dispatch code.
:param line_no: :param funcs_f: file object of the functions file.
:param funcs_f: :param deps: List of dependencies
:param deps: :param suite_deps: List of test suite dependencies
:param suite_deps: :return: Function name, arguments, function code and dispatch code.
:return:
""" """
code = '#line %d "%s"\n' % (funcs_f.line_no + 1, funcs_f.name) code = '#line %d "%s"\n' % (funcs_f.line_no + 1, funcs_f.name)
for line in funcs_f: for line in funcs_f:
@ -315,8 +320,9 @@ def parse_functions(funcs_f):
""" """
Returns functions code pieces Returns functions code pieces
:param funcs_f: :param funcs_f: file object of the functions file.
:return: :return: List of test suite dependencies, test function dispatch code, function code and
a dict with function identifiers and arguments info.
""" """
suite_headers = '' suite_headers = ''
suite_deps = [] suite_deps = []
@ -354,9 +360,9 @@ def escaped_split(str, ch):
Since return value is used to write back to the intermediate data file. Since return value is used to write back to the intermediate data file.
Any escape characters in the input are retained in the output. Any escape characters in the input are retained in the output.
:param str: :param str: String to split
:param ch: :param ch: split character
:return: :return: List of splits
""" """
if len(ch) > 1: if len(ch) > 1:
raise ValueError('Expected split character. Found string!') raise ValueError('Expected split character. Found string!')
@ -379,8 +385,8 @@ def parse_test_data(data_f, debug=False):
""" """
Parses .data file Parses .data file
:param data_f: :param data_f: file object of the data file.
:return: :return: Generator that yields test name, function name, dependency list and function argument list.
""" """
STATE_READ_NAME = 0 STATE_READ_NAME = 0
STATE_READ_ARGS = 1 STATE_READ_ARGS = 1
@ -423,9 +429,9 @@ def gen_dep_check(dep_id, dep):
""" """
Generate code for the dependency. Generate code for the dependency.
:param dep_id: :param dep_id: Dependency identifier
:param dep: :param dep: Dependency macro
:return: :return: Dependency check code
""" """
assert dep_id > -1, "Dependency Id should be a positive integer." assert dep_id > -1, "Dependency Id should be a positive integer."
noT, dep = ('!', dep[1:]) if dep[0] == '!' else ('', dep) noT, dep = ('!', dep[1:]) if dep[0] == '!' else ('', dep)
@ -447,9 +453,9 @@ def gen_expression_check(exp_id, exp):
""" """
Generates code for expression check Generates code for expression check
:param exp_id: :param exp_id: Expression Identifier
:param exp: :param exp: Expression/Macro
:return: :return: Expression check code
""" """
assert exp_id > -1, "Expression Id should be a positive integer." assert exp_id > -1, "Expression Id should be a positive integer."
assert len(exp) > 0, "Expression should not be an empty string." assert len(exp) > 0, "Expression should not be an empty string."
@ -467,10 +473,10 @@ def write_deps(out_data_f, test_deps, unique_deps):
Write dependencies to intermediate test data file. Write dependencies to intermediate test data file.
It also returns dependency check code. It also returns dependency check code.
:param out_data_f: :param out_data_f: Output intermediate data file
:param dep: :param test_deps: Dependencies
:param unique_deps: :param unique_deps: Mutable list to track unique dependencies that are global to this re-entrant function.
:return: :return: returns dependency check code.
""" """
dep_check_code = '' dep_check_code = ''
if len(test_deps): if len(test_deps):
@ -492,11 +498,11 @@ def write_parameters(out_data_f, test_args, func_args, unique_expressions):
Writes test parameters to the intermediate data file. Writes test parameters to the intermediate data file.
Also generates expression code. Also generates expression code.
:param out_data_f: :param out_data_f: Output intermediate data file
:param test_args: :param test_args: Test parameters
:param func_args: :param func_args: Function arguments
:param unique_expressions: :param unique_expressions: Mutable list to track unique expressions that are global to this re-entrant function.
:return: :return: Returns expression check code.
""" """
expression_code = '' expression_code = ''
for i in xrange(len(test_args)): for i in xrange(len(test_args)):
@ -524,10 +530,10 @@ def gen_suite_deps_checks(suite_deps, dep_check_code, expression_code):
""" """
Adds preprocessor checks for test suite dependencies. Adds preprocessor checks for test suite dependencies.
:param suite_deps: :param suite_deps: Test suite dependencies read from the .functions file.
:param dep_check_code: :param dep_check_code: Dependency check code
:param expression_code: :param expression_code: Expression check code
:return: :return: Dependency and expression code guarded by test suite dependencies.
""" """
if len(suite_deps): if len(suite_deps):
ifdef = gen_deps_one_line(suite_deps) ifdef = gen_deps_one_line(suite_deps)
@ -548,11 +554,11 @@ def gen_from_test_data(data_f, out_data_f, func_info, suite_deps):
""" """
Generates dependency checks, expression code and intermediate data file from test data file. Generates dependency checks, expression code and intermediate data file from test data file.
:param data_f: :param data_f: Data file object
:param out_data_f: :param out_data_f:Output intermediate data file
:param func_info: :param func_info: Dict keyed by function and with function id and arguments info
:param suite_deps: :param suite_deps: Test suite deps
:return: :return: Returns dependency and expression check code
""" """
unique_deps = [] unique_deps = []
unique_expressions = [] unique_expressions = []
@ -586,14 +592,14 @@ def generate_code(funcs_file, data_file, template_file, platform_file, help_file
""" """
Generate mbed-os test code. Generate mbed-os test code.
:param funcs_file: :param funcs_file: Functions file object
:param dat a_file: :param data_file: Data file object
:param template_file: :param template_file: Template file object
:param platform_file: :param platform_file: Platform file object
:param help_file: :param help_file: Helper functions file object
:param suites_dir: :param suites_dir: Test suites dir
:param c_file: :param c_file: Output C file object
:param out_data_file: :param out_data_file: Output intermediate data file object
:return: :return:
""" """
for name, path in [('Functions file', funcs_file), for name, path in [('Functions file', funcs_file),

View File

@ -1,19 +1,22 @@
""" # Unit test for generate_code.py
mbed TLS #
Copyright (c) 2017 ARM Limited # Copyright (C) 2006-2017, ARM Limited, All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
# This file is part of mbed TLS (https://tls.mbed.org)
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.
"""
from StringIO import StringIO from StringIO import StringIO
from unittest import TestCase, main as unittest_main from unittest import TestCase, main as unittest_main
from mock import patch from mock import patch
@ -425,7 +428,7 @@ class ParseFuncSignature(TestCase):
def test_int_and_char_params(self): def test_int_and_char_params(self):
""" """
Test int and char parameters parsing
:return: :return:
""" """
line = 'void entropy_threshold( char * a, int b, int result )' line = 'void entropy_threshold( char * a, int b, int result )'
@ -437,7 +440,7 @@ class ParseFuncSignature(TestCase):
def test_hex_params(self): def test_hex_params(self):
""" """
Test hex parameters parsing
:return: :return:
""" """
line = 'void entropy_threshold( char * a, HexParam_t * h, int result )' line = 'void entropy_threshold( char * a, HexParam_t * h, int result )'
@ -449,7 +452,7 @@ class ParseFuncSignature(TestCase):
def test_non_void_function(self): def test_non_void_function(self):
""" """
Test invalid signature (non void).
:return: :return:
""" """
line = 'int entropy_threshold( char * a, HexParam_t * h, int result )' line = 'int entropy_threshold( char * a, HexParam_t * h, int result )'
@ -457,7 +460,7 @@ class ParseFuncSignature(TestCase):
def test_unsupported_arg(self): def test_unsupported_arg(self):
""" """
Test unsupported arguments (not among int, char * and HexParam_t)
:return: :return:
""" """
line = 'int entropy_threshold( char * a, HexParam_t * h, int * result )' line = 'int entropy_threshold( char * a, HexParam_t * h, int * result )'
@ -465,7 +468,7 @@ class ParseFuncSignature(TestCase):
def test_no_params(self): def test_no_params(self):
""" """
Test no parameters.
:return: :return:
""" """
line = 'void entropy_threshold()' line = 'void entropy_threshold()'
@ -483,7 +486,7 @@ class ParseFunctionCode(TestCase):
def test_no_function(self): def test_no_function(self):
""" """
Test no test function found.
:return: :return:
""" """
data = ''' data = '''
@ -496,7 +499,7 @@ function
def test_no_end_case_comment(self): def test_no_end_case_comment(self):
""" """
Test missing end case.
:return: :return:
""" """
data = ''' data = '''
@ -510,7 +513,7 @@ void test_func()
@patch("generate_code.parse_function_signature") @patch("generate_code.parse_function_signature")
def test_parse_function_signature_called(self, parse_function_signature_mock): def test_parse_function_signature_called(self, parse_function_signature_mock):
""" """
Test parse_function_code()
:return: :return:
""" """
parse_function_signature_mock.return_value = ('test_func', [], '', []) parse_function_signature_mock.return_value = ('test_func', [], '', [])
@ -533,7 +536,7 @@ void test_func()
gen_deps_mock, gen_deps_mock,
gen_dispatch_mock): gen_dispatch_mock):
""" """
Test generated code.
:return: :return:
""" """
parse_function_signature_mock.return_value = ('func', [], '', []) parse_function_signature_mock.return_value = ('func', [], '', [])
@ -578,7 +581,7 @@ exit:
gen_deps_mock, gen_deps_mock,
gen_dispatch_mock): gen_dispatch_mock):
""" """
Test when exit label is present.
:return: :return:
""" """
parse_function_signature_mock.return_value = ('func', [], '', []) parse_function_signature_mock.return_value = ('func', [], '', [])

View File

@ -1,24 +1,33 @@
# Greentea host test script for on-target tests.
#
# Copyright (C) 2006-2017, ARM Limited, All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
# This file is part of mbed TLS (https://tls.mbed.org)
""" """
Greentea host test script for on-target tests. Greentea host test script for on-target tests.
Copyright (C) 2006-2017, ARM Limited, All Rights Reserved Host test script for testing mbed TLS test suites on target. Implements
SPDX-License-Identifier: Apache-2.0 BaseHostTest to handle key,value pairs (events) coming from mbed TLS
tests. Reads data file corresponding to the executing binary and dispatches
Licensed under the Apache License, Version 2.0 (the "License"); you may test cases.
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.
This file is part of mbed TLS (https://tls.mbed.org)
""" """
import re import re
import os import os
import binascii import binascii
@ -38,7 +47,9 @@ class TestDataParser(object):
def parse(self, data_file): def parse(self, data_file):
""" """
Data file parser.
:param data_file: Data file path
""" """
with open(data_file, 'r') as f: with open(data_file, 'r') as f:
self.__parse(f) self.__parse(f)
@ -46,6 +57,11 @@ class TestDataParser(object):
@staticmethod @staticmethod
def __escaped_split(str, ch): def __escaped_split(str, ch):
""" """
Splits str on ch except when escaped.
:param str: String to split
:param ch: Split character
:return: List of splits
""" """
if len(ch) > 1: if len(ch) > 1:
raise ValueError('Expected split character. Found string!') raise ValueError('Expected split character. Found string!')
@ -65,6 +81,10 @@ class TestDataParser(object):
def __parse(self, file): def __parse(self, file):
""" """
Parses data file using supplied file object.
:param file: Data file object
:return:
""" """
for line in file: for line in file:
line = line.strip() line = line.strip()
@ -93,6 +113,7 @@ class TestDataParser(object):
def get_test_data(self): def get_test_data(self):
""" """
Returns test data.
""" """
return self.tests return self.tests
@ -115,6 +136,7 @@ class MbedTlsTest(BaseHostTest):
def __init__(self): def __init__(self):
""" """
Constructor initialises test index to 0.
""" """
super(MbedTlsTest, self).__init__() super(MbedTlsTest, self).__init__()
self.tests = [] self.tests = []
@ -130,6 +152,7 @@ class MbedTlsTest(BaseHostTest):
def setup(self): def setup(self):
""" """
Setup hook implementation. Reads test suite data file and parses out tests.
""" """
binary_path = self.get_config_item('image_path') binary_path = self.get_config_item('image_path')
script_dir = os.path.split(os.path.abspath(__file__))[0] script_dir = os.path.split(os.path.abspath(__file__))[0]
@ -148,6 +171,7 @@ class MbedTlsTest(BaseHostTest):
def print_test_info(self): def print_test_info(self):
""" """
Prints test summary read by Greentea to detect test cases.
""" """
self.log('{{__testcase_count;%d}}' % len(self.tests)) self.log('{{__testcase_count;%d}}' % len(self.tests))
for name, _, _, _ in self.tests: for name, _, _, _ in self.tests:
@ -156,7 +180,7 @@ class MbedTlsTest(BaseHostTest):
@staticmethod @staticmethod
def align_32bit(b): def align_32bit(b):
""" """
4 byte aligns byte array. 4 byte aligns input byte array.
:return: :return:
""" """
@ -167,8 +191,8 @@ class MbedTlsTest(BaseHostTest):
""" """
Converts Hex string representation to byte array Converts Hex string representation to byte array
:param hex_str: :param hex_str: Hex in string format.
:return: :return: Output Byte array
""" """
assert hex_str[0] == '"' and hex_str[len(hex_str) - 1] == '"', \ assert hex_str[0] == '"' and hex_str[len(hex_str) - 1] == '"', \
"HEX test parameter missing '\"': %s" % hex_str "HEX test parameter missing '\"': %s" % hex_str
@ -183,8 +207,8 @@ class MbedTlsTest(BaseHostTest):
""" """
Coverts i to bytearray in big endian format. Coverts i to bytearray in big endian format.
:param i: :param i: Input integer
:return: :return: Output bytes array in big endian or network order
""" """
b = bytearray([((i >> x) & 0xff) for x in [24, 16, 8, 0]]) b = bytearray([((i >> x) & 0xff) for x in [24, 16, 8, 0]])
return b return b
@ -193,10 +217,10 @@ class MbedTlsTest(BaseHostTest):
""" """
Converts test vector into a byte array that can be sent to the target. Converts test vector into a byte array that can be sent to the target.
:param function_id: :param function_id: Test Function Identifier
:param deps: :param deps: Dependency list
:param parameters: :param parameters: Test function input parameters
:return: :return: Byte array and its length
""" """
b = bytearray([len(deps)]) b = bytearray([len(deps)])
if len(deps): if len(deps):
@ -243,10 +267,10 @@ class MbedTlsTest(BaseHostTest):
""" """
Runs the test. Runs the test.
:param name: :param name: Test name
:param function_id: :param function_id: function identifier
:param deps: :param deps: Dependencies list
:param args: :param args: test parameters
:return: :return:
""" """
self.log("Running: %s" % name) self.log("Running: %s" % name)
@ -256,6 +280,11 @@ class MbedTlsTest(BaseHostTest):
@staticmethod @staticmethod
def get_result(value): def get_result(value):
"""
Converts result from string type to integer
:param value: Result code in string
:return: Integer result code
"""
try: try:
return int(value) return int(value)
except ValueError: except ValueError:
@ -264,13 +293,25 @@ class MbedTlsTest(BaseHostTest):
@event_callback('GO') @event_callback('GO')
def on_go(self, key, value, timestamp): def on_go(self, key, value, timestamp):
"""
Called on key "GO". Kicks off test execution.
:param key: Event key
:param value: Value. ignored
:param timestamp: Timestamp ignored.
:return:
"""
self.run_next_test() self.run_next_test()
@event_callback("R") @event_callback("R")
def on_result(self, key, value, timestamp): def on_result(self, key, value, timestamp):
""" """
Handle result. Handle result. Prints test start, finish prints required by Greentea to detect test execution.
:param key: Event key
:param value: Value. ignored
:param timestamp: Timestamp ignored.
:return:
""" """
int_val = self.get_result(value) int_val = self.get_result(value)
name, function, deps, args = self.tests[self.test_index] name, function, deps, args = self.tests[self.test_index]
@ -282,11 +323,12 @@ class MbedTlsTest(BaseHostTest):
@event_callback("F") @event_callback("F")
def on_failure(self, key, value, timestamp): def on_failure(self, key, value, timestamp):
""" """
Handles test execution failure. Hence marking test as skipped. Handles test execution failure. That means dependency not supported or
Test function not supported. Hence marking test as skipped.
:param key: :param key: Event key
:param value: :param value: Value. ignored
:param timestamp: :param timestamp: Timestamp ignored.
:return: :return:
""" """
int_val = self.get_result(value) int_val = self.get_result(value)