Fix deprecation issues with older Python code (#296)

* Fix deprecation issues with older Python code

* Remove mbed_greentea package
pull/15530/head
Jamie Smith 2024-07-06 01:19:25 -07:00 committed by GitHub
parent 25dbf7c5fd
commit 71cb8129af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
53 changed files with 76 additions and 5127 deletions

View File

@ -158,7 +158,6 @@ jobs:
doxyfile-path: ./doxyfile_options
python-tests:
# these tests run in 3.7, hence running in vm not in pre-built docker
runs-on: ubuntu-latest
steps:
-

View File

@ -16,7 +16,6 @@ set(MBEDHTRUN_ARGS --skip-flashing @MBED_HTRUN_ARGUMENTS@) # filled in by config
string(REPLACE ";" " " MBEDHTRUN_ARGS_FOR_DISPLAY "${MBEDHTRUN_ARGS}")
message("Executing: @Python3_EXECUTABLE@ -m mbed_host_tests.mbedhtrun ${MBEDHTRUN_ARGS_FOR_DISPLAY}")
# Note: For this command, we need to survive mbedhtrun not being on the PATH, so we import the package and call the main function using "python -c"
execute_process(
COMMAND @Python3_EXECUTABLE@ -m mbed_host_tests.mbedhtrun ${MBEDHTRUN_ARGS}
WORKING_DIRECTORY "@mbed-os_SOURCE_DIR@/tools/python"

View File

@ -1,227 +0,0 @@
# Development moved
The development of Greentea has been moved into the [mbed-os-tools](../../src/mbed_os_tools) package. You can continue to use this module for legacy reasons, however all further development should be continued in the new package.
-------------
[![PyPI version](https://badge.fury.io/py/mbed-greentea.svg)](https://badge.fury.io/py/mbed-greentea)
# Greentea - test automation for mbed
_**G**eneric **re**gression **en**vironment for **te**st **a**utomation_
## Introduction
Greentea is the automated testing tool for mbed OS development. It automates the process of flashing mbed boards, driving the test and accumulating test results into test reports. Developers use it for local development as well as for automation in a Continuous Integration environment.
This document should help you start using Greentea. Please see the [htrun documentation](https://github.com/ARMmbed/htrun), the tool Greentea uses to drive tests, for the technical details of the interactions between the platform and the host machine.
Because Greentea is an open source project, we accept contributions! Please see our [contributing document](CONTRIBUTING.md) for more information.
### Prerequistes
Greentea requires [Python version 2.7](https://www.python.org/downloads/). It supports the following OSes:
- Windows
- Linux (Ubuntu preferred)
- OS X (experimental)
### Installing
Tools that depend on Greentea usually install it. Determine if Greentea is already installed by running:
```
$ mbedgt --version
1.2.5
```
You can also install it manually via pip.
```
pip install mbed-greentea
```
## Test specification JSON format
The Greentea test specification format decouples the tool from your build system. It provides important data, such as test names, paths to test binaries and the platform on which the binaries should run.
Greentea automatically looks for files called `test_spec.json` in your working directory. You can also use the `--test-spec` argument to direct Greentea to a specific test specification file.
When you use the `-t` / `--target` argument with the `--test-spec` argument, you can select which "build" should be used. In the example below, you could provide the arguments `--test-spec test_spec.json -t K64F-ARM` to only run that build's tests.
### Example of test specification file
In the below example, there are two defined builds:
* Build `K64F-ARM` for NXP `K64F` platform compiled with `ARMCC` compiler.
* Build `K64F-GCC` for NXP `K64F` platform compiled with `GCC ARM` compiler.
```json
{
"builds": {
"K64F-ARM": {
"platform": "K64F",
"toolchain": "ARM",
"base_path": "./BUILD/K64F/ARM",
"baud_rate": 9600,
"tests": {
"tests-mbedmicro-rtos-mbed-mail": {
"binaries": [
{
"binary_type": "bootable",
"path": "./BUILD/K64F/ARM/tests-mbedmicro-rtos-mbed-mail.bin"
}
]
},
"tests-mbed_drivers-c_strings": {
"binaries": [
{
"binary_type": "bootable",
"path": "./BUILD/K64F/ARM/tests-mbed_drivers-c_strings.bin"
}
]
}
}
},
"K64F-GCC": {
"platform": "K64F",
"toolchain": "GCC_ARM",
"base_path": "./BUILD/K64F/GCC_ARM",
"baud_rate": 9600,
"tests": {
"tests-mbedmicro-rtos-mbed-mail": {
"binaries": [
{
"binary_type": "bootable",
"path": "./BUILD/K64F/GCC_ARM/tests-mbedmicro-rtos-mbed-mail.bin"
}
]
}
}
}
}
}
```
The examples below use the above test specification file.
## Command-line usage
This section highlights a few of the capabilities of the Greentea command-line interface. For a full list of the available options, please run `mbedgt --help`.
Assume for the examples below that the above `test_spec.json` file is in the current directory.
### Listing all tests
You can use the `-l` argument to list all available tests:
```
$ mbedgt -l
mbedgt: greentea test automation tool ver. 1.2.5
mbedgt: using multiple test specifications from current directory!
using 'BUILD\tests\K64F\ARM\test_spec.json'
using 'BUILD\tests\K64F\GCC_ARM\test_spec.json'
mbedgt: available tests for built 'K64F-GCC_ARM', location 'BUILD/tests/K64F/GCC_ARM'
test 'tests-mbedmicro-rtos-mbed-mail'
mbedgt: available tests for built 'K64F-ARM', location 'BUILD/tests/K64F/ARM'
test 'tests-mbed_drivers-c_strings'
test 'tests-mbedmicro-rtos-mbed-mail'
```
### Executing all tests
The default action of Greentea using `mbedgt` is to execute all tests that are found in `test_spec.json` files. You can also add `-V` to make the output more verbose.
### Limiting tests
You can select test cases by name using the `-n` argument. This command executes all tests named `tests-mbedmicro-rtos-mbed-mail` from all builds in the test specification:
```
$ mbedgt -n tests-mbedmicro-rtos-mbed-mail
```
When using the `-n` argument, you can use the `*` character at the end of a test name to match all tests that share a prefix. This command executes all tests that start with `tests*`:
```
$ mbedgt -n tests*
```
You can use the `-t` argument to select which build to use when finding tests. This command executes the test `tests-mbedmicro-rtos-mbed-mail` for the `K64F-ARM` build in the test specification:
```
$ mbedgt -n tests-mbedmicro-rtos-mbed-mail -t K64F-ARM
```
You can use a comma (`,`) to separate test names (argument `-n`) and build names (argument `-t`). This command executes the tests `tests-mbedmicro-rtos-mbed-mail` and `tests-mbed_drivers-c_strings` for the `K64F-ARM` and `K64F-GCC_ARM` builds in the test specification:
```
$ mbedgt -n tests-mbedmicro-rtos-mbed-mail,tests-mbed_drivers-c_strings -t K64F-ARM,K64F-GCC_ARM
```
### Selecting platforms
You can limit which boards Greentea uses for testing by using the `--use-tids` argument.
```
$ mbedgt --use-tids 02400203C3423E603EBEC3D8,024002031E031E6AE3FFE3D2
```
Where ```02400203C3423E603EBEC3D8``` and ```024002031E031E6AE3FFE3D2``` are the target IDs of platforms attached to your system.
You can view target IDs using the [mbed-ls](https://pypi.org/project/mbed-ls) tool (installed with Greentea).
```
$ mbedls
+--------------+---------------------+------------+------------+-------------------------+
|platform_name |platform_name_unique |mount_point |serial_port |target_id |
+--------------+---------------------+------------+------------+-------------------------+
|K64F |K64F[0] |E: |COM160 |024002031E031E6AE3FFE3D2 |
|K64F |K64F[1] |F: |COM162 |02400203C3423E603EBEC3D8 |
|LPC1768 |LPC1768[0] |G: |COM5 |1010ac87cfc4f23c4c57438d |
+--------------+---------------------+------------+------------+-------------------------+
```
In this case, you won't test one target, the LPC1768.
### Testing on Fast Model FVPs
Fast Models FVPs are software models for Arm reference design platfrom
Greentea supports running test on Fast Models. And [mbed-fastmodel-agent](https://github.com/ARMmbed/mbed-fastmodel-agent) module is required for this purpose.
The "--fm" option only available when the `mbed-fastmodel-agent` module is installed :
You can run tests for FVP_MPS2_Cortex-M3 models, by '--fm' option:
```
$ mbedgt --fm FVP_MPS2_M3:DEFAULT
```
Where ```FVP_MPS2_M3``` is the platfrom name for the ```FVP_MPS2_Cortex-M3``` models in mbed OS.
And ```DEFAULT``` is the config to the Fast Model, you can find out using ```mbedfm``` command
### Creating reports
Greentea supports a number of report formats.
#### HTML
This creates an interactive HTML page with test results and logs.
```
mbedgt --report-html html_report.html
```
#### JUnit
This creates an XML JUnit report, which you can use with popular Continuous Integration software, such as [Jenkins](https://jenkins.io/index.html).
```
mbedgt --report-junit junit_report.xml
```
#### JSON
This creates a general JSON report.
```
mbedgt --report-json json_report.json
```
#### Plain text
This creates a human-friendly text summary of the test run.
```
mbedgt --report-text text_report.text
```
## Host test detection
When developing with mbed OS, Greentea detects host tests automatically if you place them in the correct location. All tests in mbed OS are placed under a `TESTS` directory. You may place custom host test scripts in a folder named `host_tests` in this folder. For more information about the mbed OS test directory structure, please see the [mbed CLI documentation](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/cli/#test-directory-structure).
## Common issues
### `IOERR_SERIAL` errors
Possible causes:
- Another program is using the serial port. Be sure all terminals and other instances of Greentea are closed before trying again.
- The mbed interface firmware is out of date. Please see the platform's page on [developer.mbed.org](https://developer.mbed.org/) for details about how to update it.

View File

@ -1,29 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
"""
from .mbed_greentea_cli import main
"""! @package mbed-greentea
This is a test suite used by mbed project. If you have yotta package with tests you can run them on supported hardware
This test suite supports:
* mbed-ls - mbed-enabled device auto detection module
* mbed-host-test - mbed-enabled device test framework (flash, reset and make host tests)
"""

View File

@ -1,19 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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 mbed_greentea.mbed_greentea_cli import main
exit(main())

View File

@ -1,25 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
"""
from mbed_os_tools.test.cmake_handlers import (
load_ctest_testsuite,
parse_ctesttestfile_line,
list_binaries_for_targets,
list_binaries_for_builds,
)

View File

@ -1,23 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_common_api import (
run_cli_command,
run_cli_process,
)

View File

@ -1,23 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_coverage_api import (
coverage_pack_hex_payload,
coverage_dump_file,
)

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_greentea_dlm import (
HOME_DIR,
GREENTEA_HOME_DIR,
GREENTEA_GLOBAL_LOCK,
GREENTEA_KETTLE,
GREENTEA_KETTLE_PATH,
greentea_home_dir_init,
greentea_get_app_sem,
greentea_get_target_lock,
greentea_get_global_lock,
greentea_update_kettle,
greentea_clean_kettle,
greentea_acquire_target_id,
greentea_acquire_target_id_from_list,
greentea_release_target_id,
get_json_data_from_file,
greentea_kettle_info,
)

View File

@ -1,21 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_greentea_hooks import (
GreenteaTestHook,
GreenteaCliTestHook,
LcovHook,
GreenteaHooks,
)

View File

@ -1,24 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_greentea_log import (
COLORAMA,
GreenTeaSimpleLockLogger,
gt_logger,
)

View File

@ -1,38 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_report_api import (
export_to_file,
exporter_json,
exporter_text,
exporter_testcase_text,
exporter_testcase_junit,
html_template,
TEST_RESULT_COLOURS,
TEST_RESULT_DEFAULT_COLOUR,
get_result_colour_class_css,
get_result_colour_class,
get_dropdown_html,
get_result_overlay_testcase_dropdown,
get_result_overlay_testcases_dropdown_menu,
get_result_overlay_dropdowns,
get_result_overlay,
exporter_html,
exporter_memory_metrics_csv,
)

View File

@ -1,36 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_target_info import (
TARGET_INFO_MAPPING,
TARGET_TOOLCAHINS,
get_mbed_target_call_yotta_target,
parse_yotta_json_for_build_name,
get_yotta_target_from_local_config,
get_mbed_target_from_current_dir,
parse_yotta_target_cmd_output,
get_mbed_targets_from_yotta_local_module,
parse_mbed_target_from_target_json,
get_mbed_targets_from_yotta,
parse_yotta_search_cmd_output,
add_target_info_mapping,
get_mbed_clasic_target_info,
get_binary_type_for_platform,
get_platform_property,
)

View File

@ -1,267 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
"""
import os
from time import time
from mbed_os_tools.test.mbed_test_api import (
TEST_RESULT_OK,
TEST_RESULT_FAIL,
TEST_RESULT_ERROR,
TEST_RESULT_SKIPPED,
TEST_RESULT_UNDEF,
TEST_RESULT_IOERR_COPY,
TEST_RESULT_IOERR_DISK,
TEST_RESULT_IOERR_SERIAL,
TEST_RESULT_TIMEOUT,
TEST_RESULT_NO_IMAGE,
TEST_RESULT_MBED_ASSERT,
TEST_RESULT_BUILD_FAILED,
TEST_RESULT_SYNC_FAILED,
TEST_RESULTS,
TEST_RESULT_MAPPING,
RUN_HOST_TEST_POPEN_ERROR,
get_test_result,
run_command,
run_htrun,
get_testcase_count_and_names,
get_testcase_utest,
get_coverage_data,
get_printable_string,
get_testcase_summary,
get_testcase_result,
get_memory_metrics,
get_thread_with_max_stack_size,
get_thread_stack_info_summary,
log_mbed_devices_in_table,
get_test_spec,
get_test_build_properties,
parse_global_resource_mgr,
parse_fast_model_connection,
gt_logger,
)
def run_host_test(image_path,
disk,
port,
build_path,
target_id,
duration=10,
micro=None,
reset=None,
verbose=False,
copy_method=None,
program_cycle_s=None,
forced_reset_timeout=None,
digest_source=None,
json_test_cfg=None,
max_failed_properties=5,
enum_host_tests_path=None,
global_resource_mgr=None,
fast_model_connection=None,
compare_log=None,
num_sync_packtes=None,
polling_timeout=None,
retry_count=1,
tags=None,
run_app=None):
"""! This function runs host test supervisor (executes mbedhtrun) and checks output from host test process.
@param image_path Path to binary file for flashing
@param disk Currently mounted mbed-enabled devices disk (mount point)
@param port Currently mounted mbed-enabled devices serial port (console)
@param duration Test case timeout
@param micro Mbed-enabled device name
@param reset Reset type
@param forced_reset_timeout Reset timeout (sec)
@param verbose Verbose mode flag
@param copy_method Copy method type (name)
@param program_cycle_s Wait after flashing delay (sec)
@param json_test_cfg Additional test configuration file path passed to host tests in JSON format
@param max_failed_properties After how many unknown properties we will assume test is not ported
@param enum_host_tests_path Directory where locally defined host tests may reside
@param num_sync_packtes sync packets to send for host <---> device communication
@param polling_timeout Timeout in sec for readiness of mount point and serial port of local or remote device
@param tags Filter list of available devices under test to only run on devices with the provided list
of tags [tag-filters tag1,tag]
@param run_app Run application mode flag (we run application and grab serial port data)
@param digest_source if None mbedhtrun will be executed. If 'stdin',
stdin will be used via StdInObserver or file (if
file name was given as switch option)
@return Tuple with test results, test output, test duration times, test case results, and memory metrics.
Return int > 0 if running mbedhtrun process failed.
Retrun int < 0 if something went wrong during mbedhtrun execution.
"""
def get_binary_host_tests_dir(binary_path, level=2):
"""! Checks if in binary test group has host_tests directory
@param binary_path Path to binary in test specification
@param level How many directories above test host_tests dir exists
@return Path to host_tests dir in group binary belongs too, None if not found
"""
try:
binary_path_norm = os.path.normpath(binary_path)
current_path_norm = os.path.normpath(os.getcwd())
host_tests_path = binary_path_norm.split(os.sep)[:-level] + ['host_tests']
build_dir_candidates = ['BUILD', '.build']
idx = None
for build_dir_candidate in build_dir_candidates:
if build_dir_candidate in host_tests_path:
idx = host_tests_path.index(build_dir_candidate)
break
if idx is None:
msg = 'The following directories were not in the path: %s' % (', '.join(build_dir_candidates))
raise Exception(msg)
# Cut /<build dir>/tests/TOOLCHAIN/TARGET
host_tests_path = host_tests_path[:idx] + host_tests_path[idx+4:]
host_tests_path = os.sep.join(host_tests_path)
except Exception as e:
gt_logger.gt_log_warn("there was a problem while looking for host_tests directory")
gt_logger.gt_log_tab("level %d, path: %s"% (level, binary_path))
gt_logger.gt_log_tab(str(e))
return None
if os.path.isdir(host_tests_path):
return host_tests_path
return None
if not enum_host_tests_path:
# If there is -e specified we will try to find a host_tests path ourselves
#
# * Path to binary starts from "build" directory, and goes 4 levels
# deep: ./build/tests/compiler/toolchain
# * Binary is inside test group.
# For example: <app>/tests/test_group_name/test_dir/*,cpp.
# * We will search for directory called host_tests on the level of test group (level=2)
# or on the level of tests directory (level=3).
#
# If host_tests directory is found above test code will will pass it to mbedhtrun using
# switch -e <path_to_host_tests_dir>
gt_logger.gt_log("checking for 'host_tests' directory above image directory structure", print_text=verbose)
test_group_ht_path = get_binary_host_tests_dir(image_path, level=2)
TESTS_dir_ht_path = get_binary_host_tests_dir(image_path, level=3)
if test_group_ht_path:
enum_host_tests_path = test_group_ht_path
elif TESTS_dir_ht_path:
enum_host_tests_path = TESTS_dir_ht_path
if enum_host_tests_path:
gt_logger.gt_log_tab("found 'host_tests' directory in: '%s'"% enum_host_tests_path, print_text=verbose)
else:
gt_logger.gt_log_tab("'host_tests' directory not found: two directory levels above image path checked", print_text=verbose)
gt_logger.gt_log("selecting test case observer...", print_text=verbose)
if digest_source:
gt_logger.gt_log_tab("selected digest source: %s"% digest_source, print_text=verbose)
# Select who will digest test case serial port data
if digest_source == 'stdin':
# When we want to scan stdin for test results
raise NotImplementedError
elif digest_source is not None:
# When we want to open file to scan for test results
raise NotImplementedError
# Command executing CLI for host test supervisor (in detect-mode)
cmd = ["mbedhtrun",
'-m', micro,
'-p', port,
'-f', '"%s"'% image_path,
]
if enum_host_tests_path:
cmd += ["-e", '"%s"'% enum_host_tests_path]
if global_resource_mgr:
# Use global resource manager to execute test
# Example:
# $ mbedhtrun -p :9600 -f "tests-mbed_drivers-generic_tests.bin" -m K64F --grm raas_client:10.2.203.31:8000
cmd += ['--grm', global_resource_mgr]
else:
# Use local resources to execute tests
# Add extra parameters to host_test
if disk:
cmd += ["-d", disk]
if copy_method:
cmd += ["-c", copy_method]
if target_id:
cmd += ["-t", target_id]
if reset:
cmd += ["-r", reset]
if run_app:
cmd += ["--run"] # -f stores binary name!
if fast_model_connection:
# Use simulator resource manager to execute test
# Example:
# $ mbedhtrun -f "tests-mbed_drivers-generic_tests.elf" -m FVP_MPS2_M3 --fm DEFAULT
cmd += ['--fm', fast_model_connection]
if compare_log:
cmd += ['--compare-log', compare_log]
if program_cycle_s:
cmd += ["-C", str(program_cycle_s)]
if forced_reset_timeout:
cmd += ["-R", str(forced_reset_timeout)]
if json_test_cfg:
cmd += ["--test-cfg", '"%s"' % str(json_test_cfg)]
if num_sync_packtes:
cmd += ["--sync",str(num_sync_packtes)]
if tags:
cmd += ["--tag-filters", tags]
if polling_timeout:
cmd += ["-P", str(polling_timeout)]
gt_logger.gt_log_tab("calling mbedhtrun: %s" % " ".join(cmd), print_text=verbose)
gt_logger.gt_log("mbed-host-test-runner: started")
for retry in range(1, 1 + retry_count):
start_time = time()
returncode, htrun_output = run_htrun(cmd, verbose)
end_time = time()
if returncode < 0:
return returncode
elif returncode == 0:
break
gt_logger.gt_log("retry mbedhtrun {}/{}".format(retry, retry_count))
else:
gt_logger.gt_log("{} failed after {} count".format(cmd, retry_count))
testcase_duration = end_time - start_time # Test case duration from reset to {end}
htrun_output = get_printable_string(htrun_output)
result = get_test_result(htrun_output)
result_test_cases = get_testcase_result(htrun_output)
test_cases_summary = get_testcase_summary(htrun_output)
max_heap, reserved_heap, thread_stack_info = get_memory_metrics(htrun_output)
thread_stack_summary = []
if thread_stack_info:
thread_stack_summary = get_thread_stack_info_summary(thread_stack_info)
memory_metrics = {
"max_heap": max_heap,
"reserved_heap": reserved_heap,
"thread_stack_info": thread_stack_info,
"thread_stack_summary": thread_stack_summary
}
get_coverage_data(build_path, htrun_output)
gt_logger.gt_log("mbed-host-test-runner: stopped and returned '%s'"% result, print_text=verbose)
return (result, htrun_output, testcase_duration, duration, result_test_cases, test_cases_summary, memory_metrics)

View File

@ -1,25 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_yotta_api import (
YottaError,
build_with_yotta,
get_platform_name_from_yotta_target,
get_test_spec_from_yt_module,
)

View File

@ -1,23 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
"""
from mbed_os_tools.test.mbed_yotta_module_parse import (
YottaConfig,
YottaModule
)

View File

@ -1,30 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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.
Author: Azim Khan <Azim.Khan@arm.com>
"""
"""
This module contains classes to represent Test Specification interface that defines the data to be generated by/from
a build system to give enough information to Greentea.
"""
from mbed_os_tools.test.tests_spec import (
TestBinary,
Test,
TestBuild,
TestSpec,
)

View File

@ -22,10 +22,9 @@ command line tool instead.
"""
import imp
import importlib
import sys
from optparse import OptionParser
from optparse import SUPPRESS_HELP
from argparse import ArgumentParser, SUPPRESS
from . import host_tests_plugins
from .host_tests_registry import HostRegistry # noqa: F401
from .host_tests import BaseHostTest, event_callback # noqa: F401
@ -52,9 +51,9 @@ def init_host_test_cli_params():
@return Function returns 'options' object returned from OptionParser class
@details Options object later can be used to populate host test selector script.
"""
parser = OptionParser()
parser = ArgumentParser()
parser.add_option(
parser.add_argument(
"-m",
"--micro",
dest="micro",
@ -62,11 +61,11 @@ def init_host_test_cli_params():
metavar="MICRO",
)
parser.add_option(
parser.add_argument(
"-p", "--port", dest="port", help="Serial port of the target", metavar="PORT"
)
parser.add_option(
parser.add_argument(
"-d",
"--disk",
dest="disk",
@ -74,7 +73,7 @@ def init_host_test_cli_params():
metavar="DISK_PATH",
)
parser.add_option(
parser.add_argument(
"-t",
"--target-id",
dest="target_id",
@ -82,8 +81,7 @@ def init_host_test_cli_params():
metavar="TARGET_ID",
)
parser.add_option(
"",
parser.add_argument(
"--sync",
dest="sync_behavior",
default=2,
@ -95,8 +93,7 @@ def init_host_test_cli_params():
metavar="SYNC_BEHAVIOR",
)
parser.add_option(
"",
parser.add_argument(
"--sync-timeout",
dest="sync_timeout",
default=5,
@ -105,7 +102,7 @@ def init_host_test_cli_params():
metavar="SYNC_TIMEOUT",
)
parser.add_option(
parser.add_argument(
"-f",
"--image-path",
dest="image_path",
@ -117,7 +114,7 @@ def init_host_test_cli_params():
host_tests_plugins.get_plugin_caps("CopyMethod")
)
parser.add_option(
parser.add_argument(
"-c",
"--copy",
dest="copy_method",
@ -125,8 +122,7 @@ def init_host_test_cli_params():
metavar="COPY_METHOD",
)
parser.add_option(
"",
parser.add_argument(
"--retry-copy",
dest="retry_copy",
default=3,
@ -135,8 +131,7 @@ def init_host_test_cli_params():
metavar="RETRY_COPY",
)
parser.add_option(
"",
parser.add_argument(
"--tag-filters",
dest="tag_filters",
default="",
@ -152,14 +147,14 @@ def init_host_test_cli_params():
host_tests_plugins.get_plugin_caps("ResetMethod")
)
parser.add_option(
parser.add_argument(
"-r",
"--reset",
dest="forced_reset_type",
help="Forces different type of reset. " + reset_methods_str,
)
parser.add_option(
parser.add_argument(
"-C",
"--program_cycle_s",
dest="program_cycle_s",
@ -168,29 +163,29 @@ def init_host_test_cli_params():
"Program cycle sleep. Define how many seconds you want wait after "
"copying binary onto target (Default is 4 second)"
),
type="float",
type=float,
metavar="PROGRAM_CYCLE_S",
)
parser.add_option(
parser.add_argument(
"-R",
"--reset-timeout",
dest="forced_reset_timeout",
default=1,
metavar="NUMBER",
type="float",
type=float,
help=(
"When forcing a reset using option -r you can set up after reset "
"idle delay in seconds (Default is 1 second)"
),
)
parser.add_option(
parser.add_argument(
"--process-start-timeout",
dest="process_start_timeout",
default=60,
metavar="NUMBER",
type="float",
type=float,
help=(
"This sets the maximum time in seconds to wait for an internal "
"process to start. This mostly only affects machines under heavy "
@ -198,7 +193,7 @@ def init_host_test_cli_params():
),
)
parser.add_option(
parser.add_argument(
"-e",
"--enum-host-tests",
dest="enum_host_tests",
@ -207,15 +202,13 @@ def init_host_test_cli_params():
help="Define directory with local host tests",
)
parser.add_option(
"",
parser.add_argument(
"--test-cfg",
dest="json_test_configuration",
help="Pass to host test class data about host test configuration",
)
parser.add_option(
"",
parser.add_argument(
"--list",
dest="list_reg_hts",
default=False,
@ -223,8 +216,7 @@ def init_host_test_cli_params():
help="Prints registered host test and exits",
)
parser.add_option(
"",
parser.add_argument(
"--plugins",
dest="list_plugins",
default=False,
@ -232,7 +224,7 @@ def init_host_test_cli_params():
help="Prints registered plugins and exits",
)
parser.add_option(
parser.add_argument(
"-g",
"--grm",
dest="global_resource_mgr",
@ -244,17 +236,14 @@ def init_host_test_cli_params():
)
# Show --fm option only if "fm_agent" module installed
fm_help=SUPPRESS
try:
imp.find_module("fm_agent")
except ImportError:
fm_help = SUPPRESS_HELP
else:
fm_help = (
'Fast Model connection, This option requires mbed-fastmodel-agent '
'module installed, list CONFIGs via "mbedfm"'
)
parser.add_option(
"",
if importlib.util.find_spec('fm_agent') is not None:
fm_help='Fast Model connection, This option requires mbed-fastmodel-agent module installed, list CONFIGs via "mbedfm"'
except ModuleNotFoundError:
pass
parser.add_argument(
"--fm",
dest="fast_model_connection",
metavar="CONFIG",
@ -262,8 +251,7 @@ def init_host_test_cli_params():
help=fm_help,
)
parser.add_option(
"",
parser.add_argument(
"--run",
dest="run_binary",
default=False,
@ -271,8 +259,7 @@ def init_host_test_cli_params():
help="Runs binary image on target (workflow: flash, reset, output console)",
)
parser.add_option(
"",
parser.add_argument(
"--skip-flashing",
dest="skip_flashing",
default=False,
@ -280,8 +267,7 @@ def init_host_test_cli_params():
help="Skips use of copy/flash plugin. Note: target will not be reflashed",
)
parser.add_option(
"",
parser.add_argument(
"--skip-reset",
dest="skip_reset",
default=False,
@ -289,20 +275,20 @@ def init_host_test_cli_params():
help="Skips use of reset plugin. Note: target will not be reset",
)
parser.add_option(
parser.add_argument(
"-P",
"--polling-timeout",
dest="polling_timeout",
default=60,
metavar="NUMBER",
type="int",
type=int,
help=(
"Timeout in sec for readiness of mount point and serial port of "
"local or remote device. Default 60 sec"
),
)
parser.add_option(
parser.add_argument(
"-b",
"--send-break",
dest="send_break_cmd",
@ -314,8 +300,7 @@ def init_host_test_cli_params():
),
)
parser.add_option(
"",
parser.add_argument(
"--baud-rate",
dest="baud_rate",
help=(
@ -325,7 +310,7 @@ def init_host_test_cli_params():
metavar="BAUD_RATE",
)
parser.add_option(
parser.add_argument(
"-v",
"--verbose",
dest="verbose",
@ -334,24 +319,21 @@ def init_host_test_cli_params():
help="More verbose mode",
)
parser.add_option(
"",
parser.add_argument(
"--serial-output-file",
dest="serial_output_file",
default=None,
help="Save target serial output to this file.",
)
parser.add_option(
"",
parser.add_argument(
"--compare-log",
dest="compare_log",
default=None,
help="Log file to compare with the serial output from target.",
)
parser.add_option(
"",
parser.add_argument(
"--version",
dest="version",
default=False,
@ -359,8 +341,7 @@ def init_host_test_cli_params():
help="Prints package version and exits",
)
parser.add_option(
"",
parser.add_argument(
"--format",
dest="format",
help="Image file format passed to pyocd (elf, bin, hex, axf...).",
@ -373,10 +354,8 @@ def init_host_test_cli_params():
"""Example: mbedhtrun -d E: -p COM5 -f "test.bin" -C 4 -c shell -m K64F"""
)
(options, _) = parser.parse_args()
if len(sys.argv) == 1:
parser.print_help()
sys.exit()
return options
return parser.parse_args()

View File

@ -17,7 +17,7 @@ import re
from .. import BaseHostTest
class DetectPlatformTest(BaseHostTest):
PATTERN_MICRO_NAME = "Target '(\w+)'"
PATTERN_MICRO_NAME = r"Target '(\w+)'"
re_detect_micro_name = re.compile(PATTERN_MICRO_NAME)
def result(self):

View File

@ -18,7 +18,7 @@ from time import time, strftime, gmtime
from .. import BaseHostTest
class RTCTest(BaseHostTest):
PATTERN_RTC_VALUE = "\[(\d+)\] \[(\d+-\d+-\d+ \d+:\d+:\d+ [AaPpMm]{2})\]"
PATTERN_RTC_VALUE = r"\[(\d+)\] \[(\d+-\d+-\d+ \d+:\d+:\d+ [AaPpMm]{2})\]"
re_detect_rtc_value = re.compile(PATTERN_RTC_VALUE)
__result = None

View File

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import telnetlib
import socket
from .conn_primitive import ConnectorPrimitive, ConnectorPrimitiveException

View File

@ -14,7 +14,6 @@
# limitations under the License.
import re
import pkg_resources
from .host_test_plugins import HostTestPluginBase
@ -35,51 +34,8 @@ class HostTestPluginResetMethod_Mbed(HostTestPluginBase):
'2.7'
"""
HostTestPluginBase.__init__(self)
self.re_float = re.compile("^\d+\.\d+")
pyserial_version = pkg_resources.require("pyserial")[0].version
self.pyserial_version = self.get_pyserial_version(pyserial_version)
self.is_pyserial_v3 = float(self.pyserial_version) >= 3.0
def get_pyserial_version(self, pyserial_version):
"""! Retrieve pyserial module version
@return Returns float with pyserial module number
"""
version = 3.0
m = self.re_float.search(pyserial_version)
if m:
try:
version = float(m.group(0))
except ValueError:
version = 3.0 # We will assume you've got latest (3.0+)
return version
def safe_sendBreak(self, serial):
"""! Closure for pyserial version dependant API calls
"""
if self.is_pyserial_v3:
return self._safe_sendBreak_v3_0(serial)
return self._safe_sendBreak_v2_7(serial)
def _safe_sendBreak_v2_7(self, serial):
"""! pyserial 2.7 API implementation of sendBreak/setBreak
@details
Below API is deprecated for pyserial 3.x versions!
http://pyserial.readthedocs.org/en/latest/pyserial_api.html#serial.Serial.sendBreak
http://pyserial.readthedocs.org/en/latest/pyserial_api.html#serial.Serial.setBreak
"""
result = True
try:
serial.sendBreak()
except:
# In Linux a termios.error is raised in sendBreak and in setBreak.
# The following setBreak() is needed to release the reset signal on the target mcu.
try:
serial.setBreak(False)
except:
result = False
return result
def _safe_sendBreak_v3_0(self, serial):
def _safe_send_break(self, serial):
"""! pyserial 3.x API implementation of send_brea / break_condition
@details
http://pyserial.readthedocs.org/en/latest/pyserial_api.html#serial.Serial.send_break
@ -121,7 +77,7 @@ class HostTestPluginResetMethod_Mbed(HostTestPluginBase):
if kwargs['serial']:
if capability == 'default':
serial = kwargs['serial']
result = self.safe_sendBreak(serial)
result = self._safe_send_break(serial)
return result

View File

@ -117,7 +117,7 @@ class GreenteaCliTestHook(GreenteaTestHook):
result = None
if expandables:
expansion_result = []
m = re.search('\[.*?\]', expr)
m = re.search(r'\[.*?\]', expr)
if m:
expr_str_orig = m.group(0)
expr_str_base = m.group(0)[1:-1]
@ -186,11 +186,11 @@ class LcovHook(GreenteaCliTestHook):
expr = "lcov --gcov-tool gcov [(-a <<./build/{yotta_target_name}/{test_name_list}.info>>)] --output-file result.info"
"""
result = expr
expr_strs_orig = re.findall('\(.*?\)', expr)
expr_strs_orig = re.findall(r'\(.*?\)', expr)
for expr_str_orig in expr_strs_orig:
expr_str_base = expr_str_orig[1:-1]
result = result.replace(expr_str_orig, expr_str_base)
m = re.search('\<<.*?\>>', expr_str_base)
m = re.search(r'\<<.*?\>>', expr_str_base)
if m:
expr_str_path = m.group(0)[2:-2]
# Remove option if file not exists OR if file exists but empty

View File

@ -293,7 +293,7 @@ def get_mbed_targets_from_yotta(mbed_classic_name):
return result
def parse_yotta_search_cmd_output(line):
m = re.search('([\w\d-]+) \d+\.\d+\.\d+[$:]?', line)
m = re.search(r'([\w\d-]+) \d+\.\d+\.\d+[$:]?', line)
if m and len(m.groups()):
yotta_target_name = m.groups()[0]
return yotta_target_name

View File

@ -121,7 +121,7 @@ def run_htrun(cmd, verbose):
# int value > 0 notifies caller that starting of host test process failed
return RUN_HOST_TEST_POPEN_ERROR
htrun_failure_line = re.compile('\[RXD\] (:\d+::FAIL: .*)')
htrun_failure_line = re.compile(r'\[RXD\] (:\d+::FAIL: .*)')
for line in iter(p.stdout.readline, b''):
decoded_line = line.decode("utf-8", "replace")

View File

@ -1,22 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
"""! @package mbed-greentea-test
Unit tests for mbed-greentea test suite
"""

View File

@ -1,35 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import unittest
class BasicTestCase(unittest.TestCase):
""" Basic true asserts to see that testing is executed
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_example(self):
self.assertEqual(True, True)
self.assertNotEqual(True, False)
if __name__ == '__main__':
unittest.main()

View File

@ -1,151 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import six
import sys
import unittest
from mbed_greentea import mbed_greentea_cli
from mbed_greentea.tests_spec import TestSpec
test_spec_def = {
"builds": {
"K64F-ARM": {
"platform": "K64F",
"toolchain": "ARM",
"base_path": "./.build/K64F/ARM",
"baud_rate": 115200,
"tests": {
"mbed-drivers-test-generic_tests":{
"binaries":[
{
"binary_type": "bootable",
"path": "./.build/K64F/ARM/mbed-drivers-test-generic_tests.bin"
}
]
},
"mbed-drivers-test-c_strings":{
"binaries":[
{
"binary_type": "bootable",
"path": "./.build/K64F/ARM/mbed-drivers-test-c_strings.bin"
}
]
}
}
}
}
}
class GreenteaCliFunctionality(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_get_greentea_version(self):
version = mbed_greentea_cli.get_greentea_version()
self.assertIs(type(version), str)
version_list = version.split('.')
self.assertEqual(version_list[0].isdigit(), True)
self.assertEqual(version_list[1].isdigit(), True)
self.assertEqual(version_list[2].isdigit(), True)
def test_print_version(self):
version = mbed_greentea_cli.get_greentea_version()
old_stdout = sys.stdout
sys.stdout = stdout_capture = six.StringIO()
mbed_greentea_cli.print_version()
sys.stdout = old_stdout
printed_version = stdout_capture.getvalue().splitlines()[0]
self.assertEqual(printed_version, version)
def test_get_hello_string(self):
version = mbed_greentea_cli.get_greentea_version()
hello_string = mbed_greentea_cli.get_hello_string()
self.assertIs(type(version), str)
self.assertIs(type(hello_string), str)
self.assertIn(version, hello_string)
def test_get_local_host_tests_dir_invalid_path(self):
test_path = mbed_greentea_cli.get_local_host_tests_dir("invalid-path")
self.assertEqual(test_path, None)
def test_get_local_host_tests_dir_valid_path(self):
path = "."
test_path = mbed_greentea_cli.get_local_host_tests_dir(path)
self.assertEqual(test_path, path)
def test_get_local_host_tests_dir_default_path(self):
import os
import shutil
import tempfile
curr_dir = os.getcwd()
test1_dir = tempfile.mkdtemp()
test2_dir = os.mkdir(os.path.join(test1_dir, "test"))
test3_dir = os.mkdir(os.path.join(test1_dir, "test", "host_tests"))
os.chdir(test1_dir)
test_path = mbed_greentea_cli.get_local_host_tests_dir("")
self.assertEqual(test_path, "./test/host_tests")
os.chdir(curr_dir)
shutil.rmtree(test1_dir)
def test_create_filtered_test_list(self):
test_spec = TestSpec()
test_spec.parse(test_spec_def)
test_build = test_spec.get_test_builds()[0]
test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
'mbed-drivers-test-generic_*',
None,
test_spec=test_spec)
self.assertEqual(set(test_list.keys()), set(['mbed-drivers-test-generic_tests']))
test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
'*_strings',
None,
test_spec=test_spec)
self.assertEqual(set(test_list.keys()), set(['mbed-drivers-test-c_strings']))
test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
'mbed*s',
None,
test_spec=test_spec)
expected = set(['mbed-drivers-test-c_strings', 'mbed-drivers-test-generic_tests'])
self.assertEqual(set(test_list.keys()), expected)
test_list = mbed_greentea_cli.create_filtered_test_list(test_build.get_tests(),
'*-drivers-*',
None,
test_spec=test_spec)
expected = set(['mbed-drivers-test-c_strings', 'mbed-drivers-test-generic_tests'])
self.assertEqual(set(test_list.keys()), expected)
if __name__ == '__main__':
unittest.main()

View File

@ -1,147 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import os
import mock
import six
import sys
import unittest
from mbed_greentea import cmake_handlers, tests_spec
class GreenteaCmakeHandlers(unittest.TestCase):
""" Basic true asserts to see that testing is executed
"""
def setUp(self):
self.ctesttestfile = """# CMake generated Testfile for
# Source directory: c:/Work2/mbed-client/test
# Build directory: c:/Work2/mbed-client/build/frdm-k64f-gcc/test
#
# This file includes the relevant testing commands required for
# testing this directory and lists subdirectories to be tested as well.
add_test(mbed-client-test-mbedclient-smokeTest "mbed-client-test-mbedclient-smokeTest")
add_test(mbed-client-test-helloworld-mbedclient "mbed-client-test-helloworld-mbedclient")
"""
def tearDown(self):
pass
def test_example(self):
self.assertEqual(True, True)
self.assertNotEqual(True, False)
def test_parse_ctesttestfile_line(self):
LINK_TARGET = '/dir/to/target'
BINARY_TYPE = '.bin'
result = {}
no_skipped_lines = 0
for line in self.ctesttestfile.splitlines():
line_parse = cmake_handlers.parse_ctesttestfile_line(LINK_TARGET, BINARY_TYPE, line, verbose=True)
if line_parse:
test_case, test_case_path = line_parse
result[test_case] = test_case_path
else:
no_skipped_lines += 1
self.assertIn('mbed-client-test-mbedclient-smokeTest', result)
self.assertIn('mbed-client-test-helloworld-mbedclient', result)
for test_case, test_case_path in result.items():
self.assertEqual(test_case_path.startswith(LINK_TARGET), True)
self.assertEqual(test_case_path.endswith(BINARY_TYPE), True)
self.assertEqual(len(result), 2) # We parse two entries
self.assertEqual(no_skipped_lines, 6) # We skip six lines in this file
def test_load_ctest_testsuite_missing_link_target(self):
null_link_target = None
null_suite = cmake_handlers.load_ctest_testsuite(null_link_target)
self.assertEqual(null_suite, {})
def test_load_ctest_testsuite(self):
root_path = os.path.dirname(os.path.realpath(__file__))
emty_path = os.path.join(root_path, "resources", "empty")
full_path = os.path.join(root_path, "resources", "not-empty")
# Empty LINK_TARGET
empty_link_target = emty_path
empty_suite = cmake_handlers.load_ctest_testsuite(empty_link_target)
self.assertEqual(empty_suite, {})
# Not empty LINK_TARGET
link_target = full_path
test_suite = cmake_handlers.load_ctest_testsuite(link_target)
self.assertIsNotNone(test_suite)
self.assertIn('mbed-client-test-mbedclient-smokeTest', test_suite)
self.assertIn('mbed-client-test-helloworld-mbedclient', test_suite)
def test_list_binaries_for_targets(self):
root_path = os.path.dirname(os.path.realpath(__file__))
null_path = os.path.join(root_path, "resources", "empty", "test")
full_path = os.path.join(root_path, "resources")
def run_and_capture(path, verbose=False):
old_stdout = sys.stdout
sys.stdout = stdout_capture = six.StringIO()
cmake_handlers.list_binaries_for_targets(build_dir=path, verbose_footer=verbose)
sys.stdout = old_stdout
return stdout_capture.getvalue()
# Test empty target directory
output = run_and_capture(null_path)
self.assertTrue("no tests found in current location" in output)
# Test empty target directory (Verbose output)
output = run_and_capture(null_path, verbose=True)
self.assertTrue("no tests found in current location" in output)
self.assertTrue("Example: execute 'mbedgt -t TARGET_NAME -n TEST_NAME' to run test TEST_NAME for target TARGET_NAME" in output)
# Test non-empty target directory
output = run_and_capture(full_path)
self.assertTrue("available tests for target" in output)
def test_list_binaries_for_builds(self):
root_path = os.path.dirname(os.path.realpath(__file__))
spec_path = os.path.join(root_path, "resources", "test_spec.json")
spec = tests_spec.TestSpec(spec_path)
for verbose in [True, False]:
# Capture logging output
old_stdout = sys.stdout
sys.stdout = stdout_capture = six.StringIO()
cmake_handlers.list_binaries_for_builds(spec, verbose_footer=verbose)
sys.stdout = old_stdout
output = stdout_capture.getvalue()
self.assertTrue("available tests for build 'K64F-ARM'" in output)
self.assertTrue("available tests for build 'K64F-GCC'" in output)
self.assertTrue("tests-example-1" in output)
self.assertTrue("tests-example-2" in output)
self.assertTrue("tests-example-7" in output)
if verbose == True:
self.assertTrue("Example: execute" in output)
if __name__ == '__main__':
unittest.main()

View File

@ -1,63 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import os
import unittest
from mbed_greentea import mbed_coverage_api
class GreenteaCoverageAPI(unittest.TestCase):
def setUp(self):
pass
def test_x(self):
pass
def test_coverage_pack_hex_payload(self):
# This function takesstring as input
r = mbed_coverage_api.coverage_pack_hex_payload('')
self.assertEqual(bytearray(b''), r)
r = mbed_coverage_api.coverage_pack_hex_payload('6164636772')
self.assertEqual(bytearray(b'adcgr'), r)
r = mbed_coverage_api.coverage_pack_hex_payload('.') # '.' -> 0x00
self.assertEqual(bytearray(b'\x00'), r)
r = mbed_coverage_api.coverage_pack_hex_payload('...') # '.' -> 0x00
self.assertEqual(bytearray(b'\x00\x00\x00'), r)
r = mbed_coverage_api.coverage_pack_hex_payload('.6164636772.') # '.' -> 0x00
self.assertEqual(bytearray(b'\x00adcgr\x00'), r)
def test_coverage_dump_file_valid(self):
import tempfile
payload = bytearray(b'PAYLOAD')
handle, path = tempfile.mkstemp("test_file")
mbed_coverage_api.coverage_dump_file(".", path, payload)
with open(path, 'r') as f:
read_data = f.read()
self.assertEqual(read_data, payload.decode("utf-8", "ignore"))
os.close(handle)
os.remove(path)
if __name__ == '__main__':
unittest.main()

View File

@ -1,142 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2017 ARM Limited
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.
"""
import os
import six
import sys
import tempfile
import unittest
from lockfile import LockFile
from mock import patch
from mbed_greentea import mbed_greentea_dlm
class GreenteaDlmFunctionality(unittest.TestCase):
def setUp(self):
temp_dir = tempfile.mkdtemp()
self.home_tools_patch = patch('mbed_os_tools.test.mbed_greentea_dlm.HOME_DIR', temp_dir)
self.home_local_patch = patch('mbed_greentea.mbed_greentea_dlm.HOME_DIR', temp_dir)
kettle_dir = os.path.join(temp_dir, mbed_greentea_dlm.GREENTEA_HOME_DIR, mbed_greentea_dlm.GREENTEA_KETTLE)
self.kettle_tools_patch = patch('mbed_os_tools.test.mbed_greentea_dlm.GREENTEA_KETTLE_PATH', kettle_dir)
self.kettle_local_patch = patch('mbed_greentea.mbed_greentea_dlm.GREENTEA_KETTLE_PATH', kettle_dir)
self.home_tools_patch.start()
self.home_local_patch.start()
self.kettle_tools_patch.start()
self.kettle_local_patch.start()
def tearDown(self):
self.home_tools_patch.stop()
self.home_local_patch.stop()
self.kettle_tools_patch.stop()
self.kettle_local_patch.stop()
def test_greentea_home_dir_init(self):
mbed_greentea_dlm.greentea_home_dir_init()
path = os.path.join(mbed_greentea_dlm.HOME_DIR, mbed_greentea_dlm.GREENTEA_HOME_DIR)
self.assertTrue(os.path.exists(path))
def test_greentea_get_app_sem(self):
sem, name, uuid = mbed_greentea_dlm.greentea_get_app_sem()
self.assertIsNotNone(sem)
self.assertIsNotNone(name)
self.assertIsNotNone(uuid)
def test_greentea_get_target_lock(self):
lock = mbed_greentea_dlm.greentea_get_target_lock("target-id-2")
path = os.path.join(mbed_greentea_dlm.HOME_DIR, mbed_greentea_dlm.GREENTEA_HOME_DIR, "target-id-2")
self.assertIsNotNone(lock)
self.assertEqual(path, lock.path)
def test_greentea_get_global_lock(self):
lock = mbed_greentea_dlm.greentea_get_global_lock()
path = os.path.join(mbed_greentea_dlm.HOME_DIR, mbed_greentea_dlm.GREENTEA_HOME_DIR, "glock.lock")
self.assertIsNotNone(lock)
self.assertEqual(path, lock.path)
def test_get_json_data_from_file_invalid_file(self):
result = mbed_greentea_dlm.get_json_data_from_file("null_file")
self.assertIsNone(result)
def test_get_json_data_from_file_invalid_json(self):
path = os.path.join(mbed_greentea_dlm.HOME_DIR, "test")
with open(path, "w") as f:
f.write("invalid json")
result = mbed_greentea_dlm.get_json_data_from_file(path)
self.assertEqual(result, None)
os.remove(path)
def test_get_json_data_from_file_valid_file(self):
path = os.path.join(mbed_greentea_dlm.HOME_DIR, "test")
with open(path, "w") as f:
f.write("{}")
result = mbed_greentea_dlm.get_json_data_from_file(path)
self.assertEqual(result, {})
os.remove(path)
def test_greentea_update_kettle(self):
uuid = "001"
mbed_greentea_dlm.greentea_update_kettle(uuid)
data = mbed_greentea_dlm.get_json_data_from_file(mbed_greentea_dlm.GREENTEA_KETTLE_PATH)
self.assertIsNotNone(data)
self.assertIn("start_time", data[uuid])
self.assertIn("cwd", data[uuid])
self.assertIn("locks", data[uuid])
self.assertEqual(data[uuid]["cwd"], os.getcwd())
self.assertEqual(data[uuid]["locks"], [])
# Check greentea_kettle_info()
output = mbed_greentea_dlm.greentea_kettle_info().splitlines()
line = output[3]
self.assertIn(os.getcwd(), line)
self.assertIn(uuid, line)
# Test greentea_acquire_target_id
target_id = "999"
mbed_greentea_dlm.greentea_acquire_target_id(target_id, uuid)
data = mbed_greentea_dlm.get_json_data_from_file(mbed_greentea_dlm.GREENTEA_KETTLE_PATH)
self.assertIn(uuid, data)
self.assertIn("locks", data[uuid])
self.assertIn(target_id, data[uuid]["locks"])
# Test greentea_release_target_id
mbed_greentea_dlm.greentea_release_target_id(target_id, uuid)
data = mbed_greentea_dlm.get_json_data_from_file(mbed_greentea_dlm.GREENTEA_KETTLE_PATH)
self.assertIn(uuid, data)
self.assertIn("locks", data[uuid])
self.assertNotIn(target_id, data[uuid]["locks"])
# Test greentea_acquire_target_id_from_list
target_id = "999"
result = mbed_greentea_dlm.greentea_acquire_target_id_from_list([target_id], uuid)
data = mbed_greentea_dlm.get_json_data_from_file(mbed_greentea_dlm.GREENTEA_KETTLE_PATH)
self.assertEqual(result, target_id)
self.assertIn(uuid, data)
self.assertIn("locks", data[uuid])
self.assertIn(target_id, data[uuid]["locks"])
# Check greentea_clean_kettle()
mbed_greentea_dlm.greentea_clean_kettle(uuid)
data = mbed_greentea_dlm.get_json_data_from_file(mbed_greentea_dlm.GREENTEA_KETTLE_PATH)
self.assertEqual(data, {})

View File

@ -1,141 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import six
import sys
import unittest
from mock import patch
from mbed_greentea.mbed_greentea_hooks import GreenteaCliTestHook
from mbed_greentea.mbed_greentea_hooks import LcovHook
class GreenteaCliTestHookTest(unittest.TestCase):
def setUp(self):
self.cli_hooks = GreenteaCliTestHook('test_hook', 'some command')
self.lcov_hooks = LcovHook('test_hook', 'some command')
def tearDown(self):
pass
def test_format_before_run(self):
command = LcovHook.format_before_run("command {expansion}", None, verbose=True)
self.assertEqual(command, "command {expansion}")
expansions = ["test", "test2"]
command = LcovHook.format_before_run("command {expansion}", {"expansion": expansions}, verbose=True)
self.assertEqual(command, "command ['test', 'test2']")
def test_expand_parameters_with_1_list(self):
# Simple list
self.assertEqual('new_value_1 new_value_2',
self.cli_hooks.expand_parameters('[{token_list}]', {
"token_list" : ['new_value_1', 'new_value_2']
}))
# List with prefix
self.assertEqual('-a new_value_1 -a new_value_2',
self.cli_hooks.expand_parameters('[-a {token_list}]', {
"token_list" : ['new_value_1', 'new_value_2']
}))
# List with prefix and extra text
self.assertEqual('-a /path/to/new_value_1 -a /path/to/new_value_2',
self.cli_hooks.expand_parameters('[-a /path/to/{token_list}]', {
"token_list" : ['new_value_1', 'new_value_2']
}))
def test_expand_parameters_with_2_lists(self):
self.assertEqual('ytA T1',
self.cli_hooks.expand_parameters('[{yt_target_list} {test_list}]', {
"test_list" : ['T1'],
"yt_target_list" : ['ytA'],
}))
self.assertEqual('ytA T1 ytA T2 ytA T3 ytB T1 ytB T2 ytB T3 ytC T1 ytC T2 ytC T3',
self.cli_hooks.expand_parameters('[{yt_target_list} {test_list}]', {
"test_list" : ['T1', 'T2', 'T3'],
"yt_target_list" : ['ytA', 'ytB', 'ytC'],
}))
# In this test we expect {yotta_target_name} token to stay untouched because it is not declared as a list
self.assertEqual('lcov -a /build/{yotta_target_name}/mbed-drivers-test-basic.info -a /build/{yotta_target_name}/mbed-drivers-test-hello.info',
self.cli_hooks.expand_parameters('lcov [-a /build/{yotta_target_name}/{test_list}.info]', {
"test_list" : ['mbed-drivers-test-basic', 'mbed-drivers-test-hello'],
"yotta_target_name" : 'frdm-k64f-gcc'
}))
def test_expand_parameters_exceptions(self):
# Here [] is reduced to empty string
self.assertEqual('',
self.cli_hooks.expand_parameters('[]', {
"test_list" : ['mbed-drivers-test-basic', 'mbed-drivers-test-hello'],
"yotta_target_name" : 'frdm-k64f-gcc'
}))
# Here [some string] is reduced to empty string
self.assertEqual('',
self.cli_hooks.expand_parameters('[some string]', {
"test_list" : ['mbed-drivers-test-basic', 'mbed-drivers-test-hello'],
"yotta_target_name" : 'frdm-k64f-gcc'
}))
# Here [some string] is reduced to empty string
self.assertEqual('-+=abc',
self.cli_hooks.expand_parameters('-+=[some string]abc', {
"test_list" : ['mbed-drivers-test-basic', 'mbed-drivers-test-hello'],
"yotta_target_name" : 'frdm-k64f-gcc'
}))
self.assertEqual(None,
self.cli_hooks.expand_parameters('some text without square brackets but with tokes: {test_list} and {yotta_target_name}', {
"test_list" : ['mbed-drivers-test-basic', 'mbed-drivers-test-hello'],
"yotta_target_name" : 'frdm-k64f-gcc'
}))
def test_format_before_run_with_1_list_1_string(self):
# {test_name_list} should expand [] list twice
# {yotta_target_name} should not be used to expand, only to replace
self.assertEqual('build path = -a /build/frdm-k64f-gcc/mbed-drivers-test-basic -a /build/frdm-k64f-gcc/mbed-drivers-test-hello',
self.cli_hooks.format_before_run('build path = [-a /build/{yotta_target_name}/{test_name_list}]', {
"test_name_list" : ['mbed-drivers-test-basic', 'mbed-drivers-test-hello'],
"yotta_target_name" : 'frdm-k64f-gcc',
}))
@patch('os.path.exists')
@patch('os.path.getsize')
def test_check_if_file_exists(self, pathGetsize_mock, pathExists_mock):
pathExists_mock.return_value = True
self.assertEqual('-a ./build/frdm-k64f-gcc.info',
self.lcov_hooks.check_if_file_exists_or_is_empty('(-a <<./build/frdm-k64f-gcc.info>>)'))
pathExists_mock.return_value = False
self.assertEqual('',
self.lcov_hooks.check_if_file_exists_or_is_empty('(-a <<./build/frdm-k64f-gcc.info>>)'))
@patch('os.path.exists')
@patch('os.path.getsize')
def test_check_if_file_is_empty(self, pathGetsize_mock, pathExists_mock):
pathExists_mock.return_value = True
pathGetsize_mock.return_value = 1
self.assertEqual('-a ./build/frdm-k64f-gcc.info',
self.lcov_hooks.check_if_file_exists_or_is_empty('(-a <<./build/frdm-k64f-gcc.info>>)'))
pathExists_mock.return_value = True
pathGetsize_mock.return_value = 0
self.assertEqual('',
self.lcov_hooks.check_if_file_exists_or_is_empty('(-a <<./build/frdm-k64f-gcc.info>>)'))
if __name__ == '__main__':
unittest.main()

View File

@ -1,175 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import json
import os
import six
import sys
import tempfile
import unittest
from mock import patch
from mbed_greentea import mbed_report_api
class GreenteaReportApiFunctionality(unittest.TestCase):
def setUp(self):
self.test_case_data = {
"K64F-ARM": {
"suite": {
"testcase_result": {
"case-1": {
"duration": 1.00,
"time_start": 2.00,
"time_end": 3.00,
"result_text": "FAIL",
"passed": 10,
"failed": 10
},
"case-2": {
"duration": 1.00,
"time_start": 2.00,
"time_end": 3.00,
"result_text": "SKIPPED",
"passed": 10,
"failed": 10
},
"case-3": {
"duration": 1.00,
"time_start": 2.00,
"time_end": 3.00,
"result_text": "?",
"passed": 10,
"failed": 10
},
},
"single_test_output": "OK",
"platform_name": "K64F"
}
}
}
self.test_suite_data = {
"K64F-ARM": {
"test-1": {
"testcase_result": {
"build_path": ".."
},
"single_test_output": "OK",
"single_test_result": "OK",
"platform_name": "K64F",
"elapsed_time": 1.2,
"copy_method": "shell"
},
"test-2": {
"testcase_result": {
"build_path": ".."
},
"single_test_output": "OK",
"single_test_result": "OK",
"platform_name": "K64F",
"elapsed_time": 1.2,
"copy_method": "shell"
}
},
"N32F-ARM": {
"test-3": {
"testcase_result": {
"build_path": ".."
},
"single_test_output": "OK",
"single_test_result": "OK",
"platform_name": "N32F",
"elapsed_time": 1.2,
"copy_method": "shell"
}
}
}
def tearDown(self):
pass
def test_export_to_file(self):
# Invalid filepath
payload = "PAYLOAD"
filepath = "."
old_stdout = sys.stdout
sys.stdout = stdout_capture = six.StringIO()
result = mbed_report_api.export_to_file(filepath, payload)
sys.stdout = old_stdout
command_output = stdout_capture.getvalue().splitlines()[0]
self.assertIn("file failed:", command_output)
self.assertEqual(result, False)
# Valid filepath
temp_file = tempfile.mkstemp("test_file")
result = mbed_report_api.export_to_file(temp_file[1], payload)
self.assertTrue(result)
with open(temp_file[1], 'r') as f:
read_data = f.read()
self.assertEqual(read_data, payload)
os.close(temp_file[0])
os.remove(temp_file[1])
def test_exporter_text(self):
result, result_ = mbed_report_api.exporter_text(self.test_suite_data)
lines = result.splitlines()
self.assertIn("target", lines[0])
self.assertIn("platform_name", lines[0])
self.assertIn("test suite", lines[0])
self.assertIn("result", lines[0])
self.assertIn("K64F", lines[2])
self.assertIn("test-1", lines[2])
self.assertIn("test-2", lines[3])
self.assertIn("test-3", lines[4])
self.assertIn("OK", lines[2])
def test_exporter_testcase_test(self):
result, result_ = mbed_report_api.exporter_testcase_text(self.test_case_data)
lines = result.splitlines()
self.assertIn("target", lines[0])
self.assertIn("platform_name", lines[0])
self.assertIn("test suite", lines[0])
self.assertIn("result", lines[0])
line = lines[2]
self.assertIn("K64F-ARM", line)
self.assertIn("suite", line)
self.assertIn("case-1", line)
def test_exporter_testcase_junit(self):
result = mbed_report_api.exporter_testcase_junit(self.test_case_data)
self.assertIsNotNone(result)
from xml.etree import ElementTree as ET
xml = ET.fromstring(result)
self.assertEqual(xml.tag, "testsuites")
self.assertEqual(xml.attrib["failures"], "1")
self.assertEqual(xml.attrib["tests"], "3")
self.assertEqual(xml.attrib["errors"], "1")
self.assertEqual(xml.attrib["time"], "3.0")
child = xml[0]
self.assertEqual(child.tag, "testsuite")
self.assertEqual(child.attrib["failures"], "1")
self.assertEqual(child.attrib["tests"], "3")
self.assertEqual(child.attrib["errors"], "1")
self.assertEqual(child.attrib["time"], "3.0")

View File

@ -1,434 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import os
import shutil
import tempfile
import unittest
from six import StringIO
from mock import patch
from mbed_greentea import mbed_target_info
class GreenteaTargetInfo(unittest.TestCase):
def setUp(self):
self.YOTTA_SEARCH_SSL_ISSUE = """/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
frdm-k64f-gcc 0.0.24: Official mbed build target for the mbed frdm-k64f development board.
frdm-k64f-armcc 0.0.16: Official mbed build target for the mbed frdm-k64f development board, using the armcc toolchain.
/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
"""
def tearDown(self):
pass
def test_parse_yotta_target_cmd_output_mixed_chars(self):
self.assertIn("m", mbed_target_info.parse_yotta_target_cmd_output("m 0.0.0"))
self.assertIn("m", mbed_target_info.parse_yotta_target_cmd_output(" m 0.0.0"))
self.assertIn("aaaaaaaaaaaaa", mbed_target_info.parse_yotta_target_cmd_output("aaaaaaaaaaaaa 0.0.0"))
self.assertIn("aaaa-bbbb-cccc", mbed_target_info.parse_yotta_target_cmd_output("aaaa-bbbb-cccc 0.0.0"))
self.assertIn("aBc-DEF_hijkkk", mbed_target_info.parse_yotta_target_cmd_output("aBc-DEF_hijkkk 0.0.0"))
def test_parse_yotta_target_cmd_output_mixed_version(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.0"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 1.1.1"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 1.1.12"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 1.1.123"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 11.22.33"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.1"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.10.12"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.20.123"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.2.123"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 10.20.123"))
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 110.200.123"))
def test_parse_yotta_target_cmd_output(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.24"))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-armcc 1.12.3"))
self.assertIn("mbed-gcc", mbed_target_info.parse_yotta_target_cmd_output("mbed-gcc 0.0.14"))
self.assertIn("stm32f429i-disco-gcc", mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 0.0.14"))
def test_parse_yotta_target_cmd_output_mixed_whitechars(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.24 "))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-armcc 1.12.3 "))
self.assertIn("mbed-gcc", mbed_target_info.parse_yotta_target_cmd_output("mbed-gcc 0.0.14 "))
self.assertIn("stm32f429i-disco-gcc", mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 0.0.14 "))
def test_parse_yotta_target_cmd_output_mixed_nl(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.24\n"))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-armcc 1.12.3\n"))
self.assertIn("mbed-gcc", mbed_target_info.parse_yotta_target_cmd_output("mbed-gcc 0.0.14\n"))
self.assertIn("stm32f429i-disco-gcc", mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 0.0.14\n"))
def test_parse_yotta_target_cmd_output_mixed_rcnl(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.24\r\n"))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-armcc 1.12.3\r\n"))
self.assertIn("mbed-gcc", mbed_target_info.parse_yotta_target_cmd_output("mbed-gcc 0.0.14\r\n"))
self.assertIn("stm32f429i-disco-gcc", mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 11.222.333\r\n"))
def test_parse_yotta_target_cmd_output_mixed_nl_whitechars(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.24 \n"))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-armcc 1.12.3 \n"))
self.assertIn("mbed-gcc", mbed_target_info.parse_yotta_target_cmd_output("mbed-gcc 0.0.14 \n"))
self.assertIn("stm32f429i-disco-gcc", mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 0.0.14 \n"))
def test_parse_yotta_target_cmd_output_mixed_rcnl_whitechars(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-gcc 0.0.24 \r\n"))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_target_cmd_output("frdm-k64f-armcc 1.12.3 \r\n"))
self.assertIn("mbed-gcc", mbed_target_info.parse_yotta_target_cmd_output("mbed-gcc 0.0.14 \r\n"))
self.assertIn("stm32f429i-disco-gcc", mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 0.0.14 \r\n"))
def test_parse_yotta_target_cmd_output_fail(self):
self.assertEqual(None, mbed_target_info.parse_yotta_target_cmd_output(""))
self.assertEqual(None, mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 1"))
self.assertEqual(None, mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 1."))
self.assertEqual(None, mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 1.0"))
self.assertEqual(None, mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 1.0."))
self.assertEqual(None, mbed_target_info.parse_yotta_target_cmd_output("stm32f429i-disco-gcc 1.0.x"))
def test_parse_yotta_search_cmd_output(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_search_cmd_output("frdm-k64f-gcc 0.0.24: Official mbed build target for the mbed frdm-k64f development board."))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_search_cmd_output("frdm-k64f-armcc 0.0.16: Official mbed build target for the mbed frdm-k64f development board, using the armcc toolchain."))
self.assertEqual(None, mbed_target_info.parse_yotta_search_cmd_output(""))
self.assertEqual(None, mbed_target_info.parse_yotta_search_cmd_output("additional results from https://yotta-private.herokuapp.com:"))
def test_parse_yotta_search_cmd_output_text(self):
# Old style with new switch --short : 'yotta search ... --short'
text = """frdm-k64f-gcc 0.1.4: Official mbed build target for the mbed frdm-k64f development board.
frdm-k64f-armcc 0.1.3: Official mbed build target for the mbed frdm-k64f development board, using the armcc toolchain.
additional results from https://yotta-private.herokuapp.com:
"""
targets = []
for line in text.splitlines():
yotta_target_name = mbed_target_info.parse_yotta_search_cmd_output(line)
if yotta_target_name:
targets.append(yotta_target_name)
self.assertIn("frdm-k64f-gcc", targets)
self.assertIn("frdm-k64f-armcc", targets)
self.assertEqual(2, len(targets))
def test_parse_yotta_search_cmd_output_new_style(self):
self.assertIn("frdm-k64f-gcc", mbed_target_info.parse_yotta_search_cmd_output("frdm-k64f-gcc 0.1.4"))
self.assertIn("frdm-k64f-armcc", mbed_target_info.parse_yotta_search_cmd_output("frdm-k64f-armcc 0.1.4"))
pass
def test_parse_yotta_search_cmd_output_new_style_text(self):
# New style of 'yotta search ...'
text = """frdm-k64f-gcc 0.1.4
Official mbed build target for the mbed frdm-k64f development board.
mbed-target:k64f, mbed-official, k64f, frdm-k64f, gcc
frdm-k64f-armcc 0.1.4
Official mbed build target for the mbed frdm-k64f development board, using the armcc toolchain.
mbed-target:k64f, mbed-official, k64f, frdm-k64f, armcc
additional results from https://yotta-private.herokuapp.com:"""
targets = []
for line in text.splitlines():
yotta_target_name = mbed_target_info.parse_yotta_search_cmd_output(line)
if yotta_target_name:
targets.append(yotta_target_name)
self.assertIn("frdm-k64f-gcc", targets)
self.assertIn("frdm-k64f-armcc", targets)
self.assertEqual(2, len(targets))
def test_parse_yotta_search_cmd_output_new_style_text_2(self):
# New style of 'yotta search ...'
text = """nrf51dk-gcc 0.0.3:
Official mbed build target for the nRF51-DK 32KB platform.
mbed-official, mbed-target:nrf51_dk, gcc
additional results from https://yotta-private.herokuapp.com:
nrf51dk-gcc 0.0.3:
Official mbed build target for the nRF51-DK 32KB platform.
mbed-official, mbed-target:nrf51_dk, gcc
nrf51dk-armcc 0.0.3:
Official mbed build target for the nRF51-DK 32KB platform.
mbed-official, mbed-target:nrf51_dk, armcc
"""
targets = []
for line in text.splitlines():
yotta_target_name = mbed_target_info.parse_yotta_search_cmd_output(line)
if yotta_target_name and yotta_target_name not in targets:
targets.append(yotta_target_name)
self.assertIn("nrf51dk-gcc", targets)
self.assertIn("nrf51dk-armcc", targets)
self.assertEqual(2, len(targets))
def test_parse_yotta_search_cmd_output_with_ssl_errors(self):
result = []
for line in self.YOTTA_SEARCH_SSL_ISSUE.splitlines():
yotta_target_name = mbed_target_info.parse_yotta_search_cmd_output(line)
if yotta_target_name:
result.append(yotta_target_name)
self.assertIn("frdm-k64f-gcc", result)
self.assertIn("frdm-k64f-armcc", result)
self.assertEqual(2, len(result))
def test_parse_mbed_target_from_target_json_no_keywords(self):
target_json_data = {
"name": "frdm-k64f-armcc",
"version": "0.1.4",
}
self.assertIsNone(mbed_target_info.parse_mbed_target_from_target_json('k64f', target_json_data))
self.assertIsNone(mbed_target_info.parse_mbed_target_from_target_json('K64F', target_json_data))
def test_parse_mbed_target_from_target_json_no_name(self):
target_json_data = {
"version": "0.1.4",
"keywords": [
"mbed-target:k64f",
"mbed-target::garbage",
"mbed-official",
"k64f",
"frdm-k64f",
"armcc"
],
}
self.assertIsNone(mbed_target_info.parse_mbed_target_from_target_json('k64f', target_json_data))
self.assertIsNone(mbed_target_info.parse_mbed_target_from_target_json('K64F', target_json_data))
def test_parse_mbed_target_from_target_json(self):
target_json_data = {
"name": "frdm-k64f-armcc",
"version": "0.1.4",
"keywords": [
"mbed-target:k64f",
"mbed-target::garbage",
"mbed-official",
"k64f",
"frdm-k64f",
"armcc"
],
}
# Positive tests
self.assertEqual('frdm-k64f-armcc', mbed_target_info.parse_mbed_target_from_target_json('k64f', target_json_data))
self.assertEqual('frdm-k64f-armcc', mbed_target_info.parse_mbed_target_from_target_json('K64F', target_json_data))
# Except cases
self.assertNotEqual('frdm-k64f-gcc', mbed_target_info.parse_mbed_target_from_target_json('k64f', target_json_data))
self.assertNotEqual('frdm-k64f-gcc', mbed_target_info.parse_mbed_target_from_target_json('K64F', target_json_data))
self.assertEqual(None, mbed_target_info.parse_mbed_target_from_target_json('_k64f_', target_json_data))
self.assertEqual(None, mbed_target_info.parse_mbed_target_from_target_json('', target_json_data))
self.assertEqual(None, mbed_target_info.parse_mbed_target_from_target_json('Some board name', target_json_data))
def test_parse_mbed_target_from_target_json_multiple(self):
target_json_data = {
"name": "frdm-k64f-armcc",
"version": "0.1.4",
"keywords": [
"mbed-target:k64f",
"mbed-target:frdm-k64f",
"mbed-official",
"k64f",
"frdm-k64f",
"armcc"
],
}
# Positive tests
self.assertEqual('frdm-k64f-armcc', mbed_target_info.parse_mbed_target_from_target_json('k64f', target_json_data))
self.assertEqual('frdm-k64f-armcc', mbed_target_info.parse_mbed_target_from_target_json('frdm-k64f', target_json_data))
self.assertEqual('frdm-k64f-armcc', mbed_target_info.parse_mbed_target_from_target_json('K64F', target_json_data))
self.assertEqual('frdm-k64f-armcc', mbed_target_info.parse_mbed_target_from_target_json('FRDM-K64F', target_json_data))
# Except cases
self.assertNotEqual('frdm-k64f-gcc', mbed_target_info.parse_mbed_target_from_target_json('k64f', target_json_data))
self.assertNotEqual('frdm-k64f-gcc', mbed_target_info.parse_mbed_target_from_target_json('frdm-k64f', target_json_data))
self.assertNotEqual('frdm-k64f-gcc', mbed_target_info.parse_mbed_target_from_target_json('K64F', target_json_data))
self.assertNotEqual('frdm-k64f-gcc', mbed_target_info.parse_mbed_target_from_target_json('FRDM-K64F', target_json_data))
@patch('mbed_os_tools.test.mbed_target_info.get_mbed_target_call_yotta_target')
def test_get_mbed_target_from_current_dir_ok(self, callYtTarget_mock):
yotta_target_cmd = """frdm-k64f-gcc 2.0.0
kinetis-k64-gcc 2.0.2
mbed-gcc 1.1.0
"""
callYtTarget_mock.return_value = ('', '', 0)
r = mbed_target_info.get_mbed_target_from_current_dir()
self.assertEqual(None, r)
callYtTarget_mock.return_value = ('', '', 1)
r = mbed_target_info.get_mbed_target_from_current_dir()
self.assertEqual(None, r)
callYtTarget_mock.return_value = (yotta_target_cmd, '', 1)
r = mbed_target_info.get_mbed_target_from_current_dir()
self.assertEqual(None, r)
callYtTarget_mock.return_value = (yotta_target_cmd, '', 0)
r = mbed_target_info.get_mbed_target_from_current_dir()
self.assertEqual('frdm-k64f-gcc', r)
def test_get_yotta_target_from_local_config_invalid_path(self):
result = mbed_target_info.get_yotta_target_from_local_config("invalid_path.json")
self.assertIsNone(result)
def test_get_yotta_target_from_local_config_valid_path(self):
payload = '{"build": { "target": "test_target"}}'
handle, path = tempfile.mkstemp("test_file")
with open(path, 'w+') as f:
f.write(payload)
result = mbed_target_info.get_yotta_target_from_local_config(path)
self.assertIsNotNone(result)
self.assertEqual(result, "test_target")
def test_get_yotta_target_from_local_config_failed_open(self):
handle, path = tempfile.mkstemp()
with open(path, 'w+') as f:
result = mbed_target_info.get_yotta_target_from_local_config(path)
self.assertIsNone(result)
def test_get_mbed_targets_from_yotta_local_module_invalid_path(self):
result = mbed_target_info.get_mbed_targets_from_yotta_local_module("null", "invalid_path")
self.assertEqual(result, [])
def test_get_mbed_targets_from_yotta_local_module_invalid_target(self):
base_path = tempfile.mkdtemp()
targ_path = tempfile.mkdtemp("target-1", dir=base_path)
handle, targ_file = tempfile.mkstemp("target.json", dir=targ_path)
result = mbed_target_info.get_mbed_targets_from_yotta_local_module("null", base_path)
self.assertEqual(result, [])
def test_get_mbed_targets_from_yotta_local_module_valid(self):
payload = '{"name": "test_name", "keywords": [ "mbed-target:k64f" ]}'
base_path = tempfile.mkdtemp()
tar1_path = tempfile.mkdtemp("target-1", dir=base_path)
tar1_file = os.path.join(tar1_path, "target.json")
with open(tar1_file, 'w+') as f:
f.write(payload)
result = mbed_target_info.get_mbed_targets_from_yotta_local_module("k64f", base_path)
self.assertIsNot(result, None)
self.assertEqual(result[0], "test_name")
shutil.rmtree(base_path)
def test_parse_mbed_target_from_target_json_missing_json_data(self):
result = mbed_target_info.parse_mbed_target_from_target_json("null", "null")
self.assertIsNone(result)
def test_parse_mbed_target_from_target_json_missing_keywords(self):
data = {}
result = mbed_target_info.parse_mbed_target_from_target_json("null", data)
self.assertIsNone(result)
def test_parse_mbed_target_from_target_json_missing_target(self):
data = {}
data["keywords"] = {}
result = mbed_target_info.parse_mbed_target_from_target_json("null", data)
self.assertIsNone(result)
def test_parse_mbed_target_from_target_json_missing_name(self):
data = {}
data["keywords"] = ["mbed-target:null"]
result = mbed_target_info.parse_mbed_target_from_target_json("null", data)
self.assertIsNone(result)
# def test_get_mbed_targets_from_yotta(self):
# result = mbed_target_info.get_mbed_targets_from_yotta("k64f")
def test_parse_add_target_info_mapping(self):
result = mbed_target_info.add_target_info_mapping("null")
def test_parse_yotta_json_for_build_name(self):
self.assertEqual("", mbed_target_info.parse_yotta_json_for_build_name(
{
"build": {
"target": ""
}
}
))
self.assertEqual(None, mbed_target_info.parse_yotta_json_for_build_name(
{
"build": {}
}
))
self.assertEqual('frdm-k64f-gcc', mbed_target_info.parse_yotta_json_for_build_name(
{
"build": {
"target": "frdm-k64f-gcc,*",
"targetSetExplicitly": True
}
}
))
self.assertEqual('x86-linux-native', mbed_target_info.parse_yotta_json_for_build_name(
{
"build": {
"target": "x86-linux-native,*",
"targetSetExplicitly": True
}
}
))
self.assertEqual('frdm-k64f-gcc', mbed_target_info.parse_yotta_json_for_build_name(
{
"build": {
"target": "frdm-k64f-gcc,*"
}
}
))
self.assertEqual('frdm-k64f-gcc', mbed_target_info.parse_yotta_json_for_build_name(
{
"build": {
"target": "frdm-k64f-gcc"
}
}
))
self.assertEqual(None, mbed_target_info.parse_yotta_json_for_build_name(
{
"build": {
}
}
))
self.assertEqual(None, mbed_target_info.parse_yotta_json_for_build_name(
{
"BUILD": {
"target": "frdm-k64f-gcc,*",
"targetSetExplicitly": True
}
}
))
if __name__ == '__main__':
unittest.main()

View File

@ -1,595 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import unittest
from mbed_greentea import mbed_test_api
class GreenteaTestAPI(unittest.TestCase):
def setUp(self):
self.OUTPUT_FAILURE = """mbedgt: mbed-host-test-runner: started
[1459245784.59][CONN][RXD] >>> Test cases: 7 passed, 1 failed with reason 'Test Cases Failed'
[1459245784.61][CONN][RXD] >>> TESTS FAILED!
[1459245784.64][CONN][INF] found KV pair in stream: {{__testcase_summary;7;1}}, queued...
[1459245784.64][CONN][RXD] {{__testcase_summary;7;1}}
[1459245784.66][CONN][INF] found KV pair in stream: {{end;failure}}, queued...
[1459245784.66][HTST][INF] __notify_complete(False)
[1459245784.66][HTST][INF] test suite run finished after 2.37 sec...
[1459245784.66][CONN][RXD] {{end;failure}}
[1459245784.67][HTST][INF] CONN exited with code: 0
[1459245784.67][HTST][INF] Some events in queue
[1459245784.67][HTST][INF] stopped consuming events
[1459245784.67][HTST][INF] host test result() call skipped, received: False
[1459245784.67][HTST][WRN] missing __exit event from DUT
[1459245784.67][HTST][INF] calling blocking teardown()
[1459245784.67][HTST][INF] teardown() finished
[1459245784.67][HTST][INF] {{result;failure}}
"""
self.OUTPUT_SUCCESS = """mbedgt: mbed-host-test-runner: started
[1459245860.90][CONN][RXD] {{__testcase_summary;4;0}}
[1459245860.92][CONN][INF] found KV pair in stream: {{end;success}}, queued...
[1459245860.92][CONN][RXD] {{end;success}}
[1459245860.92][HTST][INF] __notify_complete(True)
[1459245860.92][HTST][INF] test suite run finished after 0.90 sec...
[1459245860.94][HTST][INF] CONN exited with code: 0
[1459245860.94][HTST][INF] No events in queue
[1459245860.94][HTST][INF] stopped consuming events
[1459245860.94][HTST][INF] host test result() call skipped, received: True
[1459245860.94][HTST][WRN] missing __exit event from DUT
[1459245860.94][HTST][INF] calling blocking teardown()
[1459245860.94][HTST][INF] teardown() finished
[1459245860.94][HTST][INF] {{result;success}}
"""
self.OUTPUT_TIMEOUT = """mbedgt: mbed-host-test-runner: started
[1459246047.80][HTST][INF] copy image onto target...
1 file(s) copied.
[1459246055.05][HTST][INF] starting host test process...
[1459246055.47][CONN][INF] starting connection process...
[1459246055.47][CONN][INF] initializing serial port listener...
[1459246055.47][SERI][INF] serial(port=COM205, baudrate=9600)
[1459246055.47][SERI][INF] reset device using 'default' plugin...
[1459246055.73][SERI][INF] wait for it...
[1459246056.74][CONN][INF] sending preamble '56bdcd85-b88a-460b-915e-1b9b41713b5a'...
[1459246056.74][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1459246056.74][SERI][TXD] {{__sync;56bdcd85-b88a-460b-915e-1b9b41713b5a}}
[1459246065.06][HTST][INF] test suite run finished after 10.00 sec...
[1459246065.07][HTST][INF] CONN exited with code: 0
[1459246065.07][HTST][INF] No events in queue
[1459246065.07][HTST][INF] stopped consuming events
[1459246065.07][HTST][INF] host test result(): None
[1459246065.07][HTST][WRN] missing __exit event from DUT
[1459246065.07][HTST][ERR] missing __exit event from DUT and no result from host test, timeout...
[1459246065.07][HTST][INF] calling blocking teardown()
[1459246065.07][HTST][INF] teardown() finished
[1459246065.07][HTST][INF] {{result;timeout}}
"""
self.OUTPUT_STARTTAG_MISSING = """
mbedgt: mbed-host-test-runner: started
[1507470727.39][HTST][INF] host test executor ver. 1.2.0
[1507470727.39][HTST][INF] copy image onto target... SKIPPED!
[1507470727.39][HTST][INF] starting host test process...
[1507470727.40][CONN][INF] starting connection process...
[1507470727.40][HTST][INF] setting timeout to: 120 sec
[1507470756.96][CONN][RXD] >>> Running 4 test cases...
[1507470756.96][CONN][RXD]
[1507470756.96][CONN][RXD] >>> Running case #1: 'DNS query'...
[1507470756.96][CONN][INF] found KV pair in stream: {{__testcase_name;DNS query}}, queued...
[1507470756.96][CONN][INF] found KV pair in stream: {{__testcase_name;DNS preference query}}, queued...
[1507470756.96][CONN][INF] found KV pair in stream: {{__testcase_name;DNS literal}}, queued...
[1507470756.96][CONN][INF] found KV pair in stream: {{__testcase_name;DNS preference literal}}, queued...
[1507470757.04][CONN][RXD] DNS: query "connector.mbed.com" => "169.45.82.19"
[1507470757.04][CONN][INF] found KV pair in stream: {{__testcse_start;DNS query}}, queued...
[1507470757.13][CONN][RXD] >>> 'DNS query': 1 passed, 0 failed
[1507470757.13][CONN][RXD]
[1507470757.13][CONN][INF] found KV pair in stream: {{__testcase_finish;DNS query;1;0}}, queued...
[1507470757.32][CONN][RXD] >>> Running case #2: 'DNS preference query'...
[1507470757.41][CONN][RXD] DNS: query ipv4 "connector.mbed.com" => "169.45.82.19"
[1507470757.41][CONN][RXD] >>> 'DNS preference query': 1 passed, 0 failed
[1507470757.41][CONN][RXD]
[1507470757.41][CONN][INF] found KV pair in stream: {{__testcase_start;DNS preference query}}, queued...
[1507470757.41][CONN][INF] found KV pair in stream: {{__testcase_finish;DNS preference query;1;0}}, queued...
[1507470757.57][CONN][RXD] >>> Running case #3: 'DNS literal'...
[1507470757.66][CONN][RXD] DNS: literal "10.118.13.253" => "10.118.13.253"
[1507470757.66][CONN][RXD] {{__testcase_finish;DNS l<DAPLink:Overflow>
[1507470757.66][CONN][RXD] sed, 0 fai<DAPLink:Overflow>
[1507470757.66][CONN][INF] found KV pair in stream: {{__testcase_start;DNS literal}}, queued...
[1507470757.80][CONN][RXD] case #4: 'DNS preference literal'...
[1507470757.80][CONN][RXD] {{__test<DAPLink:Overflow>
[1507470757.80][CONN][RXD] reference literal}}
[1507470757.83][CONN][RXD] DNS: literal ipv4 "10.118.13.253" => "10.118.13.253"
[1507470757.83][CONN][INF] found KV pair in stream: {{__testcase_finish;DNS preference literal;1;0}}, queued...
[1507470757.92][CONN][RXD] >>> 'DNS preference literal': 1 passed, 0 failed
[1507470757.92][CONN][RXD]
[1507470757.92][CONN][RXD] >>> Test cases: 4 passed, 0 failed
[1507470758.00][CONN][INF] found KV pair in stream: {{__testcase_summary;4;0}}, queued...
[1507470758.00][CONN][INF] found KV pair in stream: {{max_heap_usage;2800}}, queued...
[1507470758.00][CONN][INF] found KV pair in stream: {{reserved_heap;19336}}, queued...
[1507470758.00][HTST][ERR] orphan event in main phase: {{max_heap_usage;2800}}, timestamp=1507470757.999258
[1507470758.00][HTST][ERR] orphan event in main phase: {{reserved_heap;19336}}, timestamp=1507470757.999260
[1507470758.00][CONN][INF] found KV pair in stream: {{__thread_info;"0x010002ca8",600,4096}}, queued...
[1507470758.00][HTST][ERR] orphan event in main phase: {{__thread_info;"0x010002ca8",600,4096}}, timestamp=1507470757.999261
[1507470758.09][CONN][INF] found KV pair in stream: {{__thread_info;"0x01000045c",72,512}}, queued...
[1507470758.09][CONN][INF] found KV pair in stream: {{__thread_info;"0x010001168",128,512}}, queued...
[1507470758.09][HTST][ERR] orphan event in main phase: {{__thread_info;"0x01000045c",72,512}}, timestamp=1507470758.085627
[1507470758.09][HTST][ERR] orphan event in main phase: {{__thread_info;"0x010001168",128,512}}, timestamp=1507470758.085635
[1507470758.16][CONN][INF] found KV pair in stream: {{__thread_info;"0x010001018",560,1200}}, queued...
[1507470758.16][HTST][ERR] orphan event in main phase: {{__thread_info;"0x010001018",560,1200}}, timestamp=1507470758.162780
[1507470758.25][CONN][INF] found KV pair in stream: {{__thread_info;"0x0100004a4",112,768}}, queued...
[1507470758.25][CONN][INF] found KV pair in stream: {{__thread_info;"0x0100010f8",96,512}}, queued...
[1507470758.25][CONN][INF] found KV pair in stream: {{__thread_info;"0x010001088",152,512}}, queued...
[1507470758.25][CONN][INF] found KV pair in stream: {{end;success}}, queued...
[1507470758.25][HTST][ERR] orphan event in main phase: {{__thread_info;"0x0100004a4",112,768}}, timestamp=1507470758.248291
[1507470758.25][HTST][ERR] orphan event in main phase: {{__thread_info;"0x0100010f8",96,512}}, timestamp=1507470758.248296
[1507470758.25][HTST][ERR] orphan event in main phase: {{__thread_info;"0x010001088",152,512}}, timestamp=1507470758.248299
[1507470758.25][HTST][INF] __notify_complete(True)
[1507470758.25][HTST][INF] __exit_event_queue received
[1507470760.47][HTST][INF] CONN exited with code: 0
[1507470760.47][HTST][INF] No events in queue
[1507470760.47][HTST][INF] stopped consuming events
[1507470760.47][HTST][INF] host test result() call skipped, received: True
[1507470760.47][HTST][WRN] missing __exit event from DUT
[1507470760.47][HTST][INF] calling blocking teardown()
[1507470760.47][HTST][INF] teardown() finished
[1507470760.47][HTST][INF] {{result;success}}
"""
self.OUTPUT_UNDEF = """mbedgt: mbed-host-test-runner: started
{{result;some_random_value}}
"""
self.OUTOUT_CSTRING_TEST = """
[1459246264.88][HTST][INF] copy image onto target...
1 file(s) copied.
[1459246272.76][HTST][INF] starting host test process...
[1459246273.18][CONN][INF] starting connection process...
[1459246273.18][CONN][INF] initializing serial port listener...
[1459246273.18][SERI][INF] serial(port=COM205, baudrate=9600)
[1459246273.18][SERI][INF] reset device using 'default' plugin...
[1459246273.43][SERI][INF] wait for it...
[1459246274.43][CONN][INF] sending preamble '5daa5ff9-a9c1-4b47-88a2-9295f1de7c64'...
[1459246274.43][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1459246274.43][SERI][TXD] {{__sync;5daa5ff9-a9c1-4b47-88a2-9295f1de7c64}}
[1459246274.58][CONN][INF] found SYNC in stream: {{__sync;5daa5ff9-a9c1-4b47-88a2-9295f1de7c64}}, queued...
[1459246274.58][CONN][RXD] {{__sync;5daa5ff9-a9c1-4b47-88a2-9295f1de7c64}}
[1459246274.58][HTST][INF] sync KV found, uuid=5daa5ff9-a9c1-4b47-88a2-9295f1de7c64, timestamp=1459246274.575000
[1459246274.60][CONN][INF] found KV pair in stream: {{__version;1.1.0}}, queued...
[1459246274.60][CONN][RXD] {{__version;1.1.0}}
[1459246274.60][HTST][INF] DUT greentea-client version: 1.1.0
[1459246274.61][CONN][INF] found KV pair in stream: {{__timeout;5}}, queued...
[1459246274.61][HTST][INF] setting timeout to: 5 sec
[1459246274.62][CONN][RXD] {{__timeout;5}}
[1459246274.64][CONN][INF] found KV pair in stream: {{__host_test_name;default_auto}}, queued...
[1459246274.64][HTST][INF] host test setup() call...
[1459246274.64][HTST][INF] CALLBACKs updated
[1459246274.64][HTST][INF] host test detected: default_auto
[1459246274.64][CONN][RXD] {{__host_test_name;default_auto}}
[1459246274.66][CONN][INF] found KV pair in stream: {{__testcase_count;8}}, queued...
[1459246274.66][CONN][RXD] {{__testcase_count;8}}
[1459246274.69][CONN][RXD] >>> Running 8 test cases...
[1459246274.74][CONN][RXD] >>> Running case #1: 'C strings: strtok'...
[1459246274.79][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: strtok}}, queued...
[1459246274.79][CONN][RXD] {{__testcase_start;C strings: strtok}}
[1459246274.84][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: strtok;1;0}}, queued...
[1459246274.84][CONN][RXD] {{__testcase_finish;C strings: strtok;1;0}}
[1459246274.88][CONN][RXD] >>> 'C strings: strtok': 1 passed, 0 failed
[1459246274.93][CONN][RXD] >>> Running case #2: 'C strings: strpbrk'...
[1459246274.97][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: strpbrk}}, queued...
[1459246274.97][CONN][RXD] {{__testcase_start;C strings: strpbrk}}
[1459246275.01][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: strpbrk;1;0}}, queued...
[1459246275.01][CONN][RXD] {{__testcase_finish;C strings: strpbrk;1;0}}
[1459246275.06][CONN][RXD] >>> 'C strings: strpbrk': 1 passed, 0 failed
[1459246275.13][CONN][RXD] >>> Running case #3: 'C strings: %i %d integer formatting'...
[1459246275.18][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %i %d integer formatting}}, queued...
[1459246275.18][CONN][RXD] {{__testcase_start;C strings: %i %d integer formatting}}
[1459246275.24][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %i %d integer formatting;1;0}}, queued...
[1459246275.24][CONN][RXD] {{__testcase_finish;C strings: %i %d integer formatting;1;0}}
[1459246275.32][CONN][RXD] >>> 'C strings: %i %d integer formatting': 1 passed, 0 failed
[1459246275.38][CONN][RXD] >>> Running case #4: 'C strings: %u %d integer formatting'...
[1459246275.44][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %u %d integer formatting}}, queued...
[1459246275.44][CONN][RXD] {{__testcase_start;C strings: %u %d integer formatting}}
[1459246275.50][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %u %d integer formatting;1;0}}, queued...
[1459246275.50][CONN][RXD] {{__testcase_finish;C strings: %u %d integer formatting;1;0}}
[1459246275.57][CONN][RXD] >>> 'C strings: %u %d integer formatting': 1 passed, 0 failed
[1459246275.64][CONN][RXD] >>> Running case #5: 'C strings: %x %E integer formatting'...
[1459246275.68][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %x %E integer formatting}}, queued...
[1459246275.68][CONN][RXD] {{__testcase_start;C strings: %x %E integer formatting}}
[1459246275.74][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %x %E integer formatting;1;0}}, queued...
[1459246275.74][CONN][RXD] {{__testcase_finish;C strings: %x %E integer formatting;1;0}}
[1459246275.82][CONN][RXD] >>> 'C strings: %x %E integer formatting': 1 passed, 0 failed
[1459246275.88][CONN][RXD] >>> Running case #6: 'C strings: %f %f float formatting'...
[1459246275.94][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %f %f float formatting}}, queued...
[1459246275.94][CONN][RXD] {{__testcase_start;C strings: %f %f float formatting}}
[1459246276.10][CONN][RXD] :57::FAIL: Expected '0.002000 0.924300 15.913200 791.773680 6208.200000 25719.495200 426815.982588 6429271.046000 42468024.930000 212006462.910000' Was '
'
[1459246276.18][CONN][RXD] >>> failure with reason 'Assertion Failed' during 'Case Handler'
[1459246276.25][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %f %f float formatting;0;1}}, queued...
[1459246276.25][CONN][RXD] {{__testcase_finish;C strings: %f %f float formatting;0;1}}
[1459246276.34][CONN][RXD] >>> 'C strings: %f %f float formatting': 0 passed, 1 failed with reason 'Test Cases Failed'
[1459246276.41][CONN][RXD] >>> Running case #7: 'C strings: %e %E float formatting'...
[1459246276.46][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %e %E float formatting}}, queued...
[1459246276.46][CONN][RXD] {{__testcase_start;C strings: %e %E float formatting}}
[1459246276.52][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %e %E float formatting;1;0}}, queued...
[1459246276.53][CONN][RXD] {{__testcase_finish;C strings: %e %E float formatting;1;0}}
[1459246276.59][CONN][RXD] >>> 'C strings: %e %E float formatting': 1 passed, 0 failed
[1459246276.65][CONN][RXD] >>> Running case #8: 'C strings: %g %g float formatting'...
[1459246276.71][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %g %g float formatting}}, queued...
[1459246276.71][CONN][RXD] {{__testcase_start;C strings: %g %g float formatting}}
[1459246276.77][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %g %g float formatting;1;0}}, queued...
[1459246276.77][CONN][RXD] {{__testcase_finish;C strings: %g %g float formatting;1;0}}
[1459246276.83][CONN][RXD] >>> 'C strings: %g %g float formatting': 1 passed, 0 failed
[1459246276.90][CONN][RXD] >>> Test cases: 7 passed, 1 failed with reason 'Test Cases Failed'
[1459246276.92][CONN][RXD] >>> TESTS FAILED!
[1459246276.95][CONN][INF] found KV pair in stream: {{__testcase_summary;7;1}}, queued...
[1459246276.95][CONN][RXD] {{__testcase_summary;7;1}}
[1459246276.97][CONN][INF] found KV pair in stream: {{end;failure}}, queued...
[1459246276.97][CONN][RXD] {{end;failure}}
[1459246276.97][HTST][INF] __notify_complete(False)
[1459246276.97][HTST][INF] test suite run finished after 2.37 sec...
[1459246276.98][HTST][INF] CONN exited with code: 0
[1459246276.98][HTST][INF] Some events in queue
[1459246276.98][HTST][INF] stopped consuming events
[1459246276.98][HTST][INF] host test result() call skipped, received: False
[1459246276.98][HTST][WRN] missing __exit event from DUT
[1459246276.98][HTST][INF] calling blocking teardown()
[1459246276.98][HTST][INF] teardown() finished
[1459246276.98][HTST][INF] {{result;failure}}
"""
self.OUTOUT_CSTRING_TEST_CASE_COUNT_AND_NAME = """
[1467197417.13][SERI][TXD] {{__sync;3018cb93-f11c-417e-bf61-240c338dfec9}}
[1467197417.27][CONN][RXD] {{__sync;3018cb93-f11c-417e-bf61-240c338dfec9}}
[1467197417.27][CONN][INF] found SYNC in stream: {{__sync;3018cb93-f11c-417e-bf61-240c338dfec9}} it is #0 sent, queued...
[1467197417.27][HTST][INF] sync KV found, uuid=3018cb93-f11c-417e-bf61-240c338dfec9, timestamp=1467197417.272000
[1467197417.29][CONN][RXD] {{__version;1.1.0}}
[1467197417.29][CONN][INF] found KV pair in stream: {{__version;1.1.0}}, queued...
[1467197417.29][HTST][INF] DUT greentea-client version: 1.1.0
[1467197417.31][CONN][RXD] {{__timeout;5}}
[1467197417.31][CONN][INF] found KV pair in stream: {{__timeout;5}}, queued...
[1467197417.31][HTST][INF] setting timeout to: 5 sec
[1467197417.34][CONN][RXD] {{__host_test_name;default_auto}}
[1467197417.34][CONN][INF] found KV pair in stream: {{__host_test_name;default_auto}}, queued...
[1467197417.34][HTST][INF] host test class: '<class 'mbed_host_tests.host_tests.default_auto.DefaultAuto'>'
[1467197417.34][HTST][INF] host test setup() call...
[1467197417.34][HTST][INF] CALLBACKs updated
[1467197417.34][HTST][INF] host test detected: default_auto
[1467197417.36][CONN][RXD] {{__testcase_count;2}}
[1467197417.36][CONN][INF] found KV pair in stream: {{__testcase_count;2}}, queued...
[1467197417.39][CONN][RXD] >>> Running 2 test cases...
[1467197417.43][CONN][RXD] {{__testcase_name;C strings: strtok}}
[1467197417.43][CONN][INF] found KV pair in stream: {{__testcase_name;C strings: strtok}}, queued...
[1467197417.47][CONN][RXD] {{__testcase_name;C strings: strpbrk}}
[1467197417.47][CONN][INF] found KV pair in stream: {{__testcase_name;C strings: strpbrk}}, queued...
[1467197417.52][CONN][RXD] >>> Running case #1: 'C strings: strtok'...
[1467197417.56][CONN][RXD] {{__testcase_start;C strings: strtok}}
[1467197417.56][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: strtok}}, queued...
[1467197422.31][HTST][INF] test suite run finished after 5.00 sec...
[1467197422.31][CONN][INF] received special even '__host_test_finished' value='True', finishing
[1467197422.33][HTST][INF] CONN exited with code: 0
[1467197422.33][HTST][INF] No events in queue
[1467197422.33][HTST][INF] stopped consuming events
[1467197422.33][HTST][INF] host test result(): None
[1467197422.33][HTST][WRN] missing __exit event from DUT
[1467197422.33][HTST][ERR] missing __exit event from DUT and no result from host test, timeout...
[1467197422.33][HTST][INF] calling blocking teardown()
[1467197422.33][HTST][INF] teardown() finished
[1467197422.33][HTST][INF] {{result;timeout}}
"""
self.OUTOUT_GENERIC_TESTS_TESCASE_NAME_AND_COUNT = """
[1467205002.74][HTST][INF] host test executor ver. 0.2.19
[1467205002.74][HTST][INF] copy image onto target...
1 file(s) copied.
Plugin info: HostTestPluginCopyMethod_Shell::CopyMethod: Waiting up to 60 sec for '0240000033514e450019500585d40008e981000097969900' mount point (current is 'F:')...
[1467205011.16][HTST][INF] starting host test process...
[1467205011.74][CONN][INF] starting serial connection process...
[1467205011.74][CONN][INF] notify event queue about extra 60 sec timeout for serial port pooling
[1467205011.74][CONN][INF] initializing serial port listener...
[1467205011.74][HTST][INF] setting timeout to: 60 sec
[1467205011.74][SERI][INF] serial(port=COM219, baudrate=9600, timeout=0)
Plugin info: HostTestPluginBase::BasePlugin: Waiting up to 60 sec for '0240000033514e450019500585d40008e981000097969900' serial port (current is 'COM219')...
[1467205011.83][SERI][INF] reset device using 'default' plugin...
[1467205012.08][SERI][INF] waiting 1.00 sec after reset
[1467205013.08][SERI][INF] wait for it...
[1467205013.08][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1467205013.08][CONN][INF] sending up to 2 __sync packets (specified with --sync=2)
[1467205013.08][CONN][INF] sending preamble 'f82e0251-bb3e-4434-bc93-b780b5d0e82a'
[1467205013.08][SERI][TXD] {{__sync;f82e0251-bb3e-4434-bc93-b780b5d0e82a}}
[1467205013.22][CONN][RXD] {{__sync;f82e0251-bb3e-4434-bc93-b780b5d0e82a}}
[1467205013.22][CONN][INF] found SYNC in stream: {{__sync;f82e0251-bb3e-4434-bc93-b780b5d0e82a}} it is #0 sent, queued...
[1467205013.22][HTST][INF] sync KV found, uuid=f82e0251-bb3e-4434-bc93-b780b5d0e82a, timestamp=1467205013.219000
[1467205013.24][CONN][RXD] {{__version;1.1.0}}
[1467205013.24][CONN][INF] found KV pair in stream: {{__version;1.1.0}}, queued...
[1467205013.24][HTST][INF] DUT greentea-client version: 1.1.0
[1467205013.25][CONN][RXD] {{__timeout;20}}
[1467205013.26][CONN][INF] found KV pair in stream: {{__timeout;20}}, queued...
[1467205013.26][HTST][INF] setting timeout to: 20 sec
[1467205013.29][CONN][RXD] {{__host_test_name;default_auto}}
[1467205013.29][CONN][INF] found KV pair in stream: {{__host_test_name;default_auto}}, queued...
[1467205013.29][HTST][INF] host test class: '<class 'mbed_host_tests.host_tests.default_auto.DefaultAuto'>'
[1467205013.29][HTST][INF] host test setup() call...
[1467205013.29][HTST][INF] CALLBACKs updated
[1467205013.29][HTST][INF] host test detected: default_auto
[1467205013.31][CONN][RXD] {{__testcase_count;4}}
[1467205013.31][CONN][INF] found KV pair in stream: {{__testcase_count;4}}, queued...
[1467205013.34][CONN][RXD] >>> Running 4 test cases...
[1467205013.37][CONN][RXD] {{__testcase_name;Basic}}
[1467205013.37][CONN][INF] found KV pair in stream: {{__testcase_name;Basic}}, queued...
[1467205013.40][CONN][RXD] {{__testcase_name;Blinky}}
[1467205013.40][CONN][INF] found KV pair in stream: {{__testcase_name;Blinky}}, queued...
[1467205013.43][CONN][RXD] {{__testcase_name;C++ stack}}
[1467205013.43][CONN][INF] found KV pair in stream: {{__testcase_name;C++ stack}}, queued...
[1467205013.46][CONN][RXD] {{__testcase_name;C++ heap}}
[1467205013.46][CONN][INF] found KV pair in stream: {{__testcase_name;C++ heap}}, queued...
[1467205013.49][CONN][RXD] >>> Running case #1: 'Basic'...
[1467205013.52][CONN][RXD] {{__testcase_start;Basic}}
[1467205013.52][CONN][INF] found KV pair in stream: {{__testcase_start;Basic}}, queued...
[1467205013.56][CONN][RXD] {{__testcase_finish;Basic;1;0}}
[1467205013.56][CONN][INF] found KV pair in stream: {{__testcase_finish;Basic;1;0}}, queued...
[1467205013.59][CONN][RXD] >>> 'Basic': 1 passed, 0 failed
[1467205013.62][CONN][RXD] >>> Running case #2: 'Blinky'...
[1467205013.65][CONN][RXD] {{__testcase_start;Blinky}}
[1467205013.65][CONN][INF] found KV pair in stream: {{__testcase_start;Blinky}}, queued...
[1467205013.69][CONN][RXD] {{__testcase_finish;Blinky;1;0}}
[1467205013.69][CONN][INF] found KV pair in stream: {{__testcase_finish;Blinky;1;0}}, queued...
[1467205013.72][CONN][RXD] >>> 'Blinky': 1 passed, 0 failed
[1467205013.75][CONN][RXD] >>> Running case #3: 'C++ stack'...
[1467205013.78][CONN][RXD] {{__testcase_start;C++ stack}}
[1467205013.78][CONN][INF] found KV pair in stream: {{__testcase_start;C++ stack}}, queued...
[1467205013.79][CONN][RXD] Static::init
[1467205013.81][CONN][RXD] Static::stack_test
[1467205013.82][CONN][RXD] Stack::init
[1467205013.85][CONN][RXD] Stack::hello
[1467205013.87][CONN][RXD] Stack::destroy
[1467205013.89][CONN][RXD] Static::check_init: OK
[1467205013.91][CONN][RXD] Static::destroy
[1467205013.94][CONN][RXD] {{__testcase_finish;C++ stack;1;0}}
[1467205013.95][CONN][INF] found KV pair in stream: {{__testcase_finish;C++ stack;1;0}}, queued...
[1467205013.98][CONN][RXD] >>> 'C++ stack': 1 passed, 0 failed
[1467205014.02][CONN][RXD] >>> Running case #4: 'C++ heap'...
[1467205014.05][CONN][RXD] {{__testcase_start;C++ heap}}
[1467205014.05][CONN][INF] found KV pair in stream: {{__testcase_start;C++ heap}}, queued...
[1467205014.06][CONN][RXD] Heap::init
[1467205014.07][CONN][RXD] Heap::hello
[1467205014.10][CONN][RXD] Heap::check_init: OK
[1467205014.11][CONN][RXD] Heap::destroy
[1467205014.15][CONN][RXD] {{__testcase_finish;C++ heap;1;0}}
[1467205014.15][CONN][INF] found KV pair in stream: {{__testcase_finish;C++ heap;1;0}}, queued...
[1467205014.18][CONN][RXD] >>> 'C++ heap': 1 passed, 0 failed
[1467205014.22][CONN][RXD] >>> Test cases: 4 passed, 0 failed
[1467205014.25][CONN][RXD] {{__testcase_summary;4;0}}
[1467205014.25][CONN][INF] found KV pair in stream: {{__testcase_summary;4;0}}, queued...
[1467205014.27][CONN][RXD] {{end;success}}
[1467205014.27][CONN][INF] found KV pair in stream: {{end;success}}, queued...
[1467205014.28][CONN][RXD] {{__exit;0}}
[1467205014.28][CONN][INF] found KV pair in stream: {{__exit;0}}, queued...
[1467205014.28][HTST][INF] __exit(0)
[1467205014.28][HTST][INF] test suite run finished after 1.02 sec...
[1467205014.28][CONN][INF] received special even '__host_test_finished' value='True', finishing
[1467205014.31][HTST][INF] CONN exited with code: 0
[1467205014.31][HTST][INF] Some events in queue
[1467205014.31][HTST][INF] __notify_complete(True)
[1467205014.31][HTST][INF] stopped consuming events
[1467205014.31][HTST][INF] host test result() call skipped, received: True
[1467205014.31][HTST][INF] calling blocking teardown()
[1467205014.31][HTST][INF] teardown() finished
[1467205014.31][HTST][INF] {{result;success}}
"""
self.OUTPUT_WITH_MEMORY_METRICS = """mbedgt: mbed-host-test-runner: started
[1459245860.90][CONN][RXD] {{__testcase_summary;4;0}}
[1459245860.92][CONN][INF] found KV pair in stream: {{end;success}}, queued...
[1459245860.92][CONN][RXD] {{end;success}}
[1459245860.92][CONN][INF] found KV pair in stream: {{max_heap_usage;2284}}, queued...
[1459245860.92][CONN][RXD] {{end;success}}
[1459245860.92][CONN][INF] found KV pair in stream: {{reserved_heap;124124}}, queued...
[1459245860.92][CONN][RXD] {{end;success}}
[1459245860.92][CONN][INF] found KV pair in stream: {{__thread_info;"BE-EF",42,24}}, queued...
[1459245860.92][CONN][RXD] {{end;success}}
[1459245860.92][HTST][INF] __notify_complete(True)
[1459245860.92][CONN][RXD] {{__coverage_start;c:\Work\core-util/source/PoolAllocator.cpp.gcda;6164636772393034c2733f32...a33e...b9}}
[1459245860.92][HTST][INF] test suite run finished after 0.90 sec...
[1459245860.94][HTST][INF] CONN exited with code: 0
[1459245860.94][HTST][INF] No events in queue
[1459245860.94][HTST][INF] stopped consuming events
[1459245860.94][HTST][INF] host test result() call skipped, received: True
[1459245860.94][HTST][WRN] missing __exit event from DUT
[1459245860.94][HTST][INF] calling blocking teardown()
[1459245860.94][HTST][INF] teardown() finished
[1459245860.94][HTST][INF] {{result;success}}
"""
def tearDown(self):
pass
def test_get_test_result(self):
self.assertEqual(mbed_test_api.TEST_RESULT_OK, mbed_test_api.get_test_result(self.OUTPUT_SUCCESS))
self.assertEqual(mbed_test_api.TEST_RESULT_FAIL, mbed_test_api.get_test_result(self.OUTPUT_FAILURE))
self.assertEqual(mbed_test_api.TEST_RESULT_TIMEOUT, mbed_test_api.get_test_result(self.OUTPUT_TIMEOUT))
self.assertEqual(mbed_test_api.TEST_RESULT_UNDEF, mbed_test_api.get_test_result(self.OUTPUT_UNDEF))
def test_get_test_result_ok_len(self):
r = mbed_test_api.get_testcase_utest(self.OUTOUT_CSTRING_TEST, 'C strings: %e %E float formatting')
self.assertEqual(len(r), 6)
self.assertIn("[1459246276.41][CONN][RXD] >>> Running case #7: 'C strings: %e %E float formatting'...", r)
self.assertIn("[1459246276.46][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %e %E float formatting}}, queued...", r)
self.assertIn("[1459246276.46][CONN][RXD] {{__testcase_start;C strings: %e %E float formatting}}", r)
self.assertIn("[1459246276.52][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %e %E float formatting;1;0}}, queued...", r)
self.assertIn("[1459246276.53][CONN][RXD] {{__testcase_finish;C strings: %e %E float formatting;1;0}}", r)
self.assertIn("[1459246276.59][CONN][RXD] >>> 'C strings: %e %E float formatting': 1 passed, 0 failed", r)
def test_get_test_result_fail_len(self):
r = mbed_test_api.get_testcase_utest(self.OUTOUT_CSTRING_TEST, 'C strings: %f %f float formatting')
self.assertEqual(len(r), 9)
self.assertIn("[1459246275.88][CONN][RXD] >>> Running case #6: 'C strings: %f %f float formatting'...", r)
self.assertIn("[1459246275.94][CONN][INF] found KV pair in stream: {{__testcase_start;C strings: %f %f float formatting}}, queued...", r)
self.assertIn("[1459246275.94][CONN][RXD] {{__testcase_start;C strings: %f %f float formatting}}", r)
self.assertIn("[1459246276.10][CONN][RXD] :57::FAIL: Expected '0.002000 0.924300 15.913200 791.773680 6208.200000 25719.495200 426815.982588 6429271.046000 42468024.930000 212006462.910000' Was '", r)
self.assertIn("'", r)
self.assertIn("[1459246276.18][CONN][RXD] >>> failure with reason 'Assertion Failed' during 'Case Handler'", r)
self.assertIn("[1459246276.25][CONN][INF] found KV pair in stream: {{__testcase_finish;C strings: %f %f float formatting;0;1}}, queued...", r)
self.assertIn("[1459246276.25][CONN][RXD] {{__testcase_finish;C strings: %f %f float formatting;0;1}}", r)
self.assertIn("[1459246276.34][CONN][RXD] >>> 'C strings: %f %f float formatting': 0 passed, 1 failed with reason 'Test Cases Failed'", r)
def get_testcase_count_and_names(self):
tc_count, tc_names = mbed_test_api.get_testcase_count_and_names(self.OUTOUT_CSTRING_TEST_CASE_COUNT_AND_NAME)
self.assertEqual(tc_count, 2)
self.assertIn('C strings: strtok', tc_names)
self.assertIn('C strings: strpbrk', tc_names)
def test_get_test_result_return_val(self):
test_case_names = [
'C strings: %e %E float formatting',
'C strings: %g %g float formatting',
'C strings: %i %d integer formatting',
'C strings: %u %d integer formatting',
'C strings: %x %E integer formatting',
'C strings: strpbrk',
'C strings: strtok'
]
for test_case in test_case_names:
r = mbed_test_api.get_testcase_utest(self.OUTOUT_CSTRING_TEST, test_case)
self.assertEqual(len(r), 6)
# This failing test case has different long lenght
r = mbed_test_api.get_testcase_utest(self.OUTOUT_CSTRING_TEST, 'C strings: %f %f float formatting')
self.assertEqual(len(r), 9)
def test_get_testcase_summary_failures(self):
r = mbed_test_api.get_testcase_summary("{{__testcase_summary;;}}")
self.assertEqual(None, r)
r = mbed_test_api.get_testcase_summary("{{__testcase_summary;-1;-2}}")
self.assertEqual(None, r)
r = mbed_test_api.get_testcase_summary("{{__testcase_summary;A;0}}")
self.assertEqual(None, r)
def test_get_testcase_summary_value_failures(self):
r = mbed_test_api.get_testcase_summary("[1459246276.95][CONN][INF] found KV pair in stream: {{__testcase_summary;;}}")
self.assertEqual(None, r)
r = mbed_test_api.get_testcase_summary("[1459246276.95][CONN][INF] found KV pair in stream: {{__testcase_summary;-1;-2}}")
self.assertEqual(None, r)
r = mbed_test_api.get_testcase_summary("[1459246276.95][CONN][INF] found KV pair in stream: {{__testcase_summary;A;0}}")
self.assertEqual(None, r)
def test_get_testcase_summary_ok(self):
r = mbed_test_api.get_testcase_summary("[1459246276.95][CONN][INF] found KV pair in stream: {{__testcase_summary;0;0}}")
self.assertNotEqual(None, r)
self.assertEqual((0, 0), r)
r = mbed_test_api.get_testcase_summary(self.OUTOUT_CSTRING_TEST)
self.assertNotEqual(None, r)
self.assertEqual((7, 1), r) # {{__testcase_summary;7;1}}
r = mbed_test_api.get_testcase_summary(self.OUTPUT_SUCCESS)
self.assertNotEqual(None, r)
self.assertEqual((4, 0), r) # {{__testcase_summary;4;0}}
def test_get_testcase_result(self):
r = mbed_test_api.get_testcase_result(self.OUTOUT_CSTRING_TEST)
self.assertEqual(len(r), 8)
test_case_names = [
'C strings: %e %E float formatting',
'C strings: %g %g float formatting',
'C strings: %i %d integer formatting',
'C strings: %u %d integer formatting',
'C strings: %x %E integer formatting',
'C strings: strpbrk',
'C strings: strtok'
]
for test_case in test_case_names:
tc = r[test_case]
# If data structure is correct
self.assertIn('utest_log', tc)
self.assertIn('time_start', tc)
self.assertIn('time_end', tc)
self.assertIn('failed', tc)
self.assertIn('result', tc)
self.assertIn('passed', tc)
self.assertIn('duration', tc)
# values passed
self.assertEqual(tc['passed'], 1)
self.assertEqual(tc['failed'], 0)
self.assertEqual(tc['result_text'], 'OK')
# Failing test case
tc = r['C strings: %f %f float formatting']
self.assertEqual(tc['passed'], 0)
self.assertEqual(tc['failed'], 1)
self.assertEqual(tc['result_text'], 'FAIL')
def test_get_testcase_result_tescase_name_and_count(self):
r = mbed_test_api.get_testcase_result(self.OUTOUT_GENERIC_TESTS_TESCASE_NAME_AND_COUNT)
self.assertEqual(len(r), 4)
self.assertIn('Basic', r)
self.assertIn('Blinky', r)
self.assertIn('C++ heap', r)
self.assertIn('C++ stack', r)
def test_get_testcase_result_tescase_name_and_count(self):
r = mbed_test_api.get_testcase_result(self.OUTOUT_CSTRING_TEST_CASE_COUNT_AND_NAME)
self.assertEqual(len(r), 2)
self.assertIn('C strings: strpbrk', r)
self.assertIn('C strings: strtok', r)
self.assertEqual(r['C strings: strpbrk']['result_text'], 'SKIPPED')
self.assertEqual(r['C strings: strtok']['result_text'], 'ERROR')
def test_get_test_results_empty_output(self):
result = mbed_test_api.get_test_result("")
self.assertEqual(result, "TIMEOUT")
def test_get_memory_metrics(self):
result = mbed_test_api.get_memory_metrics(self.OUTPUT_WITH_MEMORY_METRICS)
self.assertEqual(result[0], 2284)
self.assertEqual(result[1], 124124)
thread_info = list(result[2])[0]
self.assertIn("entry", thread_info)
self.assertEqual(thread_info["entry"], "BE")
self.assertIn("stack_size", thread_info)
self.assertEqual(thread_info["stack_size"], 24)
self.assertIn("max_stack", thread_info)
self.assertEqual(thread_info["max_stack"], 42)
self.assertIn("arg", thread_info)
self.assertEqual(thread_info["arg"], "EF")
def test_get_testcase_result_start_tag_missing(self):
result = mbed_test_api.get_testcase_result(self.OUTPUT_STARTTAG_MISSING)
self.assertEqual(result['DNS query']['utest_log'], "__testcase_start tag not found.")
if __name__ == '__main__':
unittest.main()

View File

@ -1,294 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import unittest
from mbed_greentea import mbed_greentea_cli
class GreenteaFilteredTestList(unittest.TestCase):
def setUp(self):
self.ctest_test_list = {'test1': '\\build\\test1.bin',
'test2': '\\build\\test2.bin',
'test3': '\\build\\test3.bin',
'test4': '\\build\\test4.bin'}
self.test_by_names = None
self.skip_test = None
self.ctest_test_list_mbed_drivers = {'mbed-drivers-test-c_strings' : './build/mbed-drivers-test-c_strings.bin',
'mbed-drivers-test-dev_null' : './build/mbed-drivers-test-dev_null.bin',
'mbed-drivers-test-echo' : './build/mbed-drivers-test-echo.bin',
'mbed-drivers-test-generic_tests' : './build/mbed-drivers-test-generic_tests.bin',
'mbed-drivers-test-rtc' : './build/mbed-drivers-test-rtc.bin',
'mbed-drivers-test-stl_features' : './build/mbed-drivers-test-stl_features.bin',
'mbed-drivers-test-ticker' : './build/mbed-drivers-test-ticker.bin',
'mbed-drivers-test-ticker_2' : './build/mbed-drivers-test-ticker_2.bin',
'mbed-drivers-test-ticker_3' : './build/mbed-drivers-test-ticker_3.bin',
'mbed-drivers-test-timeout' : './build/mbed-drivers-test-timeout.bin',
'mbed-drivers-test-wait_us' : './build/mbed-drivers-test-wait_us.bin'}
self.ctest_test_list_mbed_drivers_ext = {'tests-integration-threaded_blinky' : './build/tests-integration-threaded_blinky.bin',
'tests-mbed_drivers-c_strings' : './build/tests-mbed_drivers-c_strings.bin',
'tests-mbed_drivers-callback' : './build/tests-mbed_drivers-callback.bin',
'tests-mbed_drivers-dev_null' : './build/tests-mbed_drivers-dev_null.bin',
'tests-mbed_drivers-echo' : './build/tests-mbed_drivers-echo.bin',
'tests-mbed_drivers-generic_tests' : './build/tests-mbed_drivers-generic_tests.bin',
'tests-mbed_drivers-rtc' : './build/tests-mbed_drivers-rtc.bin',
'tests-mbed_drivers-stl_features' : './build/tests-mbed_drivers-stl_features.bin',
'tests-mbed_drivers-ticker' : './build/tests-mbed_drivers-ticker.bin',
'tests-mbed_drivers-ticker_2' : './build/tests-mbed_drivers-ticker_2.bin',
'tests-mbed_drivers-ticker_3' : './build/tests-mbed_drivers-ticker_3.bin',
'tests-mbed_drivers-timeout' : './build/tests-mbed_drivers-timeout.bin',
'tests-mbed_drivers-wait_us' : './build/tests-mbed_drivers-wait_us.bin',
'tests-mbedmicro-mbed-attributes' : './build/tests-mbedmicro-mbed-attributes.bin',
'tests-mbedmicro-mbed-call_before_main' : './build/tests-mbedmicro-mbed-call_before_main.bin',
'tests-mbedmicro-mbed-cpp' : './build/tests-mbedmicro-mbed-cpp.bin',
'tests-mbedmicro-mbed-div' : './build/tests-mbedmicro-mbed-div.bin',
'tests-mbedmicro-mbed-heap_and_stack' : './build/tests-mbedmicro-mbed-heap_and_stack.bin',
'tests-mbedmicro-rtos-mbed-basic' : './build/tests-mbedmicro-rtos-mbed-basic.bin',
'tests-mbedmicro-rtos-mbed-isr' : './build/tests-mbedmicro-rtos-mbed-isr.bin',
'tests-mbedmicro-rtos-mbed-mail' : './build/tests-mbedmicro-rtos-mbed-mail.bin',
'tests-mbedmicro-rtos-mbed-mutex' : './build/tests-mbedmicro-rtos-mbed-mutex.bin',
'tests-mbedmicro-rtos-mbed-queue' : './build/tests-mbedmicro-rtos-mbed-queue.bin',
'tests-mbedmicro-rtos-mbed-semaphore' : './build/tests-mbedmicro-rtos-mbed-semaphore.bin',
'tests-mbedmicro-rtos-mbed-signals' : './build/tests-mbedmicro-rtos-mbed-signals.bin',
'tests-mbedmicro-rtos-mbed-threads' : './build/tests-mbedmicro-rtos-mbed-threads.bin',
'tests-mbedmicro-rtos-mbed-timer' : './build/tests-mbedmicro-rtos-mbed-timer.bin',
'tests-storage_abstraction-basicapi' : './build/tests-storage_abstraction-basicapi.bin'}
def tearDown(self):
pass
def test_filter_test_list(self):
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {'test1': '\\build\\test1.bin',
'test2': '\\build\\test2.bin',
'test3': '\\build\\test3.bin',
'test4': '\\build\\test4.bin'}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_skip_test(self):
self.skip_test = 'test1,test2'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {'test3': '\\build\\test3.bin',
'test4': '\\build\\test4.bin'}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_skip_test_invaild(self):
self.skip_test='test1,testXY'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {'test2': '\\build\\test2.bin',
'test3': '\\build\\test3.bin',
'test4': '\\build\\test4.bin'}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_test_by_names(self):
self.test_by_names='test3'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {'test3': '\\build\\test3.bin'}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_test_by_names_invalid(self):
self.test_by_names='test3,testXY'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {'test3': '\\build\\test3.bin'}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_list_is_None_skip_test(self):
self.ctest_test_list = None
self.skip_test='test3'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_list_is_None_test_by_names(self):
self.ctest_test_list = None
self.test_by_names='test3'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_list_is_Empty_skip_test(self):
self.ctest_test_list = {}
self.skip_test='test4'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_list_is_Empty_test_by_names(self):
self.ctest_test_list = {}
self.test_by_names='test4'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list,
self.test_by_names,
self.skip_test)
filtered_test_list = {}
self.assertEqual(filtered_test_list, filtered_ctest_test_list)
def test_prefix_filter_one_star(self):
self.test_by_names='mbed-drivers-test-t*'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers,
self.test_by_names,
self.skip_test)
expected = ['mbed-drivers-test-ticker',
'mbed-drivers-test-ticker_2',
'mbed-drivers-test-ticker_3',
'mbed-drivers-test-timeout']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
def test_prefix_filter_one_star_and_no_star(self):
self.test_by_names='mbed-drivers-test-t*,mbed-drivers-test-rtc'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers,
self.test_by_names,
self.skip_test)
expected = ['mbed-drivers-test-ticker',
'mbed-drivers-test-ticker_2',
'mbed-drivers-test-ticker_3',
'mbed-drivers-test-timeout',
'mbed-drivers-test-rtc']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
def test_prefix_filter_no_star(self):
self.test_by_names='mbed-drivers-test-ticker_2,mbed-drivers-test-rtc,mbed-drivers-test-ticker'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers,
self.test_by_names,
self.skip_test)
expected = ['mbed-drivers-test-ticker',
'mbed-drivers-test-ticker_2',
'mbed-drivers-test-rtc']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
def test_prefix_filter_merge_n_and_i(self):
self.test_by_names='mbed-drivers-test-ticker_2,mbed-drivers-test-ticker_3,mbed-drivers-test-rtc,mbed-drivers-test-ticker'
self.skip_test = 'mbed-drivers-test-ticker_3'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers,
self.test_by_names,
self.skip_test)
expected = ['mbed-drivers-test-ticker',
'mbed-drivers-test-ticker_2',
'mbed-drivers-test-rtc']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
def test_prefix_filter_merge_n_and_i_repeated(self):
self.test_by_names='mbed-drivers-test-ticker_2,mbed-drivers-test-ticker_3,mbed-drivers-test-rtc,mbed-drivers-test-ticker'
self.skip_test = 'mbed-drivers-test-ticker_3,mbed-drivers-test-ticker_3'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers,
self.test_by_names,
self.skip_test)
expected = ['mbed-drivers-test-ticker',
'mbed-drivers-test-ticker_2',
'mbed-drivers-test-rtc']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
def test_prefix_filter_merge_n_and_i_missing(self):
self.test_by_names='mbed-drivers-test-ticker_2,mbed-drivers-test-ticker_3,mbed-drivers-test-rtc,mbed-drivers-test-ticker'
self.skip_test = 'mbed-drivers-test-ticker_XXX'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers,
self.test_by_names,
self.skip_test)
expected = ['mbed-drivers-test-ticker',
'mbed-drivers-test-ticker_2',
'mbed-drivers-test-ticker_3',
'mbed-drivers-test-rtc']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
def test_prefix_filter_merge_n_multi_star(self):
self.test_by_names='tests-mbedmicro-mbed*,tests-mbedmicro-rtos*'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers_ext,
self.test_by_names,
self.skip_test)
expected = ['tests-mbedmicro-mbed-attributes',
'tests-mbedmicro-mbed-call_before_main',
'tests-mbedmicro-mbed-cpp',
'tests-mbedmicro-mbed-div',
'tests-mbedmicro-mbed-heap_and_stack',
'tests-mbedmicro-rtos-mbed-basic',
'tests-mbedmicro-rtos-mbed-isr',
'tests-mbedmicro-rtos-mbed-mail',
'tests-mbedmicro-rtos-mbed-mutex',
'tests-mbedmicro-rtos-mbed-queue',
'tests-mbedmicro-rtos-mbed-semaphore',
'tests-mbedmicro-rtos-mbed-signals',
'tests-mbedmicro-rtos-mbed-threads',
'tests-mbedmicro-rtos-mbed-timer']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
def test_prefix_filter_merge_n_multi_star_and_i(self):
self.test_by_names='tests-mbedmicro-mbed*,tests-mbedmicro-rtos*'
self.skip_test='tests-mbedmicro-rtos-mbed-isr,tests-mbedmicro-rtos-mbed-semaphore,tests-mbedmicro-mbed-call_before_main'
filtered_ctest_test_list = mbed_greentea_cli.create_filtered_test_list(self.ctest_test_list_mbed_drivers_ext,
self.test_by_names,
self.skip_test)
expected = ['tests-mbedmicro-mbed-attributes',
#'tests-mbedmicro-mbed-call_before_main',
'tests-mbedmicro-mbed-cpp',
'tests-mbedmicro-mbed-div',
'tests-mbedmicro-mbed-heap_and_stack',
'tests-mbedmicro-rtos-mbed-basic',
#'tests-mbedmicro-rtos-mbed-isr',
'tests-mbedmicro-rtos-mbed-mail',
'tests-mbedmicro-rtos-mbed-mutex',
'tests-mbedmicro-rtos-mbed-queue',
#'tests-mbedmicro-rtos-mbed-semaphore',
'tests-mbedmicro-rtos-mbed-signals',
'tests-mbedmicro-rtos-mbed-threads',
'tests-mbedmicro-rtos-mbed-timer']
self.assertEqual(len(expected), len(filtered_ctest_test_list))
self.assertEqual(set(filtered_ctest_test_list.keys()), set(expected))
if __name__ == '__main__':
unittest.main()

View File

@ -1,232 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import os
import unittest
from mbed_greentea.tests_spec import Test, TestBinary, TestBuild, TestSpec
simple_test_spec = {
"builds": {
"K64F-ARM": {
"platform": "K64F",
"toolchain": "ARM",
"base_path": "./.build/K64F/ARM",
"baud_rate": 115200,
"tests": {
"mbed-drivers-test-generic_tests":{
"binaries":[
{
"binary_type": "bootable",
"path": "./.build/K64F/ARM/mbed-drivers-test-generic_tests.bin"
}
]
},
"mbed-drivers-test-c_strings":{
"binaries":[
{
"binary_type": "bootable",
"path": "./.build/K64F/ARM/mbed-drivers-test-c_strings.bin"
}
]
}
}
},
"K64F-GCC": {
"platform": "K64F",
"toolchain": "GCC_ARM",
"base_path": "./.build/K64F/GCC_ARM",
"baud_rate": 9600,
"tests": {
"mbed-drivers-test-generic_tests":{
"binaries":[
{
"binary_type": "bootable",
"path": "./.build/K64F/GCC_ARM/mbed-drivers-test-generic_tests.bin"
}
]
}
}
}
}
}
class TestsSpecFunctionality(unittest.TestCase):
def setUp(self):
self.ts_2_builds = simple_test_spec
def tearDown(self):
pass
def test_example(self):
self.assertEqual(True, True)
self.assertNotEqual(True, False)
def test_initialise_test_spec_with_filename(self):
root_path = os.path.dirname(os.path.realpath(__file__))
spec_path = os.path.join(root_path, "resources", "test_spec.json")
self.test_spec = TestSpec(spec_path)
test_builds = self.test_spec.get_test_builds()
build = list(filter(lambda x: x.get_name() == "K64F-ARM", test_builds))[0]
self.assertEqual(build.get_name(), "K64F-ARM")
self.assertEqual(build.get_platform(), "K64F")
self.assertEqual(build.get_baudrate(), 9600)
self.assertEqual(build.get_path(), "./BUILD/K64F/ARM")
self.assertEqual(len(build.get_tests()), 2)
self.assertTrue("tests-example-1" in build.get_tests())
self.assertTrue("tests-example-2" in build.get_tests())
test = build.get_tests()["tests-example-1"]
self.assertEqual(test.get_name(), "tests-example-1")
self.assertEqual(test.get_binary().get_path(), "./BUILD/K64F/ARM/tests-mbedmicro-rtos-mbed-mail.bin")
self.assertIs(type(test_builds), list)
self.assertEqual(len(test_builds), 2)
def test_initialise_test_spec_with_invalid_filename(self):
root_path = os.path.dirname(os.path.realpath(__file__))
spec_path = os.path.join(root_path, "resources", "null.json")
self.test_spec = TestSpec(spec_path)
test_builds = self.test_spec.get_test_builds()
def test_manually_add_test_binary(self):
test_name = "example-test"
test_path = "test-path"
test = Test(test_name)
self.assertEqual(test.get_name(), test_name)
self.assertEqual(test.get_binary(), None)
test.add_binary(test_path, "bootable")
self.assertEqual(test.get_binary().get_path(), test_path)
def test_manually_add_test_to_build(self):
name = "example-test"
test = Test(name)
test_build = TestBuild("build", "K64F", "ARM", 9600, "./")
self.assertEqual(len(test_build.get_tests()), 0)
test_build.add_test(name, test)
self.assertEqual(len(test_build.get_tests()), 1)
self.assertTrue(name in test_build.get_tests())
def test_manually_add_test_build_to_test_spec(self):
test_name = "example-test"
test = Test(test_name)
test_spec = TestSpec(None)
build_name = "example-build"
test_build = TestBuild(build_name, "K64F", "ARM", 9600, "./")
test_build.add_test(test_name, test)
self.assertEqual(len(test_spec.get_test_builds()), 0)
test_spec.add_test_builds(build_name, test_build)
self.assertEqual(len(test_spec.get_test_builds()), 1)
self.assertTrue(build_name in test_spec.get_test_builds()[0].get_name())
def test_get_test_builds(self):
self.test_spec = TestSpec()
self.test_spec.parse(self.ts_2_builds)
test_builds = self.test_spec.get_test_builds()
self.assertIs(type(test_builds), list)
self.assertEqual(len(test_builds), 2)
def test_get_test_builds_names(self):
self.test_spec = TestSpec()
self.test_spec.parse(self.ts_2_builds)
test_builds = self.test_spec.get_test_builds()
test_builds_names = [x.get_name() for x in self.test_spec.get_test_builds()]
self.assertEqual(len(test_builds_names), 2)
self.assertIs(type(test_builds_names), list)
self.assertIn('K64F-ARM', test_builds_names)
self.assertIn('K64F-GCC', test_builds_names)
def test_get_test_build(self):
self.test_spec = TestSpec()
self.test_spec.parse(self.ts_2_builds)
test_builds = self.test_spec.get_test_builds()
test_builds_names = [x.get_name() for x in self.test_spec.get_test_builds()]
self.assertEqual(len(test_builds_names), 2)
self.assertIs(type(test_builds_names), list)
self.assertNotEqual(None, self.test_spec.get_test_build('K64F-ARM'))
self.assertNotEqual(None, self.test_spec.get_test_build('K64F-GCC'))
def test_get_build_properties(self):
self.test_spec = TestSpec()
self.test_spec.parse(self.ts_2_builds)
test_builds = self.test_spec.get_test_builds()
test_builds_names = [x.get_name() for x in self.test_spec.get_test_builds()]
self.assertEqual(len(test_builds_names), 2)
self.assertIs(type(test_builds_names), list)
k64f_arm = self.test_spec.get_test_build('K64F-ARM')
k64f_gcc = self.test_spec.get_test_build('K64F-GCC')
self.assertNotEqual(None, k64f_arm)
self.assertNotEqual(None, k64f_gcc)
self.assertEqual('K64F', k64f_arm.get_platform())
self.assertEqual('ARM', k64f_arm.get_toolchain())
self.assertEqual(115200, k64f_arm.get_baudrate())
self.assertEqual('K64F', k64f_gcc.get_platform())
self.assertEqual('GCC_ARM', k64f_gcc.get_toolchain())
self.assertEqual(9600, k64f_gcc.get_baudrate())
def test_get_test_builds_properties(self):
self.test_spec = TestSpec()
self.test_spec.parse(self.ts_2_builds)
test_builds = self.test_spec.get_test_builds()
test_builds_names = [x.get_name() for x in self.test_spec.get_test_builds()]
self.assertIn('K64F-ARM', test_builds_names)
self.assertIn('K64F-GCC', test_builds_names)
def test_get_test_builds_names_filter_by_names(self):
self.test_spec = TestSpec()
self.test_spec.parse(self.ts_2_builds)
filter_by_names = ['K64F-ARM']
test_builds = self.test_spec.get_test_builds(filter_by_names=filter_by_names)
test_builds_names = [x.get_name() for x in test_builds]
self.assertEqual(len(test_builds_names), 1)
self.assertIn('K64F-ARM', test_builds_names)
filter_by_names = ['K64F-GCC']
test_builds = self.test_spec.get_test_builds(filter_by_names=filter_by_names)
test_builds_names = [x.get_name() for x in test_builds]
self.assertEqual(len(test_builds_names), 1)
self.assertIn('K64F-GCC', test_builds_names)
filter_by_names = ['SOME-PLATFORM-NAME']
test_builds = self.test_spec.get_test_builds(filter_by_names=filter_by_names)
test_builds_names = [x.get_name() for x in test_builds]
self.assertEqual(len(test_builds_names), 0)
if __name__ == '__main__':
unittest.main()

View File

@ -1,87 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import os
import shutil
import tempfile
import unittest
from mbed_greentea import mbed_yotta_api
def generate_paths_and_write(data):
# Generate some dummy temp directories
curr_dir = os.getcwd()
temp0_dir = tempfile.mkdtemp()
temp1_dir = os.mkdir(os.path.join(temp0_dir, "yotta_targets"))
temp2_dir = os.mkdir(os.path.join(temp0_dir, "yotta_targets", "target_name"))
with open(os.path.join(os.path.join(temp0_dir, "yotta_targets", "target_name"), "target.json"), "w") as f:
f.write(data)
return temp0_dir
class YottaApiFunctionality(unittest.TestCase):
def setUp(self):
self.curr_dir = os.getcwd()
def tearDown(self):
pass
def test_build_with_yotta_invalid_target_name(self):
res, ret = mbed_yotta_api.build_with_yotta("invalid_name", True, build_to_debug=True)
self.assertEqual(res, False)
res, ret = mbed_yotta_api.build_with_yotta("invalid_name", True, build_to_release=True)
self.assertEqual(res, False)
def test_get_platform_name_from_yotta_target_invalid_target_file(self):
temp0_dir = generate_paths_and_write("test")
os.chdir(temp0_dir)
result = mbed_yotta_api.get_platform_name_from_yotta_target("target_name")
self.assertEqual(result, None)
os.chdir(self.curr_dir)
shutil.rmtree(temp0_dir)
def test_get_platform_name_from_yotta_target_missing_keywords(self):
temp0_dir = generate_paths_and_write("{}")
os.chdir(temp0_dir)
result = mbed_yotta_api.get_platform_name_from_yotta_target("target_name")
self.assertEqual(result, None)
os.chdir(self.curr_dir)
shutil.rmtree(temp0_dir)
def test_get_platform_name_from_yotta_target_missing_targets(self):
temp0_dir = generate_paths_and_write('{"keywords": []}')
os.chdir(temp0_dir)
result = mbed_yotta_api.get_platform_name_from_yotta_target("target_name")
self.assertEqual(result, None)
os.chdir(self.curr_dir)
shutil.rmtree(temp0_dir)
def test_get_platform_name_from_yotta_target_valid_targets(self):
temp0_dir = generate_paths_and_write('{"keywords": ["mbed-target:K64F"]}')
os.chdir(temp0_dir)
result = mbed_yotta_api.get_platform_name_from_yotta_target("target_name")
self.assertEqual(result, "K64F")
os.chdir(self.curr_dir)
shutil.rmtree(temp0_dir)

View File

@ -1,175 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import unittest
from mbed_greentea.mbed_yotta_module_parse import YottaConfig
class YOttaConfigurationParse(unittest.TestCase):
def setUp(self):
self.YOTTA_CONFIG_LONG = {
"minar": {
"initial_event_pool_size": 50,
"additional_event_pools_size": 100
},
"mbed-os": {
"net": {
"stacks": {
"lwip": True
}
},
"stdio": {
"default-baud": 9600
}
},
"cmsis": {
"nvic": {
"ram_vector_address": "0x1FFF0000",
"flash_vector_address": "0x0",
"user_irq_offset": 16,
"user_irq_number": 86
}
},
"hardware": {
"pins": {
"LED_RED": "PTB22",
"LED_GREEN": "PTE26",
"LED_BLUE": "PTB21",
"LED1": "LED_RED",
"LED2": "LED_GREEN",
"LED3": "LED_BLUE",
"LED4": "LED_RED",
"SW2": "PTC6",
"SW3": "PTA4",
"USBTX": "PTB17",
"USBRX": "PTB16",
"D0": "PTC16",
"D1": "PTC17",
"D2": "PTB9",
"D3": "PTA1",
"D4": "PTB23",
"D5": "PTA2",
"D6": "PTC2",
"D7": "PTC3",
"D8": "PTA0",
"D9": "PTC4",
"D10": "PTD0",
"D11": "PTD2",
"D12": "PTD3",
"D13": "PTD1",
"D14": "PTE25",
"D15": "PTE24",
"I2C_SCL": "D15",
"I2C_SDA": "D14",
"A0": "PTB2",
"A1": "PTB3",
"A2": "PTB10",
"A3": "PTB11",
"A4": "PTC10",
"A5": "PTC11",
"DAC0_OUT": "0xFEFE"
},
"test-pins": {
"spi": {
"mosi": "PTD2",
"miso": "PTD3",
"sclk": "PTD1",
"ssel": "PTD0"
},
"i2c": {
"sda": "PTE25",
"scl": "PTE24"
},
"serial": {
"tx": "PTC17",
"rx": "PTD2"
}
}
},
"uvisor": {
"present": 1
},
"arch": {
"arm": {}
},
"mbed": {}
}
self.YOTTA_CONFIG_SHORT = {
"minar": {
"initial_event_pool_size": 50,
"additional_event_pools_size": 100
},
"mbed-os": {
"net": {
"stacks": {
"lwip": True
}
},
"stdio": {
"default-baud": 38400
}
},
"cmsis": {
"nvic": {
"ram_vector_address": "0x1FFF0000",
"flash_vector_address": "0x0",
"user_irq_offset": 16,
"user_irq_number": 86
}
},
}
def tearDown(self):
pass
def test_get_baudrate_9600(self):
yotta_config = YottaConfig()
yotta_config.set_yotta_config(self.YOTTA_CONFIG_LONG)
self.assertEqual(yotta_config.get_baudrate(), 9600)
def test_get_baudrate_38400(self):
yotta_config = YottaConfig()
yotta_config.set_yotta_config(self.YOTTA_CONFIG_SHORT)
self.assertEqual(yotta_config.get_baudrate(), 38400)
def test_get_baudrate_default_115200(self):
yotta_config = YottaConfig()
self.assertEqual(115200, yotta_config.DEFAULT_BAUDRATE)
def test_get_baudrate_default_115200_no_yotta_config(self):
yotta_config = YottaConfig()
self.assertEqual(yotta_config.get_baudrate(), yotta_config.DEFAULT_BAUDRATE)
def test_get_baudrate_None(self):
yotta_config = YottaConfig()
yotta_config.set_yotta_config(None)
self.assertEqual(yotta_config.get_baudrate(), yotta_config.DEFAULT_BAUDRATE)
self.assertEqual(115200, yotta_config.DEFAULT_BAUDRATE)
def test_get_test_pins(self):
yotta_config = YottaConfig()
yotta_config.set_yotta_config(self.YOTTA_CONFIG_LONG)
self.assertEqual(yotta_config.get_baudrate(), 9600)
self.assertIn('spi', yotta_config.get_test_pins())
self.assertIn('i2c', yotta_config.get_test_pins())
self.assertIn('serial', yotta_config.get_test_pins())
if __name__ == '__main__':
unittest.main()

View File

@ -1,228 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import unittest
from mbed_greentea.mbed_yotta_module_parse import YottaModule
class YOttaConfigurationParse(unittest.TestCase):
def setUp(self):
# greentea-client defined in 'dependencies' and 'testDependencies'
self.YOTTA_MODULE_LONG = {
"name": "utest",
"version": "1.9.1",
"description": "Simple test harness with unity and greentea integration.",
"keywords": [
"greentea",
"testing",
"unittest",
"unity",
"unit",
"test",
"asynchronous",
"async",
"mbed-official"
],
"author": "Niklas Hauser <niklas.hauser@arm.com>",
"license": "Apache-2.0",
"dependencies": {
"minar": "^1.0.0",
"core-util": "^1.0.1",
"compiler-polyfill": "^1.2.0",
"mbed-drivers": "~0.12.0",
"greentea-client": "^0.1.2"
},
"testDependencies": {
"unity": "^2.0.1",
"greentea-client": "^0.1.2"
}
}
# greentea-client defined in 'dependencies'
self.YOTTA_MODULE_LONG_IN_DEP = {
"name": "utest",
"version": "1.9.1",
"description": "Simple test harness with unity and greentea integration.",
"keywords": [
"greentea",
"testing",
"unittest",
"unity",
"unit",
"test",
"asynchronous",
"async",
"mbed-official"
],
"author": "Niklas Hauser <niklas.hauser@arm.com>",
"license": "Apache-2.0",
"dependencies": {
"minar": "^1.0.0",
"core-util": "^1.0.1",
"compiler-polyfill": "^1.2.0",
"mbed-drivers": "~0.12.0",
"greentea-client": "^0.1.2"
},
"testDependencies": {
"unity": "^2.0.1",
}
}
# greentea-client defined in 'testDependencies'
self.YOTTA_MODULE_LONG_IN_TESTDEP = {
"name": "utest",
"version": "1.9.1",
"description": "Simple test harness with unity and greentea integration.",
"keywords": [
"greentea",
"testing",
"unittest",
"unity",
"unit",
"test",
"asynchronous",
"async",
"mbed-official"
],
"author": "Niklas Hauser <niklas.hauser@arm.com>",
"license": "Apache-2.0",
"dependencies": {
"minar": "^1.0.0",
"core-util": "^1.0.1",
"compiler-polyfill": "^1.2.0",
"mbed-drivers": "~0.12.0"
},
"testDependencies": {
"unity": "^2.0.1",
"greentea-client": "^0.1.2"
}
}
# No dependency to greentea-client
self.YOTTA_MODULE_LONG_NO_DEP = {
"name": "utest",
"version": "1.9.1",
"description": "Simple test harness with unity and greentea integration.",
"keywords": [
"greentea",
"testing",
"unittest",
"unity",
"unit",
"test",
"asynchronous",
"async",
"mbed-official"
],
"author": "Niklas Hauser <niklas.hauser@arm.com>",
"license": "Apache-2.0",
"dependencies": {
"minar": "^1.0.0",
"core-util": "^1.0.1",
"compiler-polyfill": "^1.2.0",
"mbed-drivers": "~0.12.0"
},
"testDependencies": {
"unity": "^2.0.1"
}
}
# Yotta module itself is 'greentea-client'
self.GREENTEA_CLIENT_MODULE = {
"name": "greentea-client",
"version": "0.1.6",
"description": "greentea client for mbed devices.",
"keywords": [
"greentea",
"greentea-client",
"mbedgt"
],
"author": "Przemyslaw.Wirkus <Przemyslaw.Wirkus@arm.com>",
"homepage": "https://github.com/ARMmbed/greentea-client",
"repository": {
"url": "git@github.com:ARMmbed/greentea-client.git",
"type": "git"
},
"license": "Apache-2.0",
"dependencies": {
},
"testDependencies": {
"utest": "^1.10.0",
"unity": "^2.0.0"
}
}
def tearDown(self):
pass
def test_get_name(self):
yotta_module = YottaModule()
# Modules using Greentea >= v0.2.0
for module_json in [self.YOTTA_MODULE_LONG,
self.YOTTA_MODULE_LONG_IN_DEP,
self.YOTTA_MODULE_LONG_IN_TESTDEP,
self.YOTTA_MODULE_LONG_NO_DEP]:
yotta_module.set_yotta_module(module_json)
self.assertEqual('utest', yotta_module.get_name())
# 'greentea-client' module itself
yotta_module.set_yotta_module(self.GREENTEA_CLIENT_MODULE)
self.assertEqual('greentea-client', yotta_module.get_name())
def test_get_dict_items(self):
yotta_module = YottaModule()
yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG)
self.assertEqual('Simple test harness with unity and greentea integration.', yotta_module.get_data().get('description'))
self.assertEqual('Apache-2.0', yotta_module.get_data().get('license'))
def test_check_greentea_client_in_dep(self):
yotta_module = YottaModule()
yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG)
self.assertTrue(yotta_module.check_greentea_client())
yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG_IN_DEP)
self.assertTrue(yotta_module.check_greentea_client())
yotta_module.set_yotta_module(self.GREENTEA_CLIENT_MODULE)
self.assertTrue(yotta_module.check_greentea_client())
yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG_NO_DEP)
self.assertFalse(yotta_module.check_greentea_client())
def test_check_greentea_client_in_test_dep(self):
yotta_module = YottaModule()
yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG)
self.assertTrue(yotta_module.check_greentea_client())
yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG_IN_TESTDEP)
self.assertTrue(yotta_module.check_greentea_client())
yotta_module.set_yotta_module(self.GREENTEA_CLIENT_MODULE)
self.assertTrue(yotta_module.check_greentea_client())
yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG_NO_DEP)
self.assertFalse(yotta_module.check_greentea_client())
if __name__ == '__main__':
unittest.main()

View File

@ -1,55 +0,0 @@
"""
mbed SDK
Copyright (c) 2017 ARM Limited
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.
"""
import unittest
from mock import patch
from mbed_greentea.mbed_report_api import exporter_html, \
exporter_memory_metrics_csv, exporter_testcase_junit, \
exporter_testcase_text, exporter_text, exporter_json
class ReportEmitting(unittest.TestCase):
report_fns = [exporter_html, exporter_memory_metrics_csv,
exporter_testcase_junit, exporter_testcase_text,
exporter_text, exporter_json]
def test_report_zero_tests(self):
test_data = {}
for report_fn in self.report_fns:
report_fn(test_data)
def test_report_zero_testcases(self):
test_data = {
'k64f-gcc_arm': {
'garbage_test_suite' :{
u'single_test_result': u'NOT_RAN',
u'elapsed_time': 0.0,
u'build_path': u'N/A',
u'build_path_abs': u'N/A',
u'copy_method': u'N/A',
u'image_path': u'N/A',
u'single_test_output': u'\x80abc' ,
u'platform_name': u'k64f',
u'test_bin_name': u'N/A',
u'testcase_result': {},
}
}
}
for report_fn in self.report_fns:
report_fn(test_data)

View File

@ -1,6 +0,0 @@
# CMake generated Testfile for
# Source directory: c:/Work2/mbed-client/test
# Build directory: c:/Work2/mbed-client/build/frdm-k64f-gcc/test
#
# This file includes the relevant testing commands required for
# testing this directory and lists subdirectories to be tested as well.

View File

@ -1,9 +0,0 @@
# CMake generated Testfile for
# Source directory: c:/Work2/mbed-client/test
# Build directory: c:/Work2/mbed-client/build/frdm-k64f-gcc/test
#
# This file includes the relevant testing commands required for
# testing this directory and lists subdirectories to be tested as well.
add_test(mbed-client-test-mbedclient-smokeTest "mbed-client-test-mbedclient-smokeTest")
add_test(mbed-client-test-helloworld-mbedclient "mbed-client-test-helloworld-mbedclient")
add_test()

View File

@ -1,44 +0,0 @@
{
"builds": {
"K64F-ARM": {
"platform": "K64F",
"toolchain": "ARM",
"base_path": "./BUILD/K64F/ARM",
"baud_rate": 9600,
"tests": {
"tests-example-1": {
"binaries": [
{
"binary_type": "bootable",
"path": "./BUILD/K64F/ARM/tests-mbedmicro-rtos-mbed-mail.bin"
}
]
},
"tests-example-2": {
"binaries": [
{
"binary_type": "bootable",
"path": "./BUILD/K64F/ARM/tests-mbed_drivers-c_strings.bin"
}
]
}
}
},
"K64F-GCC": {
"platform": "K64F",
"toolchain": "GCC_ARM",
"base_path": "./BUILD/K64F/GCC_ARM",
"baud_rate": 9600,
"tests": {
"tests-example-7": {
"binaries": [
{
"binary_type": "bootable",
"path": "./BUILD/K64F/GCC_ARM/tests-mbedmicro-rtos-mbed-mail.bin"
}
]
}
}
}
}
}

View File

@ -1,43 +0,0 @@
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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.
"""
import unittest
from mbed_host_tests.host_tests_plugins.module_reset_mbed import HostTestPluginResetMethod_Mbed
class HostOSDetectionTestCase(unittest.TestCase):
def setUp(self):
self.plugin_reset_mbed = HostTestPluginResetMethod_Mbed()
def tearDown(self):
pass
def test_examle(self):
pass
def test_pyserial_version_detect(self):
self.assertEqual(1.0, self.plugin_reset_mbed.get_pyserial_version("1.0"))
self.assertEqual(1.0, self.plugin_reset_mbed.get_pyserial_version("1.0.0"))
self.assertEqual(2.7, self.plugin_reset_mbed.get_pyserial_version("2.7"))
self.assertEqual(2.7, self.plugin_reset_mbed.get_pyserial_version("2.7.1"))
self.assertEqual(3.0, self.plugin_reset_mbed.get_pyserial_version("3.0"))
self.assertEqual(3.0, self.plugin_reset_mbed.get_pyserial_version("3.0.1"))
if __name__ == '__main__':
unittest.main()

View File

@ -20,7 +20,6 @@ import os
import errno
import logging
import re
import pkg_resources
import json
from mock import patch, MagicMock
from copy import deepcopy

View File

@ -418,7 +418,11 @@ Remount count: 0
self.assertIsNotNone(ret_with_details[0])
self.assertEqual(ret[0]['target_id'], new_device_id)
self.assertEqual(ret_with_details[0]['daplink_automation_allowed'], '0')
self.assertDictContainsSubset(ret[0], ret_with_details[0])
# Below is the recommended replacement for assertDictContainsSubset().
# See: https://stackoverflow.com/a/59777678/7083698
self.assertEqual(ret_with_details[0], {**ret_with_details[0], **ret[0]})
_read_htm.assert_called_with(device['mount_point'])
_up_details.assert_called_with(device['mount_point'])
@ -494,7 +498,7 @@ Remount count: 0
self.assertIsNotNone(ret_with_details[0])
self.assertEqual(ret[0]['target_id'], new_device_id)
self.assertEqual(ret_with_details[0]['daplink_automation_allowed'], '0')
self.assertDictContainsSubset(ret[0], ret_with_details[0])
self.assertEqual(ret_with_details[0], {**ret_with_details[0], **ret[0]})
_read_htm.assert_called_with(device['mount_point'])
_up_details.assert_called_with(device['mount_point'])
@ -516,7 +520,7 @@ Remount count: 0
self.assertIsNotNone(ret_with_details[0])
self.assertEqual(ret[0]['target_id'], new_device_id)
self.assertEqual(ret_with_details[0]['daplink_automation_allowed'], '0')
self.assertDictContainsSubset(ret[0], ret_with_details[0])
self.assertEqual(ret_with_details[0], {**ret_with_details[0], **ret[0]})
_read_htm.assert_called_with(device['mount_point'])
_up_details.assert_called_with(device['mount_point'])

View File

@ -413,7 +413,11 @@ Remount count: 0
self.assertIsNotNone(ret_with_details[0])
self.assertEqual(ret[0]['target_id'], new_device_id)
self.assertEqual(ret_with_details[0]['daplink_automation_allowed'], '0')
self.assertDictContainsSubset(ret[0], ret_with_details[0])
# Below is the recommended replacement for assertDictContainsSubset().
# See: https://stackoverflow.com/a/59777678/7083698
self.assertEqual(ret_with_details[0], {**ret_with_details[0], **ret[0]})
_read_htm.assert_called_with(device['mount_point'])
_up_details.assert_called_with(device['mount_point'])
@ -489,7 +493,7 @@ Remount count: 0
self.assertIsNotNone(ret_with_details[0])
self.assertEqual(ret[0]['target_id'], new_device_id)
self.assertEqual(ret_with_details[0]['daplink_automation_allowed'], '0')
self.assertDictContainsSubset(ret[0], ret_with_details[0])
self.assertEqual(ret_with_details[0], {**ret_with_details[0], **ret[0]})
_read_htm.assert_called_with(device['mount_point'])
_up_details.assert_called_with(device['mount_point'])
@ -511,7 +515,7 @@ Remount count: 0
self.assertIsNotNone(ret_with_details[0])
self.assertEqual(ret[0]['target_id'], new_device_id)
self.assertEqual(ret_with_details[0]['daplink_automation_allowed'], '0')
self.assertDictContainsSubset(ret[0], ret_with_details[0])
self.assertEqual(ret_with_details[0], {**ret_with_details[0], **ret[0]})
_read_htm.assert_called_with(device['mount_point'])
_up_details.assert_called_with(device['mount_point'])

View File

@ -1,7 +0,0 @@
python3-pytest
python3-factory-boy
python3-requests-mock
python3-mock
python3-coverage
python3-bs4
python3-lxml

View File

@ -1,7 +1,3 @@
## NOTE: This file must be kept in sync with requirements.apt.txt in the same folder.
## That file gives the equivalent package names of these packages in the apt package manager
## for Ubuntu & Debian
# These are the requirements for running the Python package tests.
# They are in addition to the requirements.txt under mbedos/tools/.
pytest

View File

@ -11,7 +11,7 @@
set -e
PYTHON=python3
PYTHON=python
# Comma separated list of directories to exclude from coverage
COVERAGE_EXCLUDES='--omit=python_tests/*'
@ -31,9 +31,6 @@ $PYTHON -m coverage run "$COVERAGE_EXCLUDES" -a -m pytest python_tests/scancode_
# test case filenames for some packages. So, the "-p *.py" argument is needed to
# make it look for any files as tests, not just ones ending in _test.py.
echo ">> Running unittests for mbed_greentea package"
$PYTHON -m coverage run "$COVERAGE_EXCLUDES" -a -m unittest discover -p '*.py' python_tests.mbed_greentea
echo ">> Running unittests for mbed_host_tests package"
$PYTHON -m coverage run "$COVERAGE_EXCLUDES" -a -m unittest discover -p '*.py' python_tests.mbed_host_tests

View File

@ -1,7 +1,3 @@
## NOTE: This file must be kept in sync with requirements.apt.txt in the same folder.
## That file gives the equivalent package names of these packages in the apt package manager
## for Ubuntu & Debian
PrettyTable<=1.0.1; python_version < '3.6'
prettytable>=2.0,<4.0; python_version >= '3.6'
future>=0.18.0,<1.0
@ -27,6 +23,9 @@ colorama>=0.3,<0.5
json5
humanize~=4.9.0
# Install pyocd so that it's available in the venv if the user chooses to use it
pyocd
# beautifulsoup only needed for USB device detection on Mac
beautifulsoup4; sys_platform == 'darwin'
lxml; sys_platform == 'darwin'
@ -36,4 +35,7 @@ cryptography
cbor
# Needed for downloading CMSIS MCU descriptions
cmsis-pack-manager~=0.5.0
cmsis-pack-manager~=0.5.0
# cffi is a dependency of cmsis-pack-manager, but cffi needs a prerelease to support Python 3.13
cffi>=1.17.0rc1; python_version >= '3.13'