├── .coveragerc
├── .flake8
├── .github
├── issue_template.md
└── pull_request_template.md
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── MANIFEST.in
├── README.md
├── azure-pipelines.yml
├── docs
├── package_versioning.png
├── package_versioning.xml
├── release.md
└── test_plan.md
├── packages
├── mbed-greentea
│ ├── .coveragerc
│ ├── MANIFEST.in
│ ├── README.md
│ ├── mbed_greentea
│ │ ├── __init__.py
│ │ ├── __main__.py
│ │ ├── cmake_handlers.py
│ │ ├── mbed_common_api.py
│ │ ├── mbed_coverage_api.py
│ │ ├── mbed_greentea_cli.py
│ │ ├── mbed_greentea_dlm.py
│ │ ├── mbed_greentea_hooks.py
│ │ ├── mbed_greentea_log.py
│ │ ├── mbed_report_api.py
│ │ ├── mbed_target_info.py
│ │ ├── mbed_test_api.py
│ │ ├── mbed_yotta_api.py
│ │ ├── mbed_yotta_module_parse.py
│ │ └── tests_spec.py
│ ├── requirements.txt
│ ├── setup.py
│ ├── test
│ │ ├── __init__.py
│ │ ├── basic.py
│ │ ├── mbed_gt_cli.py
│ │ ├── mbed_gt_cmake_handlers.py
│ │ ├── mbed_gt_coverage_api.py
│ │ ├── mbed_gt_greentea_dlm.py
│ │ ├── mbed_gt_hooks.py
│ │ ├── mbed_gt_report_api.py
│ │ ├── mbed_gt_target_info.py
│ │ ├── mbed_gt_test_api.py
│ │ ├── mbed_gt_test_filtered_test_list.py
│ │ ├── mbed_gt_tests_spec.py
│ │ ├── mbed_gt_yotta_api.py
│ │ ├── mbed_gt_yotta_config.py
│ │ ├── mbed_gt_yotta_module.py
│ │ ├── report_api.py
│ │ └── resources
│ │ │ ├── empty
│ │ │ └── test
│ │ │ │ └── CTestTestfile.cmake
│ │ │ ├── not-empty
│ │ │ └── test
│ │ │ │ └── CTestTestfile.cmake
│ │ │ └── test_spec.json
│ └── test_requirements.txt
├── mbed-host-tests
│ ├── .coveragerc
│ ├── MANIFEST.in
│ ├── README.md
│ ├── mbed_host_tests
│ │ ├── __init__.py
│ │ ├── host_tests
│ │ │ ├── __init__.py
│ │ │ ├── base_host_test.py
│ │ │ ├── default_auto.py
│ │ │ ├── detect_auto.py
│ │ │ ├── dev_null_auto.py
│ │ │ ├── echo.py
│ │ │ ├── hello_auto.py
│ │ │ ├── rtc_auto.py
│ │ │ └── wait_us_auto.py
│ │ ├── host_tests_conn_proxy
│ │ │ ├── __init__.py
│ │ │ ├── conn_primitive.py
│ │ │ ├── conn_primitive_fastmodel.py
│ │ │ ├── conn_primitive_remote.py
│ │ │ ├── conn_primitive_serial.py
│ │ │ └── conn_proxy.py
│ │ ├── host_tests_logger
│ │ │ ├── __init__.py
│ │ │ └── ht_logger.py
│ │ ├── host_tests_plugins
│ │ │ ├── __init__.py
│ │ │ ├── host_test_plugins.py
│ │ │ ├── host_test_registry.py
│ │ │ ├── module_copy_jn51xx.py
│ │ │ ├── module_copy_mbed.py
│ │ │ ├── module_copy_mps2.py
│ │ │ ├── module_copy_pyocd.py
│ │ │ ├── module_copy_shell.py
│ │ │ ├── module_copy_silabs.py
│ │ │ ├── module_copy_stlink.py
│ │ │ ├── module_copy_ublox.py
│ │ │ ├── module_power_cycle_mbed.py
│ │ │ ├── module_reset_jn51xx.py
│ │ │ ├── module_reset_mbed.py
│ │ │ ├── module_reset_mps2.py
│ │ │ ├── module_reset_pyocd.py
│ │ │ ├── module_reset_silabs.py
│ │ │ ├── module_reset_stlink.py
│ │ │ └── module_reset_ublox.py
│ │ ├── host_tests_registry
│ │ │ ├── __init__.py
│ │ │ └── host_registry.py
│ │ ├── host_tests_runner
│ │ │ ├── __init__.py
│ │ │ ├── host_test.py
│ │ │ ├── host_test_default.py
│ │ │ └── mbed_base.py
│ │ ├── host_tests_toolbox
│ │ │ ├── __init__.py
│ │ │ └── host_functional.py
│ │ ├── mbedflsh.py
│ │ └── mbedhtrun.py
│ ├── requirements.txt
│ ├── setup.py
│ ├── test
│ │ ├── __init__.py
│ │ ├── basic.py
│ │ ├── basic_ht.py
│ │ ├── conn_primitive_remote.py
│ │ ├── event_callback_decorator.py
│ │ ├── host_registry.py
│ │ ├── host_test_base.py
│ │ ├── host_test_os_detect.py
│ │ ├── host_test_plugins.py
│ │ ├── host_test_scheme.py
│ │ ├── mps2_copy.py
│ │ └── mps2_reset.py
│ └── test_requirements.txt
└── mbed-ls
│ ├── .coveragerc
│ ├── MANIFEST.in
│ ├── README.md
│ ├── mbed_lstools
│ ├── __init__.py
│ ├── darwin.py
│ ├── linux.py
│ ├── lstools_base.py
│ ├── main.py
│ ├── platform_database.py
│ └── windows.py
│ ├── requirements.txt
│ ├── setup.py
│ ├── test
│ ├── __init__.py
│ ├── base.py
│ ├── details_txt.py
│ ├── detect_os.py
│ ├── mbed_htm.py
│ ├── mbedls_toolsbase.py
│ ├── os_darwin.py
│ ├── os_linux_generic.py
│ ├── os_win7.py
│ ├── platform_database.py
│ ├── platform_detection.py
│ └── test_data
│ │ ├── efm32pg_stk3401_jlink
│ │ ├── MBED.HTM
│ │ ├── README.TXT
│ │ ├── sl_kit.html
│ │ └── sl_qsg.html
│ │ ├── k64f_daplink
│ │ ├── DETAILS.TXT
│ │ └── MBED.HTM
│ │ ├── lpc1768
│ │ ├── MBED.HTM
│ │ ├── basic.bin
│ │ └── dirs.bin
│ │ ├── nrf51_microbit
│ │ ├── DETAILS.TXT
│ │ └── MICROBIT.HTM
│ │ ├── nrf52_dk_daplink
│ │ ├── DETAILS.TXT
│ │ └── MBED.HTM
│ │ ├── nrf52_dk_jlink
│ │ ├── MBED.HTM
│ │ ├── README.TXT
│ │ ├── Segger.html
│ │ └── User Guide.html
│ │ └── nucleo_f411re_stlink
│ │ ├── DETAILS.TXT
│ │ └── MBED.HTM
│ └── test_requirements.txt
├── pypi-release.yml
├── requirements.txt
├── setup.py
├── src
└── mbed_os_tools
│ ├── __init__.py
│ ├── detect
│ ├── __init__.py
│ ├── darwin.py
│ ├── linux.py
│ ├── lstools_base.py
│ ├── main.py
│ ├── platform_database.py
│ └── windows.py
│ └── test
│ ├── __init__.py
│ ├── __main__.py
│ ├── cmake_handlers.py
│ ├── host_tests
│ ├── __init__.py
│ ├── base_host_test.py
│ ├── default_auto.py
│ ├── detect_auto.py
│ ├── dev_null_auto.py
│ ├── echo.py
│ ├── hello_auto.py
│ ├── rtc_auto.py
│ └── wait_us_auto.py
│ ├── host_tests_conn_proxy
│ ├── __init__.py
│ ├── conn_primitive.py
│ ├── conn_primitive_fastmodel.py
│ ├── conn_primitive_remote.py
│ ├── conn_primitive_serial.py
│ └── conn_proxy.py
│ ├── host_tests_logger
│ ├── __init__.py
│ └── ht_logger.py
│ ├── host_tests_plugins
│ ├── __init__.py
│ ├── host_test_plugins.py
│ ├── host_test_registry.py
│ ├── module_copy_jn51xx.py
│ ├── module_copy_mbed.py
│ ├── module_copy_mps2.py
│ ├── module_copy_pyocd.py
│ ├── module_copy_shell.py
│ ├── module_copy_silabs.py
│ ├── module_copy_stlink.py
│ ├── module_copy_ublox.py
│ ├── module_power_cycle_mbed.py
│ ├── module_reset_jn51xx.py
│ ├── module_reset_mbed.py
│ ├── module_reset_mps2.py
│ ├── module_reset_pyocd.py
│ ├── module_reset_silabs.py
│ ├── module_reset_stlink.py
│ └── module_reset_ublox.py
│ ├── host_tests_registry
│ ├── __init__.py
│ └── host_registry.py
│ ├── host_tests_runner
│ ├── __init__.py
│ ├── host_test.py
│ ├── host_test_default.py
│ └── mbed_base.py
│ ├── host_tests_toolbox
│ ├── __init__.py
│ └── host_functional.py
│ ├── mbed_common_api.py
│ ├── mbed_coverage_api.py
│ ├── mbed_greentea_cli.py
│ ├── mbed_greentea_dlm.py
│ ├── mbed_greentea_hooks.py
│ ├── mbed_greentea_log.py
│ ├── mbed_report_api.py
│ ├── mbed_target_info.py
│ ├── mbed_test_api.py
│ ├── mbed_yotta_api.py
│ ├── mbed_yotta_module_parse.py
│ └── tests_spec.py
├── test
├── __init__.py
├── detect
│ ├── __init__.py
│ ├── details_txt.py
│ ├── detect_os.py
│ ├── mbed_htm.py
│ ├── mbedls_toolsbase.py
│ ├── os_darwin.py
│ ├── os_linux_generic.py
│ ├── os_win7.py
│ ├── platform_database.py
│ ├── platform_detection.py
│ └── test_data
│ │ ├── efm32pg_stk3401_jlink
│ │ ├── MBED.HTM
│ │ ├── README.TXT
│ │ ├── sl_kit.html
│ │ └── sl_qsg.html
│ │ ├── k64f_daplink
│ │ ├── DETAILS.TXT
│ │ └── MBED.HTM
│ │ ├── lpc1768
│ │ ├── MBED.HTM
│ │ ├── basic.bin
│ │ └── dirs.bin
│ │ ├── nrf51_microbit
│ │ ├── DETAILS.TXT
│ │ └── MICROBIT.HTM
│ │ ├── nrf52_dk_daplink
│ │ ├── DETAILS.TXT
│ │ └── MBED.HTM
│ │ ├── nrf52_dk_jlink
│ │ ├── MBED.HTM
│ │ ├── README.TXT
│ │ ├── Segger.html
│ │ └── User Guide.html
│ │ └── nucleo_f411re_stlink
│ │ ├── DETAILS.TXT
│ │ └── MBED.HTM
└── test
│ ├── __init__.py
│ ├── basic_gt.py
│ ├── basic_ht.py
│ ├── conn_primitive_remote.py
│ ├── event_callback_decorator.py
│ ├── host_registry.py
│ ├── host_test_base.py
│ ├── host_test_black_box.py
│ ├── host_test_default.py
│ ├── host_test_os_detect.py
│ ├── host_test_plugins.py
│ ├── host_test_scheme.py
│ ├── mbed_gt_cli.py
│ ├── mbed_gt_cmake_handlers.py
│ ├── mbed_gt_coverage_api.py
│ ├── mbed_gt_greentea_dlm.py
│ ├── mbed_gt_hooks.py
│ ├── mbed_gt_report_api.py
│ ├── mbed_gt_target_info.py
│ ├── mbed_gt_test_api.py
│ ├── mbed_gt_test_filtered_test_list.py
│ ├── mbed_gt_tests_spec.py
│ ├── mbed_gt_yotta_api.py
│ ├── mbed_gt_yotta_config.py
│ ├── mbed_gt_yotta_module.py
│ ├── mocks
│ ├── __init__.py
│ ├── environment
│ │ ├── __init__.py
│ │ ├── darwin.py
│ │ ├── linux.py
│ │ ├── posix.py
│ │ └── windows.py
│ ├── mbed_device.py
│ ├── process.py
│ └── serial.py
│ ├── mps2_copy.py
│ ├── mps2_reset.py
│ ├── report_api.py
│ ├── resources
│ ├── empty
│ │ └── test
│ │ │ └── CTestTestfile.cmake
│ ├── not-empty
│ │ └── test
│ │ │ └── CTestTestfile.cmake
│ └── test_spec.json
│ ├── test_conn_primitive_serial.py
│ └── test_mbed_base.py
└── test_requirements.txt
/.coveragerc:
--------------------------------------------------------------------------------
1 | [run]
2 | source =
3 | src/mbed_os_tools
4 |
--------------------------------------------------------------------------------
/.flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | # black, the super-great auto-formatter has decided that 88 is a good number.
3 | # I'm inclined to agree, or not to dissagree.
4 | max-line-length = 88
5 | exclude =
6 | packages/*,
7 | src/mbed_os_tools/test/host_tests/*,
8 | src/mbed_os_tools/test/host_tests_conn_proxy/*,
9 | src/mbed_os_tools/test/host_tests_logger/*,
10 | src/mbed_os_tools/test/host_tests_plugins/*,
11 | src/mbed_os_tools/test/host_tests_registry/*,
12 | src/mbed_os_tools/test/host_tests_runner/*,
13 | src/mbed_os_tools/test/host_tests_toolbox/*,
14 | src/mbed_os_tools/test/mbed_*.py,
15 | test/*,
16 |
--------------------------------------------------------------------------------
/.github/issue_template.md:
--------------------------------------------------------------------------------
1 |
16 |
17 | ### Description
18 |
19 |
30 |
31 |
32 | ### Issue request type
33 |
34 |
41 | [ ] Question
42 | [ ] Enhancement
43 | [ ] Bug
44 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ### Description
2 |
3 |
8 |
9 |
10 | ### Pull request type
11 |
12 |
19 | [ ] Fix
20 | [ ] Refactor
21 | [ ] Target update
22 | [ ] Functionality change
23 | [ ] Docs update
24 | [ ] Test update
25 | [ ] Breaking change
26 |
27 | ### Reviewers
28 |
29 |
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .coverage
4 | .eggs/
5 | *.egg-info/
6 | *.egg
7 | *.swp
8 | .mbedls-mock
9 | mbedls.json
10 | build/
11 | dist/
12 | .idea
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | global-exclude *.py[cod] __pycache__ *.so
2 | graft test
3 | include README.md
4 | include LICENSE
5 | include CONTRIBUTING.md
6 | include requirements.txt
7 | include test_requirements.txt
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Mbed OS tools
2 |
3 | This repository contains the Python modules needed to work with Mbed OS. Historically, the Mbed OS tools have been delivered in separate packages and repositories. Their APIs have evolved separately over time, each with their own style and syntax. This project unifies these packages into a single intuitive API.
4 |
5 | ## Packages
6 |
7 | Below is a table showing what packages are delivered from this repository:
8 |
9 | | PyPI package | Source | Depends on | Stable API |
10 | | ------- | ------ | ---------- | ---------- |
11 | | `mbed-os-tools` ([Documentation](docs)) | [`src/`](src) | | **No** |
12 | | `mbed-ls` ([Documentation](packages/mbed-ls/README.md)) | [`packages/mbed-ls/`](packages/mbed-ls) | `mbed-os-tools` | **Yes** |
13 | | `mbed-host-tests` ([Documentation](packages/mbed-host-tests/README.md)) | [`packages/mbed-host-tests/`](packages/mbed-host-tests/) | `mbed-os-tools` | **Yes** |
14 | | `mbed-greentea` ([Documentation](packages/mbed-greentea/README.md)) | [`packages/mbed-greentea/`](packages/mbed-greentea/) | `mbed-os-tools` | **Yes** |
15 |
16 | As indicated above, **the API `mbed-os-tools` provides is not stable**. For this reason, please continue to use the other packages.
17 |
18 | ## License and contributions
19 |
20 | The software is provided under [Apache-2.0 license](LICENSE). Contributions to this project are accepted under the same license. Please see [contributing.md](CONTRIBUTING.md) for more info.
21 |
22 | This project contains code from other projects. The original license text is included in those source files. They must comply with our [license guide](https://os.mbed.com/docs/latest/reference/license.html).
23 |
--------------------------------------------------------------------------------
/docs/package_versioning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ARMmbed/mbed-os-tools/c467d6f1498018669872883a95a8c9c9120d6abd/docs/package_versioning.png
--------------------------------------------------------------------------------
/docs/package_versioning.xml:
--------------------------------------------------------------------------------
1 | 3ZZNc5swEIZ/DccwgGziXOO67aE9+ZDkKMMGaAXLiMVAfn2EWQwak5nMdCZOwwXtu7v6eCQWOWKbtz+0LNPfGINyAi9uHfHNCQJ/FYTm1SvdoNyJu0FIdBZz0CTssxdg0WO1zmKorEBCVJSVthhhUUBElia1xsYOe0Zlj1rKBC6EfSTVpfqQxZQO6mbtTfpPyJJ0HNn32HOQ0d9EY13weE4gnk/P4M7l2BfHV6mMsZlJYueIrUakoZW3W1A92xHbkPf9De953hoKek9CMCQcpap56fkB4psUK7ohqKhyglCZnu4P2rSSvuW7Kze4lHk91I0MTxSgH8cz7ibNCPaljHpvY06N0VLKlbH8c/YRNEH75lL8MyBz8ABzIN2ZEE4YkXbjIWS7mTbQH2PS2eaFrEk+M8m554mbaTC6ZYxiGaNaxBd+Snz+5or8VhfLh9h8kGyiphQTLKTaTeq9DWgGA9qMHnvZXbP1NHoKM6+ZqzefuIM/QNRxJZI1oZGmcX8hlhbqfnoW6AprHbF0yxVL6gTI+s7esR0alKTsaPf+L2zXX52tuB7b8Kuz3VyP7e1yTe3vAQtl1XM91/8fyuoHVtXNMsFEg5k8yOVf+2eEKFYf928y5nT9Ovlmd1yxewU=
--------------------------------------------------------------------------------
/packages/mbed-greentea/.coveragerc:
--------------------------------------------------------------------------------
1 | [run]
2 | source =
3 | mbed_greentea
4 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/MANIFEST.in:
--------------------------------------------------------------------------------
1 | global-exclude *.py[cod] __pycache__ *.so
2 | graft test
3 | include README.md
4 | include LICENSE
5 | include CONTRIBUTING.md
6 | include requirements.txt
7 | include test_requirements.txt
8 | include .coveragerc
9 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from .mbed_greentea_cli import main
21 |
22 | """! @package mbed-greentea
23 |
24 | This is a test suite used by mbed project. If you have yotta package with tests you can run them on supported hardware
25 | This test suite supports:
26 | * mbed-ls - mbed-enabled device auto detection module
27 | * mbed-host-test - mbed-enabled device test framework (flash, reset and make host tests)
28 |
29 | """
30 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/__main__.py:
--------------------------------------------------------------------------------
1 | from mbed_greentea.mbed_greentea_cli import main
2 | main()
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/cmake_handlers.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.cmake_handlers import (
21 | load_ctest_testsuite,
22 | parse_ctesttestfile_line,
23 | list_binaries_for_targets,
24 | list_binaries_for_builds,
25 | )
26 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_common_api.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_common_api import (
21 | run_cli_command,
22 | run_cli_process,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_coverage_api.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_coverage_api import (
21 | coverage_pack_hex_payload,
22 | coverage_dump_file,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_greentea_dlm.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_greentea_dlm import (
21 | HOME_DIR,
22 | GREENTEA_HOME_DIR,
23 | GREENTEA_GLOBAL_LOCK,
24 | GREENTEA_KETTLE,
25 | GREENTEA_KETTLE_PATH,
26 | greentea_home_dir_init,
27 | greentea_get_app_sem,
28 | greentea_get_target_lock,
29 | greentea_get_global_lock,
30 | greentea_update_kettle,
31 | greentea_clean_kettle,
32 | greentea_acquire_target_id,
33 | greentea_acquire_target_id_from_list,
34 | greentea_release_target_id,
35 | get_json_data_from_file,
36 | greentea_kettle_info,
37 | )
38 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_greentea_hooks.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 | http://www.apache.org/licenses/LICENSE-2.0
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | Author: Przemyslaw Wirkus
14 | """
15 |
16 | from mbed_os_tools.test.mbed_greentea_hooks import (
17 | GreenteaTestHook,
18 | GreenteaCliTestHook,
19 | LcovHook,
20 | GreenteaHooks,
21 | )
22 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_greentea_log.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_greentea_log import (
21 | COLORAMA,
22 | GreenTeaSimpleLockLogger,
23 | gt_logger,
24 | )
25 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_report_api.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_report_api import (
21 | export_to_file,
22 | exporter_json,
23 | exporter_text,
24 | exporter_testcase_text,
25 | exporter_testcase_junit,
26 | html_template,
27 | TEST_RESULT_COLOURS,
28 | TEST_RESULT_DEFAULT_COLOUR,
29 | get_result_colour_class_css,
30 | get_result_colour_class,
31 | get_dropdown_html,
32 | get_result_overlay_testcase_dropdown,
33 | get_result_overlay_testcases_dropdown_menu,
34 | get_result_overlay_dropdowns,
35 | get_result_overlay,
36 | exporter_html,
37 | exporter_memory_metrics_csv,
38 | )
39 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_target_info.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_target_info import (
21 | TARGET_INFO_MAPPING,
22 | TARGET_TOOLCAHINS,
23 | get_mbed_target_call_yotta_target,
24 | parse_yotta_json_for_build_name,
25 | get_yotta_target_from_local_config,
26 | get_mbed_target_from_current_dir,
27 | parse_yotta_target_cmd_output,
28 | get_mbed_targets_from_yotta_local_module,
29 | parse_mbed_target_from_target_json,
30 | get_mbed_targets_from_yotta,
31 | parse_yotta_search_cmd_output,
32 | add_target_info_mapping,
33 | get_mbed_clasic_target_info,
34 | get_binary_type_for_platform,
35 | get_platform_property,
36 | )
37 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_yotta_api.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_yotta_api import (
21 | YottaError,
22 | build_with_yotta,
23 | get_platform_name_from_yotta_target,
24 | get_test_spec_from_yt_module,
25 | )
26 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/mbed_yotta_module_parse.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.mbed_yotta_module_parse import (
21 | YottaConfig,
22 | YottaModule
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/mbed_greentea/tests_spec.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Azim Khan
18 | """
19 |
20 | """
21 | This module contains classes to represent Test Specification interface that defines the data to be generated by/from
22 | a build system to give enough information to Greentea.
23 | """
24 |
25 | from mbed_os_tools.test.tests_spec import (
26 | TestBinary,
27 | Test,
28 | TestBuild,
29 | TestSpec,
30 | )
31 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/requirements.txt:
--------------------------------------------------------------------------------
1 | mbed-os-tools>=0.0.9
2 | mbed-host-tests>=1.5.0,<2
3 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | """! @package mbed-greentea-test
19 |
20 | Unit tests for mbed-greentea test suite
21 |
22 | """
23 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test/basic.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 |
20 | class BasicTestCase(unittest.TestCase):
21 | """ Basic true asserts to see that testing is executed
22 | """
23 |
24 | def setUp(self):
25 | pass
26 |
27 | def tearDown(self):
28 | pass
29 |
30 | def test_example(self):
31 | self.assertEqual(True, True)
32 | self.assertNotEqual(True, False)
33 |
34 | if __name__ == '__main__':
35 | unittest.main()
36 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test/mbed_gt_coverage_api.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import os
19 | import unittest
20 | from mbed_greentea import mbed_coverage_api
21 |
22 |
23 | class GreenteaCoverageAPI(unittest.TestCase):
24 |
25 | def setUp(self):
26 | pass
27 |
28 | def test_x(self):
29 | pass
30 |
31 | def test_coverage_pack_hex_payload(self):
32 | # This function takesstring as input
33 | r = mbed_coverage_api.coverage_pack_hex_payload('')
34 | self.assertEqual(bytearray(b''), r)
35 |
36 | r = mbed_coverage_api.coverage_pack_hex_payload('6164636772')
37 | self.assertEqual(bytearray(b'adcgr'), r)
38 |
39 | r = mbed_coverage_api.coverage_pack_hex_payload('.') # '.' -> 0x00
40 | self.assertEqual(bytearray(b'\x00'), r)
41 |
42 | r = mbed_coverage_api.coverage_pack_hex_payload('...') # '.' -> 0x00
43 | self.assertEqual(bytearray(b'\x00\x00\x00'), r)
44 |
45 | r = mbed_coverage_api.coverage_pack_hex_payload('.6164636772.') # '.' -> 0x00
46 | self.assertEqual(bytearray(b'\x00adcgr\x00'), r)
47 |
48 | def test_coverage_dump_file_valid(self):
49 | import tempfile
50 |
51 | payload = bytearray(b'PAYLOAD')
52 | handle, path = tempfile.mkstemp("test_file")
53 | mbed_coverage_api.coverage_dump_file(".", path, payload)
54 |
55 | with open(path, 'r') as f:
56 | read_data = f.read()
57 |
58 | self.assertEqual(read_data, payload.decode("utf-8", "ignore"))
59 | os.close(handle)
60 | os.remove(path)
61 |
62 | if __name__ == '__main__':
63 | unittest.main()
64 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test/report_api.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2017 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 | from mock import patch
20 |
21 | from mbed_greentea.mbed_report_api import exporter_html, \
22 | exporter_memory_metrics_csv, exporter_testcase_junit, \
23 | exporter_testcase_text, exporter_text, exporter_json
24 |
25 |
26 | class ReportEmitting(unittest.TestCase):
27 |
28 |
29 | report_fns = [exporter_html, exporter_memory_metrics_csv,
30 | exporter_testcase_junit, exporter_testcase_text,
31 | exporter_text, exporter_json]
32 | def test_report_zero_tests(self):
33 | test_data = {}
34 | for report_fn in self.report_fns:
35 | report_fn(test_data)
36 |
37 | def test_report_zero_testcases(self):
38 | test_data = {
39 | 'k64f-gcc_arm': {
40 | 'garbage_test_suite' :{
41 | u'single_test_result': u'NOT_RAN',
42 | u'elapsed_time': 0.0,
43 | u'build_path': u'N/A',
44 | u'build_path_abs': u'N/A',
45 | u'copy_method': u'N/A',
46 | u'image_path': u'N/A',
47 | u'single_test_output': u'\x80abc' ,
48 | u'platform_name': u'k64f',
49 | u'test_bin_name': u'N/A',
50 | u'testcase_result': {},
51 | }
52 | }
53 | }
54 | for report_fn in self.report_fns:
55 | report_fn(test_data)
56 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test/resources/empty/test/CTestTestfile.cmake:
--------------------------------------------------------------------------------
1 | # CMake generated Testfile for
2 | # Source directory: c:/Work2/mbed-client/test
3 | # Build directory: c:/Work2/mbed-client/build/frdm-k64f-gcc/test
4 | #
5 | # This file includes the relevant testing commands required for
6 | # testing this directory and lists subdirectories to be tested as well.
7 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test/resources/not-empty/test/CTestTestfile.cmake:
--------------------------------------------------------------------------------
1 | # CMake generated Testfile for
2 | # Source directory: c:/Work2/mbed-client/test
3 | # Build directory: c:/Work2/mbed-client/build/frdm-k64f-gcc/test
4 | #
5 | # This file includes the relevant testing commands required for
6 | # testing this directory and lists subdirectories to be tested as well.
7 | add_test(mbed-client-test-mbedclient-smokeTest "mbed-client-test-mbedclient-smokeTest")
8 | add_test(mbed-client-test-helloworld-mbedclient "mbed-client-test-helloworld-mbedclient")
9 | add_test()
10 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test/resources/test_spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "builds": {
3 | "K64F-ARM": {
4 | "platform": "K64F",
5 | "toolchain": "ARM",
6 | "base_path": "./BUILD/K64F/ARM",
7 | "baud_rate": 9600,
8 | "tests": {
9 | "tests-example-1": {
10 | "binaries": [
11 | {
12 | "binary_type": "bootable",
13 | "path": "./BUILD/K64F/ARM/tests-mbedmicro-rtos-mbed-mail.bin"
14 | }
15 | ]
16 | },
17 | "tests-example-2": {
18 | "binaries": [
19 | {
20 | "binary_type": "bootable",
21 | "path": "./BUILD/K64F/ARM/tests-mbed_drivers-c_strings.bin"
22 | }
23 | ]
24 | }
25 | }
26 | },
27 | "K64F-GCC": {
28 | "platform": "K64F",
29 | "toolchain": "GCC_ARM",
30 | "base_path": "./BUILD/K64F/GCC_ARM",
31 | "baud_rate": 9600,
32 | "tests": {
33 | "tests-example-7": {
34 | "binaries": [
35 | {
36 | "binary_type": "bootable",
37 | "path": "./BUILD/K64F/GCC_ARM/tests-mbedmicro-rtos-mbed-mail.bin"
38 | }
39 | ]
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/packages/mbed-greentea/test_requirements.txt:
--------------------------------------------------------------------------------
1 | mock>=2
2 | coverage
3 | coveralls
4 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/.coveragerc:
--------------------------------------------------------------------------------
1 | [run]
2 | source =
3 | mbed_host_tests
4 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/MANIFEST.in:
--------------------------------------------------------------------------------
1 | global-exclude *.py[cod] __pycache__ *.so
2 | graft test
3 | include README.md
4 | include requirements.txt
5 | include test_requirements.txt
6 | include .coveragerc
7 |
8 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 |
21 | """! @package mbed-host-tests
22 |
23 | Flash, reset and perform host supervised tests on mbed platforms.
24 | Write your own programs (import this package) or use 'mbedhtrun' command line tool instead.
25 |
26 | """
27 |
28 | from mbed_os_tools.test import (
29 | host_tests_plugins,
30 | HostRegistry,
31 | BaseHostTest,
32 | event_callback,
33 | DEFAULT_BAUD_RATE,
34 | get_plugin_caps,
35 | init_host_test_cli_params,
36 | )
37 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2013 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | # base host test class
19 | from .base_host_test import BaseHostTest, event_callback
20 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/base_host_test.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.base_host_test import (
19 | BaseHostTestAbstract,
20 | event_callback,
21 | HostTestCallbackBase,
22 | BaseHostTest,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/default_auto.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2013 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.default_auto import DefaultAuto
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/detect_auto.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2013 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.detect_auto import DetectPlatformTest
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/dev_null_auto.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2013 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.dev_null_auto import DevNullTest
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/echo.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.echo import EchoTest
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/hello_auto.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2013 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.hello_auto import HelloTest
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/rtc_auto.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2013 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.rtc_auto import RTCTest
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests/wait_us_auto.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2013 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests.wait_us_auto import WaitusTest
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_conn_proxy/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from .conn_proxy import conn_process
21 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_conn_proxy/conn_primitive.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests_conn_proxy.conn_primitive import (
19 | ConnectorPrimitiveException,
20 | ConnectorPrimitive,
21 | )
22 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_conn_proxy/conn_primitive_fastmodel.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests_conn_proxy.conn_primitive_fastmodel import (
19 | FastmodelConnectorPrimitive,
20 | )
21 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_conn_proxy/conn_primitive_remote.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests_conn_proxy.conn_primitive_remote import (
19 | RemoteConnectorPrimitive,
20 | )
21 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_conn_proxy/conn_primitive_serial.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 |
19 | from mbed_os_tools.test.host_tests_conn_proxy.conn_primitive_serial import (
20 | SerialConnectorPrimitive,
21 | )
22 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_conn_proxy/conn_proxy.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests_conn_proxy.conn_proxy import (
19 | KiViBufferWalker,
20 | conn_primitive_factory,
21 | conn_process,
22 | )
23 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_logger/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from .ht_logger import HtrunLogger
21 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_logger/ht_logger.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.test.host_tests_logger.ht_logger import HtrunLogger
19 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | """! @package mbed-host-test-plugins
21 |
22 | This package contains plugins used by host test to reset, flash devices etc.
23 | This package can be extended with new packages to add more generic functionality
24 |
25 | """
26 |
27 | from mbed_os_tools.test.host_tests_plugins import (
28 | HOST_TEST_PLUGIN_REGISTRY,
29 | call_plugin,
30 | get_plugin_caps,
31 | get_plugin_info,
32 | print_plugin_info,
33 | )
34 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/host_test_plugins.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.host_test_plugins import (
21 | HostTestPluginBase,
22 | )
23 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/host_test_registry.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.host_test_registry import (
21 | HostTestRegistry,
22 | )
23 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_jn51xx.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_jn51xx import (
21 | HostTestPluginCopyMethod_JN51xx,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_mbed.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_mbed import (
21 | HostTestPluginCopyMethod_Mbed,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_mps2.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_mps2 import (
21 | HostTestPluginCopyMethod_MPS2,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_pyocd.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2016-2016,2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Russ Butler
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_pyocd import (
21 | HostTestPluginCopyMethod_pyOCD,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_shell.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_shell import (
21 | HostTestPluginCopyMethod_Shell,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_silabs.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_silabs import (
21 | HostTestPluginCopyMethod_Silabs,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_stlink.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_stlink import (
21 | HostTestPluginCopyMethod_Stlink,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_copy_ublox.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_copy_ublox import (
21 | HostTestPluginCopyMethod_ublox,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_power_cycle_mbed.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_power_cycle_mbed import (
21 | HostTestPluginPowerCycleResetMethod,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_reset_jn51xx.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_reset_jn51xx import (
21 | HostTestPluginResetMethod_JN51xx,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_reset_mbed.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_reset_mbed import (
21 | HostTestPluginResetMethod_Mbed,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_reset_mps2.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_reset_mps2 import (
21 | HostTestPluginResetMethod_MPS2,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_reset_pyocd.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2016-2016,2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Russ Butler
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_reset_pyocd import (
21 | HostTestPluginResetMethod_pyOCD,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_reset_silabs.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_reset_silabs import (
21 | HostTestPluginResetMethod_SiLabs,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_reset_stlink.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_reset_stlink import (
21 | HostTestPluginResetMethod_Stlink,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_plugins/module_reset_ublox.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_plugins.module_reset_ublox import (
21 | HostTestPluginResetMethod_ublox,
22 | load_plugin,
23 | )
24 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_registry/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | """! @package host_registry
21 |
22 | Host registry is used to store all host tests (by id) which can be called from test framework
23 |
24 | """
25 |
26 | from .host_registry import HostRegistry
27 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_registry/host_registry.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_registry.host_registry import HostRegistry
21 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_runner/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | """! @package mbed-host-test-runner
21 |
22 | This package contains basic host test implementation with algorithms to flash and reset device.
23 | Functionality can be overridden by set of plugins which can provide specialised flashing and reset implementations.
24 |
25 | """
26 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_runner/host_test.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_runner.host_test import (
21 | HostTestResults,
22 | Test,
23 | DefaultTestSelectorBase,
24 | )
25 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_runner/host_test_default.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_runner.host_test_default import (
21 | DefaultTestSelector,
22 | )
23 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_runner/mbed_base.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_runner.mbed_base import Mbed
21 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_toolbox/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from .host_functional import reset_dev
21 | from .host_functional import flash_dev
22 | from .host_functional import handle_send_break_cmd
23 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/host_tests_toolbox/host_functional.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from mbed_os_tools.test.host_tests_toolbox.host_functional import (
21 | flash_dev,
22 | reset_dev,
23 | handle_send_break_cmd,
24 | )
25 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/mbed_host_tests/mbedhtrun.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2016 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | Author: Przemyslaw Wirkus
18 | """
19 |
20 | from __future__ import print_function
21 | from multiprocessing import freeze_support
22 | from mbed_os_tools.test import init_host_test_cli_params
23 | from mbed_os_tools.test.host_tests_runner.host_test_default import DefaultTestSelector
24 | from mbed_os_tools.test.host_tests_toolbox.host_functional import handle_send_break_cmd
25 |
26 |
27 | def main():
28 | """! This function drives command line tool 'mbedhtrun' which is using DefaultTestSelector
29 | @details 1. Create DefaultTestSelector object and pass command line parameters
30 | 2. Call default test execution function run() to start test instrumentation
31 | """
32 | freeze_support()
33 | result = 0
34 | cli_params = init_host_test_cli_params()
35 |
36 | if cli_params.version: # --version
37 | import pkg_resources # part of setuptools
38 | version = pkg_resources.require("mbed-host-tests")[0].version
39 | print(version)
40 | elif cli_params.send_break_cmd: # -b with -p PORT (and optional -r RESET_TYPE)
41 | handle_send_break_cmd(
42 | port=cli_params.port,
43 | disk=cli_params.disk,
44 | reset_type=cli_params.forced_reset_type,
45 | baudrate=cli_params.baud_rate,
46 | verbose=cli_params.verbose
47 | )
48 | else:
49 | test_selector = DefaultTestSelector(cli_params)
50 | try:
51 | result = test_selector.execute()
52 | # Ensure we don't return a negative value
53 | if result < 0 or result > 255:
54 | result = 1
55 | except (KeyboardInterrupt, SystemExit):
56 | test_selector.finish()
57 | result = 1
58 | raise
59 | else:
60 | test_selector.finish()
61 |
62 | return result
63 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/requirements.txt:
--------------------------------------------------------------------------------
1 | mbed-os-tools>=0.0.9
2 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | """! @package mbed-host-tests-test
19 |
20 | Unit tests for mbed-host-tests package
21 |
22 | """
23 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/basic.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 |
20 | class BasicTestCase(unittest.TestCase):
21 |
22 | def setUp(self):
23 | pass
24 |
25 | def tearDown(self):
26 | pass
27 |
28 | def test_example(self):
29 | self.assertEqual(True, True)
30 | self.assertNotEqual(True, False)
31 |
32 | if __name__ == '__main__':
33 | unittest.main()
34 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/basic_ht.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 |
20 | from mbed_host_tests import get_plugin_caps
21 |
22 | class BasicHostTestsTestCase(unittest.TestCase):
23 |
24 | def setUp(self):
25 | pass
26 |
27 | def tearDown(self):
28 | pass
29 |
30 | def test_get_plugin_caps(self):
31 | d = get_plugin_caps()
32 | self.assertIs(type(d), dict)
33 |
34 |
35 | if __name__ == '__main__':
36 | unittest.main()
37 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/event_callback_decorator.py:
--------------------------------------------------------------------------------
1 | # Copyright 2015 ARM Limited, All rights reserved
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | import unittest
16 |
17 | from mbed_host_tests.host_tests.base_host_test import BaseHostTest, event_callback
18 |
19 |
20 | class TestEvenCallbackDecorator(unittest.TestCase):
21 | def setUp(self):
22 | pass
23 |
24 | def tearDown(self):
25 | pass
26 |
27 | def test_event_callback_decorator(self):
28 | class Ht(BaseHostTest):
29 |
30 | @event_callback('Hi')
31 | def hi(self, key, value, timestamp):
32 | print('hi')
33 |
34 | @event_callback('Hello')
35 | def hello(self, key, value, timestamp):
36 | print('hello')
37 | h = Ht()
38 | h.setup()
39 | callbacks = h.get_callbacks()
40 | self.assertIn('Hi', callbacks)
41 | self.assertIn('Hello', callbacks)
42 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/host_registry.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 | from mbed_host_tests.host_tests_registry import HostRegistry
20 | from mbed_host_tests import BaseHostTest
21 |
22 |
23 | class HostRegistryTestCase(unittest.TestCase):
24 |
25 | class HostTestClassMock(BaseHostTest):
26 | def setup(self):
27 | pass
28 |
29 | def result(self):
30 | pass
31 |
32 | def teardown(self):
33 | pass
34 |
35 | def setUp(self):
36 | self.HOSTREGISTRY = HostRegistry()
37 |
38 | def tearDown(self):
39 | pass
40 |
41 | def test_register_host_test(self):
42 | self.HOSTREGISTRY.register_host_test('host_test_mock_auto', self.HostTestClassMock())
43 | self.assertEqual(True, self.HOSTREGISTRY.is_host_test('host_test_mock_auto'))
44 |
45 | def test_unregister_host_test(self):
46 | self.HOSTREGISTRY.register_host_test('host_test_mock_2_auto', self.HostTestClassMock())
47 | self.assertEqual(True, self.HOSTREGISTRY.is_host_test('host_test_mock_2_auto'))
48 | self.assertNotEqual(None, self.HOSTREGISTRY.get_host_test('host_test_mock_2_auto'))
49 | self.HOSTREGISTRY.unregister_host_test('host_test_mock_2_auto')
50 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test('host_test_mock_2_auto'))
51 |
52 | def test_get_host_test(self):
53 | self.HOSTREGISTRY.register_host_test('host_test_mock_3_auto', self.HostTestClassMock())
54 | self.assertEqual(True, self.HOSTREGISTRY.is_host_test('host_test_mock_3_auto'))
55 | self.assertNotEqual(None, self.HOSTREGISTRY.get_host_test('host_test_mock_3_auto'))
56 |
57 | def test_is_host_test(self):
58 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test(''))
59 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test(None))
60 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test('xyz'))
61 |
62 | def test_host_test_str_not_empty(self):
63 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
64 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
65 | self.assertNotEqual(None, ht)
66 |
67 | def test_host_test_has_name_attribute(self):
68 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
69 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
70 | self.assertTrue(hasattr(ht, 'setup'))
71 | self.assertTrue(hasattr(ht, 'result'))
72 | self.assertTrue(hasattr(ht, 'teardown'))
73 |
74 |
75 | if __name__ == '__main__':
76 | unittest.main()
77 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/host_test_base.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 |
20 | from mbed_host_tests.host_tests_registry import HostRegistry
21 |
22 | class BaseHostTestTestCase(unittest.TestCase):
23 |
24 | def setUp(self):
25 | self.HOSTREGISTRY = HostRegistry()
26 |
27 | def tearDown(self):
28 | pass
29 |
30 | def test_host_test_has_setup_teardown_attribute(self):
31 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
32 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
33 | self.assertTrue(hasattr(ht, 'setup'))
34 | self.assertTrue(hasattr(ht, 'teardown'))
35 |
36 | def test_host_test_has_no_rampUpDown_attribute(self):
37 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
38 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
39 | self.assertFalse(hasattr(ht, 'rampUp'))
40 | self.assertFalse(hasattr(ht, 'rampDown'))
41 |
42 | if __name__ == '__main__':
43 | unittest.main()
44 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/host_test_os_detect.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 |
20 | import os
21 | import re
22 | import sys
23 | import platform
24 | from mbed_host_tests.host_tests_plugins.host_test_plugins import HostTestPluginBase
25 |
26 |
27 | class HostOSDetectionTestCase(unittest.TestCase):
28 |
29 | def setUp(self):
30 | self.plugin_base = HostTestPluginBase()
31 | self.os_names = ['Windows7', 'Ubuntu', 'LinuxGeneric', 'Darwin']
32 | self.re_float = re.compile("^\d+\.\d+$")
33 |
34 | def tearDown(self):
35 | pass
36 |
37 | def test_os_info(self):
38 | self.assertNotEqual(None, self.plugin_base.mbed_os_info())
39 |
40 | def test_os_support(self):
41 | self.assertNotEqual(None, self.plugin_base.mbed_os_support())
42 |
43 | def test_supported_os_name(self):
44 | self.assertIn(self.plugin_base.mbed_os_support(), self.os_names)
45 |
46 | def test_detect_os_support_ext(self):
47 | os_info = (os.name,
48 | platform.system(),
49 | platform.release(),
50 | platform.version(),
51 | sys.platform)
52 |
53 | self.assertEqual(os_info, self.plugin_base.mbed_os_info())
54 |
55 |
56 | if __name__ == '__main__':
57 | unittest.main()
58 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/host_test_plugins.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 |
20 | from mbed_host_tests.host_tests_plugins.module_reset_mbed import HostTestPluginResetMethod_Mbed
21 |
22 | class HostOSDetectionTestCase(unittest.TestCase):
23 |
24 | def setUp(self):
25 | self.plugin_reset_mbed = HostTestPluginResetMethod_Mbed()
26 |
27 | def tearDown(self):
28 | pass
29 |
30 | def test_examle(self):
31 | pass
32 |
33 | def test_pyserial_version_detect(self):
34 | self.assertEqual(1.0, self.plugin_reset_mbed.get_pyserial_version("1.0"))
35 | self.assertEqual(1.0, self.plugin_reset_mbed.get_pyserial_version("1.0.0"))
36 | self.assertEqual(2.7, self.plugin_reset_mbed.get_pyserial_version("2.7"))
37 | self.assertEqual(2.7, self.plugin_reset_mbed.get_pyserial_version("2.7.1"))
38 | self.assertEqual(3.0, self.plugin_reset_mbed.get_pyserial_version("3.0"))
39 | self.assertEqual(3.0, self.plugin_reset_mbed.get_pyserial_version("3.0.1"))
40 |
41 |
42 | if __name__ == '__main__':
43 | unittest.main()
44 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/host_test_scheme.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2015 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import six
19 | import unittest
20 | from mbed_host_tests.host_tests_registry import HostRegistry
21 |
22 |
23 | class HostRegistryTestCase(unittest.TestCase):
24 |
25 | def setUp(self):
26 | self.HOSTREGISTRY = HostRegistry()
27 |
28 | def tearDown(self):
29 | pass
30 |
31 | def test_host_test_class_has_test_attr(self):
32 | """ Check if host test has 'result' class member
33 | """
34 | for i, ht_name in enumerate(self.HOSTREGISTRY.HOST_TESTS):
35 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
36 | if ht is not None:
37 | self.assertEqual(True, hasattr(ht, 'result'))
38 |
39 | def test_host_test_class_test_attr_callable(self):
40 | """ Check if host test has callable 'result' class member
41 | """
42 | for i, ht_name in enumerate(self.HOSTREGISTRY.HOST_TESTS):
43 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
44 | if ht:
45 | self.assertEqual(True, hasattr(ht, 'result') and callable(getattr(ht, 'result')))
46 |
47 | def test_host_test_class_test_attr_callable_args_num(self):
48 | """ Check if host test has callable setup(), result() and teardown() class member has 2 arguments
49 | """
50 | for i, ht_name in enumerate(self.HOSTREGISTRY.HOST_TESTS):
51 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
52 | if ht and hasattr(ht, 'setup') and callable(getattr(ht, 'setup')):
53 | self.assertEqual(1, six.get_function_code(ht.setup).co_argcount)
54 | if ht and hasattr(ht, 'result') and callable(getattr(ht, 'result')):
55 | self.assertEqual(1, six.get_function_code(ht.result).co_argcount)
56 | if ht and hasattr(ht, 'teardown') and callable(getattr(ht, 'teardown')):
57 | self.assertEqual(1, six.get_function_code(ht.teardown).co_argcount)
58 |
59 |
60 | if __name__ == '__main__':
61 | unittest.main()
62 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/mps2_copy.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 | import os
20 |
21 | from mbed_host_tests.host_tests_plugins.module_copy_mps2 import HostTestPluginCopyMethod_MPS2
22 |
23 | class MPS2CopyTestCase(unittest.TestCase):
24 |
25 | def setUp(self):
26 | self.mps2_copy_plugin = HostTestPluginCopyMethod_MPS2()
27 | self.filename = "toto.bin"
28 | # Create the empty file named self.filename
29 | open(self.filename, "w+").close()
30 |
31 | def tearDown(self):
32 | os.remove(self.filename)
33 |
34 | def test_copy_bin(self):
35 | # Check that file has been copied as "mbed.bin"
36 | self.mps2_copy_plugin.mps2_copy(self.filename, ".")
37 | self.assertTrue(os.path.isfile("mbed.bin"))
38 | os.remove("mbed.bin")
39 |
40 | def test_copy_elf(self):
41 | # Check that file has been copied as "mbed.elf"
42 | os.rename(self.filename, "toto.elf")
43 | self.filename = "toto.elf"
44 | self.mps2_copy_plugin.mps2_copy(self.filename, ".")
45 | self.assertTrue(os.path.isfile("mbed.elf"))
46 | os.remove("mbed.elf")
47 |
48 | if __name__ == '__main__':
49 | unittest.main()
50 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test/mps2_reset.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 | import mock
20 | import os
21 | import time
22 |
23 | from mbed_host_tests.host_tests_plugins.module_reset_mps2 import HostTestPluginResetMethod_MPS2
24 |
25 | class MPS2ResetTestCase(unittest.TestCase):
26 |
27 | def setUp(self):
28 | self.mps2_reset_plugin = HostTestPluginResetMethod_MPS2()
29 |
30 | def tearDown(self):
31 | pass
32 |
33 | @mock.patch("os.name", "posix")
34 | @mock.patch("time.sleep")
35 | @mock.patch("mbed_host_tests.host_tests_plugins.module_reset_mps2.HostTestPluginResetMethod_MPS2.run_command")
36 | def test_check_sync(self, run_command_function, sleep_function):
37 | # Check that a sync call has correctly been executed
38 | self.mps2_reset_plugin.execute("reboot.txt", disk=".")
39 | args, _ = run_command_function.call_args
40 | self.assertTrue("sync" in args[0])
41 | os.remove("reboot.txt")
42 |
43 | if __name__ == '__main__':
44 | unittest.main()
45 |
--------------------------------------------------------------------------------
/packages/mbed-host-tests/test_requirements.txt:
--------------------------------------------------------------------------------
1 | mock>=2
2 | coverage
3 | coveralls
4 |
--------------------------------------------------------------------------------
/packages/mbed-ls/.coveragerc:
--------------------------------------------------------------------------------
1 | [run]
2 | source =
3 | mbed_lstools
4 |
--------------------------------------------------------------------------------
/packages/mbed-ls/MANIFEST.in:
--------------------------------------------------------------------------------
1 | global-exclude *.py[cod] __pycache__ *.so
2 | graft test
3 | include README.md
4 | include requirements.txt
5 | include test_requirements.txt
6 | include .coveragerc
7 |
--------------------------------------------------------------------------------
/packages/mbed-ls/mbed_lstools/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | """! @package mbed-ls
19 |
20 | mbed-ls package is a set of tools inherited from mbed-lmtools used to detect
21 | mbed enabled devices on host (Windows, Linux and MacOS).
22 |
23 | mbed-lstools is a Python module that detects and lists mbed-enabled devices
24 | connected to the host computer. It will be delivered as a redistributable
25 | Python module (package) and command line tool.
26 |
27 | Currently supported operating system:
28 | * Windows 7.
29 | * Ubuntu.
30 | * Mac OS X (Darwin).
31 |
32 | The stand-alone mbed-lstools Python package is still under development,
33 | but it's already delivered as part of the mbed SDK's test suite and a command
34 | line tool (see below).
35 | """
36 |
37 | from .main import mbedls_main
38 | from .main import create
39 |
--------------------------------------------------------------------------------
/packages/mbed-ls/mbed_lstools/darwin.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.detect.darwin import MbedLsToolsDarwin
19 |
--------------------------------------------------------------------------------
/packages/mbed-ls/mbed_lstools/linux.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.detect.linux import MbedLsToolsLinuxGeneric
19 |
--------------------------------------------------------------------------------
/packages/mbed-ls/mbed_lstools/lstools_base.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import functools
19 | import json
20 | import logging
21 |
22 | from mbed_os_tools.detect.lstools_base import (
23 | FSInteraction,
24 | MbedLsToolsBase,
25 | )
26 |
--------------------------------------------------------------------------------
/packages/mbed-ls/mbed_lstools/platform_database.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2017-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | """Functions that manage a platform database"""
19 |
20 | from mbed_os_tools.detect.platform_database import (
21 | LOCAL_PLATFORM_DATABASE,
22 | LOCAL_MOCKS_DATABASE,
23 | DEFAULT_PLATFORM_DB,
24 | PlatformDatabase
25 | )
26 |
27 | """
28 | NOTE: The platform database is now in the mbed-os-tools package.
29 | You can find it in the following file: mbed_os_tools/detect/platform_database.py
30 | Please make all further contributions to the new package.
31 | """
32 |
--------------------------------------------------------------------------------
/packages/mbed-ls/mbed_lstools/windows.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | from mbed_os_tools.detect.windows import (
19 | MbedLsToolsWin7,
20 | CompatibleIDsNotFoundException
21 | )
22 |
--------------------------------------------------------------------------------
/packages/mbed-ls/requirements.txt:
--------------------------------------------------------------------------------
1 | PrettyTable<=1.0.1; python_version < '3.6'
2 | prettytable>=2.0,<3.0; python_version >= '3.6'
3 | mbed-os-tools>=0.0.9
4 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | """! @package mbed-ls-test
19 |
20 | Unit tests for mbed-ls package
21 |
22 | """
--------------------------------------------------------------------------------
/packages/mbed-ls/test/detect_os.py:
--------------------------------------------------------------------------------
1 | """
2 | mbed SDK
3 | Copyright (c) 2011-2018 ARM Limited
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | """
17 |
18 | import unittest
19 | import os
20 | import sys
21 | import errno
22 | import logging
23 |
24 | import platform
25 | from mbed_lstools.main import create
26 | from mbed_lstools.main import mbed_os_support
27 | from mbed_lstools.main import mbed_lstools_os_info
28 |
29 |
30 | class DetectOSTestCase(unittest.TestCase):
31 | """ Test cases for host OS related functionality. Helpful during porting
32 | """
33 |
34 | def setUp(self):
35 | pass
36 |
37 | def tearDown(self):
38 | pass
39 |
40 | def test_porting_mbed_lstools_os_info(self):
41 | self.assertNotEqual(None, mbed_lstools_os_info())
42 |
43 | def test_porting_mbed_os_support(self):
44 | self.assertNotEqual(None, mbed_os_support())
45 |
46 | def test_porting_create(self):
47 | self.assertNotEqual(None, create())
48 |
49 | def test_supported_os_name(self):
50 | os_names = ['Windows7', 'Ubuntu', 'LinuxGeneric', 'Darwin']
51 | self.assertIn(mbed_os_support(), os_names)
52 |
53 | def test_detect_os_support_ext(self):
54 | os_info = (os.name,
55 | platform.system(),
56 | platform.release(),
57 | platform.version(),
58 | sys.platform)
59 |
60 | self.assertEqual(os_info, mbed_lstools_os_info())
61 |
62 |
63 | if __name__ == '__main__':
64 | unittest.main()
65 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/efm32pg_stk3401_jlink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/efm32pg_stk3401_jlink/README.TXT:
--------------------------------------------------------------------------------
1 | Silicon Labs J-Link MSD volume.
2 |
3 | Copying a binary file here will flash it to the MCU.
4 |
5 | Supported binary file formats:
6 | - Intel Hex (.hex)
7 | - Motorola s-records (.mot)
8 | - Binary (.bin/.par/.crd)
9 |
10 | Known limitations:
11 | - Virtual COM port speed is currently fixed at 115200 bps
12 | - Using other kit functionality such as energy profiling or debugger while flashing is
13 | not supported.
14 | Workaround: Pause any energy profiling and disconnect any connected debug sessions
15 | before flashing.
16 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/efm32pg_stk3401_jlink/sl_kit.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EFM32PG-STK3401 - Pearl Gecko STK
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/efm32pg_stk3401_jlink/sl_qsg.html:
--------------------------------------------------------------------------------
1 | Simplicity Studio Shortcut
2 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/k64f_daplink/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | # DAPLink Firmware - see https://mbed.com/daplink
2 | Unique ID: 0240000032044e45000a700a997b00356781000097969900
3 | HIC ID: 97969900
4 | Auto Reset: 0
5 | Automation allowed: 0
6 | Overflow detection: 0
7 | Daplink Mode: Interface
8 | Interface Version: 0244
9 | Git SHA: 363abb00ee17ad50cb407c6d2e299407332e3c85
10 | Local Mods: 1
11 | USB Interfaces: MSD, CDC, HID
12 | Interface CRC: 0xc44e96e1
13 | Remount count: 0
14 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/k64f_daplink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/lpc1768/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mbed Website Shortcut
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/lpc1768/basic.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ARMmbed/mbed-os-tools/c467d6f1498018669872883a95a8c9c9120d6abd/packages/mbed-ls/test/test_data/lpc1768/basic.bin
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/lpc1768/dirs.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ARMmbed/mbed-os-tools/c467d6f1498018669872883a95a8c9c9120d6abd/packages/mbed-ls/test/test_data/lpc1768/dirs.bin
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf51_microbit/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | # DAPLink Firmware - see https://mbed.com/daplink
2 | Unique ID: 9900007031324e45000f9019000000340000000097969901
3 | HIC ID: 97969901
4 | Auto Reset: 1
5 | Automation allowed: 0
6 | Overflow detection: 0
7 | Daplink Mode: Interface
8 | Interface Version: 0244
9 | Git SHA: 72ea244a3a9219299c5655c614c955185451e98e
10 | Local Mods: 1
11 | USB Interfaces: MSD, CDC, HID, WebUSB
12 | Interface CRC: 0xfdd0c098
13 | Remount count: 0
14 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf51_microbit/MICROBIT.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf52_dk_daplink/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | # DAPLink Firmware - see https://mbed.com/daplink
2 | Unique ID: 110100004420312043574641323032203233303397969903
3 | HIC ID: 97969903
4 | Auto Reset: 0
5 | Automation allowed: 0
6 | Overflow detection: 0
7 | Daplink Mode: Interface
8 | Interface Version: 0245
9 | Git SHA: aace60cd16996cc881567f35eb84db063a9268b7
10 | Local Mods: 0
11 | USB Interfaces: MSD, CDC, HID
12 | Interface CRC: 0xfa307a74
13 | Remount count: 0
14 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf52_dk_daplink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf52_dk_jlink/MBED.HTM:
--------------------------------------------------------------------------------
1 | mbed Website Shortcut
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf52_dk_jlink/README.TXT:
--------------------------------------------------------------------------------
1 | SEGGER J-Link MSD volume.
2 | This volume is used to update the flash content of your target device.
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf52_dk_jlink/Segger.html:
--------------------------------------------------------------------------------
1 | SEGGER Shortcut
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nrf52_dk_jlink/User Guide.html:
--------------------------------------------------------------------------------
1 | Starter Guide Shortcut
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nucleo_f411re_stlink/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | Version: 0221
2 | Build: Jan 11 2016 16:12:36
3 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test/test_data/nucleo_f411re_stlink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mbed Website Shortcut
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/mbed-ls/test_requirements.txt:
--------------------------------------------------------------------------------
1 | mock>=2
2 | pytest>=3
3 | coverage
4 | coveralls
5 |
--------------------------------------------------------------------------------
/pypi-release.yml:
--------------------------------------------------------------------------------
1 | # File: simple-param.yml
2 | parameters:
3 | - name: repoName
4 | type: string
5 | - name: wDirectory
6 | type: string
7 |
8 | steps:
9 | - task: TwineAuthenticate@1
10 | displayName: 'Twine Authenticate ${{ parameters.repoName }}'
11 | inputs:
12 | pythonUploadServiceConnection: pypi-${{ parameters.repoName }}
13 |
14 | # Build the python distribution from source
15 | - script: "python setup.py sdist bdist_wheel --universal"
16 | displayName: "Prepare ${{ parameters.repoName }} for release"
17 | workingDirectory: ${{ parameters.wDirectory }}
18 |
19 | # Use command line script to 'twine upload'. Use -r to pass the repository name and --config-file to pass the environment variable set by the authenticate task.
20 | - script: |
21 | python -m twine upload -r ${{ parameters.repoName }} --config-file $(PYPIRC_PATH) dist/*.whl
22 | displayName: "Release ${{ parameters.repoName }} to pypi"
23 | workingDirectory: ${{ parameters.wDirectory }}
24 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | PySerial>=3.0,<4.0
2 | requests>=2.0,<3.0
3 | intelhex>=2.0,<3.0
4 | future
5 | PrettyTable<=1.0.1; python_version < '3.6'
6 | prettytable>=2.0,<3.0; python_version >= '3.6'
7 | fasteners
8 | appdirs>=1.4,<2.0
9 | junit-xml>=1.0,<2.0
10 | lockfile
11 | six>=1.0,<2.0
12 | colorama>=0.3,<0.5
13 | # When using beautiful soup, the XML parser needs to be installed independently. It is only needed on macOs though.
14 | beautifulsoup4
15 | lxml; sys_platform == 'darwin'
16 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/detect/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | """! @package mbed-ls
17 |
18 | mbed-ls package is a set of tools inherited from mbed-lmtools used to detect
19 | mbed enabled devices on host (Windows, Linux and MacOS).
20 |
21 | mbed-lstools is a Python module that detects and lists mbed-enabled devices
22 | connected to the host computer. It will be delivered as a redistributable
23 | Python module (package) and command line tool.
24 |
25 | Currently supported operating system:
26 | * Windows 7.
27 | * Ubuntu.
28 | * Mac OS X (Darwin).
29 |
30 | The stand-alone mbed-lstools Python package is still under development,
31 | but it's already delivered as part of the mbed SDK's test suite and a command
32 | line tool (see below).
33 | """
34 |
35 | from .main import create
36 |
37 | create = create
38 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/__main__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .mbed_greentea_cli import main
17 | main()
18 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | # base host test class
17 | from .base_host_test import BaseHostTest, event_callback
18 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/default_auto.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 |
17 | from .. import BaseHostTest
18 |
19 |
20 | class DefaultAuto(BaseHostTest):
21 | """ Simple, basic host test's test runner waiting for serial port
22 | output from MUT, no supervision over test running in MUT is executed.
23 | """
24 | pass
25 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/detect_auto.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import re
17 | from .. import BaseHostTest
18 |
19 | class DetectPlatformTest(BaseHostTest):
20 | PATTERN_MICRO_NAME = "Target '(\w+)'"
21 | re_detect_micro_name = re.compile(PATTERN_MICRO_NAME)
22 |
23 | def result(self):
24 | raise NotImplementedError
25 |
26 | def test(self, selftest):
27 | result = True
28 |
29 | c = selftest.mbed.serial_readline() # {{start}} preamble
30 | if c is None:
31 | return selftest.RESULT_IO_SERIAL
32 |
33 | selftest.notify(c.strip())
34 | selftest.notify("HOST: Detecting target name...")
35 |
36 | c = selftest.mbed.serial_readline()
37 | if c is None:
38 | return selftest.RESULT_IO_SERIAL
39 | selftest.notify(c.strip())
40 |
41 | # Check for target name
42 | m = self.re_detect_micro_name.search(c)
43 | if m and len(m.groups()):
44 | micro_name = m.groups()[0]
45 | micro_cmp = selftest.mbed.options.micro == micro_name
46 | result = result and micro_cmp
47 | selftest.notify("HOST: MUT Target name '%s', expected '%s'... [%s]"% (micro_name,
48 | selftest.mbed.options.micro,
49 | "OK" if micro_cmp else "FAIL"))
50 |
51 | for i in range(0, 2):
52 | c = selftest.mbed.serial_readline()
53 | if c is None:
54 | return selftest.RESULT_IO_SERIAL
55 | selftest.notify(c.strip())
56 |
57 | return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE
58 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/dev_null_auto.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .. import BaseHostTest
17 |
18 | class DevNullTest(BaseHostTest):
19 |
20 | __result = None
21 |
22 | def _callback_result(self, key, value, timestamp):
23 | # We should not see result data in this test
24 | self.__result = False
25 |
26 | def _callback_to_stdout(self, key, value, timestamp):
27 | self.__result = True
28 | self.log("_callback_to_stdout !")
29 |
30 | def setup(self):
31 | self.register_callback("end", self._callback_result)
32 | self.register_callback("to_null", self._callback_result)
33 | self.register_callback("to_stdout", self._callback_to_stdout)
34 |
35 | def result(self):
36 | return self.__result
37 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/echo.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 |
17 | import uuid
18 | from .. import BaseHostTest
19 |
20 | class EchoTest(BaseHostTest):
21 |
22 | __result = None
23 | echo_count = 0
24 | count = 0
25 | uuid_sent = []
26 | uuid_recv = []
27 |
28 | def __send_echo_uuid(self):
29 | if self.echo_count:
30 | str_uuid = str(uuid.uuid4())
31 | self.send_kv("echo", str_uuid)
32 | self.uuid_sent.append(str_uuid)
33 | self.echo_count -= 1
34 |
35 | def _callback_echo(self, key, value, timestamp):
36 | self.uuid_recv.append(value)
37 | self.__send_echo_uuid()
38 |
39 | def _callback_echo_count(self, key, value, timestamp):
40 | # Handshake
41 | self.echo_count = int(value)
42 | self.send_kv(key, value)
43 | # Send first echo to echo server on DUT
44 | self.__send_echo_uuid()
45 |
46 | def setup(self):
47 | self.register_callback("echo", self._callback_echo)
48 | self.register_callback("echo_count", self._callback_echo_count)
49 |
50 | def result(self):
51 | self.__result = self.uuid_sent == self.uuid_recv
52 | return self.__result
53 |
54 | def teardown(self):
55 | pass
56 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/hello_auto.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .. import BaseHostTest
17 |
18 | class HelloTest(BaseHostTest):
19 | HELLO_WORLD = "Hello World"
20 |
21 | __result = None
22 |
23 | def _callback_hello_world(self, key, value, timestamp):
24 | self.__result = value == self.HELLO_WORLD
25 | self.notify_complete()
26 |
27 | def setup(self):
28 | self.register_callback("hello_world", self._callback_hello_world)
29 |
30 | def result(self):
31 | return self.__result
32 |
33 | def teardown(self):
34 | pass
35 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/rtc_auto.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import re
17 | from time import time, strftime, gmtime
18 | from .. import BaseHostTest
19 |
20 | class RTCTest(BaseHostTest):
21 | PATTERN_RTC_VALUE = "\[(\d+)\] \[(\d+-\d+-\d+ \d+:\d+:\d+ [AaPpMm]{2})\]"
22 | re_detect_rtc_value = re.compile(PATTERN_RTC_VALUE)
23 |
24 | __result = None
25 | timestamp = None
26 | rtc_reads = []
27 |
28 | def _callback_timestamp(self, key, value, timestamp):
29 | self.timestamp = int(value)
30 |
31 | def _callback_rtc(self, key, value, timestamp):
32 | self.rtc_reads.append((key, value, timestamp))
33 |
34 | def _callback_end(self, key, value, timestamp):
35 | self.notify_complete()
36 |
37 | def setup(self):
38 | self.register_callback('timestamp', self._callback_timestamp)
39 | self.register_callback('rtc', self._callback_rtc)
40 | self.register_callback('end', self._callback_end)
41 |
42 | def result(self):
43 | def check_strftimes_format(t):
44 | m = self.re_detect_rtc_value.search(t)
45 | if m and len(m.groups()):
46 | sec, time_str = int(m.groups()[0]), m.groups()[1]
47 | correct_time_str = strftime("%Y-%m-%d %H:%M:%S", gmtime(float(sec)))
48 | return time_str == correct_time_str
49 | return False
50 |
51 | ts = [t for _, t, _ in self.rtc_reads]
52 | self.__result = all(filter(check_strftimes_format, ts))
53 | return self.__result
54 |
55 | def teardown(self):
56 | pass
57 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests/wait_us_auto.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from time import time
17 | from .. import BaseHostTest
18 |
19 |
20 | class WaitusTest(BaseHostTest):
21 | """ This test is reading single characters from stdio
22 | and measures time between their occurrences.
23 | """
24 | __result = None
25 | DEVIATION = 0.10 # +/-10%
26 | ticks = []
27 |
28 | def _callback_exit(self, key, value, timeout):
29 | self.notify_complete()
30 |
31 | def _callback_tick(self, key, value, timestamp):
32 | """ {{tick;%d}}} """
33 | self.log("tick! " + str(timestamp))
34 | self.ticks.append((key, value, timestamp))
35 |
36 | def setup(self):
37 | self.register_callback('exit', self._callback_exit)
38 | self.register_callback('tick', self._callback_tick)
39 |
40 | def result(self):
41 | def sub_timestamps(t1, t2):
42 | delta = t1 - t2
43 | deviation = abs(delta - 1.0)
44 | #return True if delta > 0 and deviation <= self.DEVIATION else False
45 | return deviation <= self.DEVIATION
46 |
47 | # Check if time between ticks was accurate
48 | if self.ticks:
49 | # If any ticks were recorded
50 | timestamps = [timestamp for _, _, timestamp in self.ticks]
51 | self.log(str(timestamps))
52 | m = map(sub_timestamps, timestamps[1:], timestamps[:-1])
53 | self.log(str(m))
54 | self.__result = all(m)
55 | else:
56 | self.__result = False
57 | return self.__result
58 |
59 | def teardown(self):
60 | pass
61 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_conn_proxy/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .conn_proxy import conn_process
17 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_conn_proxy/conn_primitive.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from ..host_tests_logger import HtrunLogger
17 |
18 |
19 | class ConnectorPrimitiveException(Exception):
20 | """
21 | Exception in connector primitive module.
22 | """
23 | pass
24 |
25 |
26 | class ConnectorPrimitive(object):
27 |
28 | def __init__(self, name):
29 | self.LAST_ERROR = None
30 | self.logger = HtrunLogger(name)
31 | self.polling_timeout = 60
32 |
33 | def write_kv(self, key, value):
34 | """! Forms and sends Key-Value protocol message.
35 | @details On how to parse K-V sent from DUT see KiViBufferWalker::KIVI_REGEX
36 | On how DUT sends K-V please see greentea_write_postamble() function in greentea-client
37 | @return Returns buffer with K-V message sent to DUT on success, None on failure
38 | """
39 | # All Key-Value messages ends with newline character
40 | kv_buff = "{{%s;%s}}"% (key, value) + '\n'
41 |
42 | if self.write(kv_buff):
43 | self.logger.prn_txd(kv_buff.rstrip())
44 | return kv_buff
45 | else:
46 | return None
47 |
48 | def read(self, count):
49 | """! Read data from DUT
50 | @param count Number of bytes to read
51 | @return Bytes read
52 | """
53 | raise NotImplementedError
54 |
55 | def write(self, payload, log=False):
56 | """! Read data from DUT
57 | @param payload Buffer with data to send
58 | @param log Set to True if you want to enable logging for this function
59 | @return Payload (what was actually sent - if possible to establish that)
60 | """
61 | raise NotImplementedError
62 |
63 | def flush(self):
64 | """! Flush read/write channels of DUT """
65 | raise NotImplementedError
66 |
67 | def reset(self):
68 | """! Reset the dut
69 | """
70 | raise NotImplementedError
71 |
72 | def connected(self):
73 | """! Check if there is a connection to DUT
74 | @return True if there is conenction to DUT (read/write/flush API works)
75 | """
76 | raise NotImplementedError
77 |
78 | def error(self):
79 | """! Returns LAST_ERROR value
80 | @return Value of self.LAST_ERROR
81 | """
82 | return self.LAST_ERROR
83 |
84 | def finish(self):
85 | """! Handle DUT dtor like (close resource) operations here
86 | """
87 | raise NotImplementedError
88 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_logger/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .ht_logger import HtrunLogger
17 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_logger/ht_logger.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 |
17 | import sys
18 | import logging
19 | from functools import partial
20 |
21 |
22 | class HtrunLogger(object):
23 | """! Yet another logger flavour """
24 | def __init__(self, name):
25 | logging.basicConfig(stream=sys.stdout,format='[%(created).2f][%(name)s]%(message)s', level=logging.DEBUG)
26 | self.logger = logging.getLogger(name)
27 | self.format_str = '[%(logger_level)s] %(message)s'
28 |
29 | def __prn_log(self, logger_level, text, timestamp=None):
30 | self.logger.debug(self.format_str% {
31 | 'logger_level' : logger_level,
32 | 'message' : text,
33 | })
34 |
35 | self.prn_dbg = partial(__prn_log, self, 'DBG')
36 | self.prn_wrn = partial(__prn_log, self, 'WRN')
37 | self.prn_err = partial(__prn_log, self, 'ERR')
38 | self.prn_inf = partial(__prn_log, self, 'INF')
39 | self.prn_txt = partial(__prn_log, self, 'TXT')
40 | self.prn_txd = partial(__prn_log, self, 'TXD')
41 | self.prn_rxd = partial(__prn_log, self, 'RXD')
42 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_plugins/module_copy_silabs.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import os
17 | from .host_test_plugins import HostTestPluginBase
18 |
19 |
20 | class HostTestPluginCopyMethod_Silabs(HostTestPluginBase):
21 |
22 | # Plugin interface
23 | name = 'HostTestPluginCopyMethod_Silabs'
24 | type = 'CopyMethod'
25 | capabilities = ['eACommander', 'eACommander-usb']
26 | required_parameters = ['image_path', 'destination_disk']
27 | stable = True
28 |
29 | def __init__(self):
30 | """ ctor
31 | """
32 | HostTestPluginBase.__init__(self)
33 |
34 | def setup(self, *args, **kwargs):
35 | """ Configure plugin, this function should be called before plugin execute() method is used.
36 | """
37 | self.EACOMMANDER_CMD = 'eACommander.exe'
38 | return True
39 |
40 | def execute(self, capability, *args, **kwargs):
41 | """! Executes capability by name
42 |
43 | @param capability Capability name
44 | @param args Additional arguments
45 | @param kwargs Additional arguments
46 |
47 | @details Each capability e.g. may directly just call some command line program or execute building pythonic function
48 |
49 | @return Capability call return value
50 | """
51 | result = False
52 | if self.check_parameters(capability, *args, **kwargs) is True:
53 | image_path = os.path.normpath(kwargs['image_path'])
54 | destination_disk = os.path.normpath(kwargs['destination_disk'])
55 | if capability == 'eACommander':
56 | cmd = [self.EACOMMANDER_CMD,
57 | '--serialno', destination_disk,
58 | '--flash', image_path,
59 | '--resettype', '2', '--reset']
60 | result = self.run_command(cmd)
61 | elif capability == 'eACommander-usb':
62 | cmd = [self.EACOMMANDER_CMD,
63 | '--usb', destination_disk,
64 | '--flash', image_path]
65 | result = self.run_command(cmd)
66 | return result
67 |
68 |
69 | def load_plugin():
70 | """ Returns plugin available in this module
71 | """
72 | return HostTestPluginCopyMethod_Silabs()
73 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_plugins/module_copy_stlink.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import os
17 | from .host_test_plugins import HostTestPluginBase
18 |
19 |
20 | class HostTestPluginCopyMethod_Stlink(HostTestPluginBase):
21 |
22 | # Plugin interface
23 | name = 'HostTestPluginCopyMethod_Stlink'
24 | type = 'CopyMethod'
25 | capabilities = ['stlink']
26 | required_parameters = ['image_path']
27 |
28 | def __init__(self):
29 | """ ctor
30 | """
31 | HostTestPluginBase.__init__(self)
32 |
33 | def is_os_supported(self, os_name=None):
34 | """! In this implementation this plugin only is supporeted under Windows machines
35 | """
36 | # If no OS name provided use host OS name
37 | if not os_name:
38 | os_name = self.mbed_os_support()
39 |
40 | # This plugin only works on Windows
41 | if os_name and os_name.startswith('Windows'):
42 | return True
43 | return False
44 |
45 | def setup(self, *args, **kwargs):
46 | """! Configure plugin, this function should be called before plugin execute() method is used.
47 | """
48 | self.ST_LINK_CLI = 'ST-LINK_CLI.exe'
49 | return True
50 |
51 | def execute(self, capability, *args, **kwargs):
52 | """! Executes capability by name
53 |
54 | @param capability Capability name
55 | @param args Additional arguments
56 | @param kwargs Additional arguments
57 |
58 | @details Each capability e.g. may directly just call some command line program or execute building pythonic function
59 |
60 | @return Capability call return value
61 | """
62 | result = False
63 | if self.check_parameters(capability, *args, **kwargs) is True:
64 | image_path = os.path.normpath(kwargs['image_path'])
65 | if capability == 'stlink':
66 | # Example:
67 | # ST-LINK_CLI.exe -p "C:\Work\mbed\build\test\DISCO_F429ZI\GCC_ARM\MBED_A1\basic.bin"
68 | cmd = [self.ST_LINK_CLI,
69 | '-p', image_path, '0x08000000',
70 | '-V'
71 | ]
72 | result = self.run_command(cmd)
73 | return result
74 |
75 |
76 | def load_plugin():
77 | """ Returns plugin available in this module
78 | """
79 | return HostTestPluginCopyMethod_Stlink()
80 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_plugins/module_copy_ublox.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import os
17 | from .host_test_plugins import HostTestPluginBase
18 |
19 |
20 | class HostTestPluginCopyMethod_ublox(HostTestPluginBase):
21 |
22 | # Plugin interface
23 | name = 'HostTestPluginCopyMethod_ublox'
24 | type = 'CopyMethod'
25 | capabilities = ['ublox']
26 | required_parameters = ['image_path']
27 |
28 | def is_os_supported(self, os_name=None):
29 | """! In this implementation this plugin only is supporeted under Windows machines
30 | """
31 | # If no OS name provided use host OS name
32 | if not os_name:
33 | os_name = self.mbed_os_support()
34 |
35 | # This plugin only works on Windows
36 | if os_name and os_name.startswith('Windows'):
37 | return True
38 | return False
39 |
40 | def setup(self, *args, **kwargs):
41 | """! Configure plugin, this function should be called before plugin execute() method is used.
42 | """
43 | self.FLASH_ERASE = 'FlashErase.exe'
44 | return True
45 |
46 | def execute(self, capability, *args, **kwargs):
47 | """! Executes capability by name
48 |
49 | @param capability Capability name
50 | @param args Additional arguments
51 | @param kwargs Additional arguments
52 |
53 | @details Each capability e.g. may directly just call some command line program or execute building pythonic function
54 |
55 | @return Capability call return value
56 | """
57 | result = False
58 | if self.check_parameters(capability, *args, **kwargs) is True:
59 | image_path = os.path.normpath(kwargs['image_path'])
60 | if capability == 'ublox':
61 | # Example:
62 | # FLASH_ERASE -c 2 -s 0xD7000 -l 0x20000 -f "binary_file.bin"
63 | cmd = [self.FLASH_ERASE,
64 | '-c',
65 | 'A',
66 | '-s',
67 | '0xD7000',
68 | '-l',
69 | '0x20000',
70 | '-f', image_path
71 | ]
72 | result = self.run_command(cmd)
73 | return result
74 |
75 |
76 | def load_plugin():
77 | """ Returns plugin available in this module
78 | """
79 | return HostTestPluginCopyMethod_ublox()
80 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_plugins/module_reset_pyocd.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .host_test_plugins import HostTestPluginBase
17 |
18 | try:
19 | from pyocd.core.helpers import ConnectHelper
20 | PYOCD_PRESENT = True
21 | except ImportError:
22 | PYOCD_PRESENT = False
23 |
24 |
25 | class HostTestPluginResetMethod_pyOCD(HostTestPluginBase):
26 |
27 | # Plugin interface
28 | name = 'HostTestPluginResetMethod_pyOCD'
29 | type = 'ResetMethod'
30 | stable = True
31 | capabilities = ['pyocd']
32 | required_parameters = ['target_id']
33 |
34 | def __init__(self):
35 | """! ctor
36 | @details We can check module version by referring to version attribute
37 | import pkg_resources
38 | print pkg_resources.require("mbed-host-tests")[0].version
39 | '2.7'
40 | """
41 | HostTestPluginBase.__init__(self)
42 |
43 | def setup(self, *args, **kwargs):
44 | """! Configure plugin, this function should be called before plugin execute() method is used.
45 | """
46 | return True
47 |
48 | def execute(self, capability, *args, **kwargs):
49 | """! Executes capability by name
50 | @param capability Capability name
51 | @param args Additional arguments
52 | @param kwargs Additional arguments
53 | @details Each capability e.g. may directly just call some command line program or execute building pythonic function
54 | @return Capability call return value
55 | """
56 | if not PYOCD_PRESENT:
57 | self.print_plugin_error(
58 | 'The "pyocd" feature is not installed. Please run '
59 | '"pip install mbed-os-tools[pyocd]" to enable the "pyocd" reset plugin.'
60 | )
61 | return False
62 |
63 | if not kwargs['target_id']:
64 | self.print_plugin_error("Error: target_id not set")
65 | return False
66 |
67 | result = False
68 | if self.check_parameters(capability, *args, **kwargs) is True:
69 | if kwargs['target_id']:
70 | if capability == 'pyocd':
71 | target_id = kwargs['target_id']
72 | with ConnectHelper.session_with_chosen_probe(unique_id=target_id,
73 | resume_on_disconnect=False) as session:
74 | session.target.reset()
75 | session.target.resume()
76 | result = True
77 | return result
78 |
79 |
80 | def load_plugin():
81 | """! Returns plugin available in this module
82 | """
83 | return HostTestPluginResetMethod_pyOCD()
84 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_plugins/module_reset_silabs.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .host_test_plugins import HostTestPluginBase
17 |
18 |
19 | class HostTestPluginResetMethod_SiLabs(HostTestPluginBase):
20 |
21 | # Plugin interface
22 | name = 'HostTestPluginResetMethod_SiLabs'
23 | type = 'ResetMethod'
24 | capabilities = ['eACommander', 'eACommander-usb']
25 | required_parameters = ['disk']
26 | stable = True
27 |
28 | def __init__(self):
29 | """ ctor
30 | """
31 | HostTestPluginBase.__init__(self)
32 |
33 | def setup(self, *args, **kwargs):
34 | """ Configure plugin, this function should be called before plugin execute() method is used.
35 | """
36 | # Note you need to have eACommander.exe on your system path!
37 | self.EACOMMANDER_CMD = 'eACommander.exe'
38 | return True
39 |
40 | def execute(self, capability, *args, **kwargs):
41 | """! Executes capability by name
42 |
43 | @param capability Capability name
44 | @param args Additional arguments
45 | @param kwargs Additional arguments
46 |
47 | @details Each capability e.g. may directly just call some command line program or execute building pythonic function
48 |
49 | @return Capability call return value
50 | """
51 | result = False
52 | if self.check_parameters(capability, *args, **kwargs) is True:
53 | disk = kwargs['disk'].rstrip('/\\')
54 |
55 | if capability == 'eACommander':
56 | # For this copy method 'disk' will be 'serialno' for eACommander command line parameters
57 | # Note: Commands are executed in the order they are specified on the command line
58 | cmd = [self.EACOMMANDER_CMD,
59 | '--serialno', disk,
60 | '--resettype', '2', '--reset',]
61 | result = self.run_command(cmd)
62 | elif capability == 'eACommander-usb':
63 | # For this copy method 'disk' will be 'usb address' for eACommander command line parameters
64 | # Note: Commands are executed in the order they are specified on the command line
65 | cmd = [self.EACOMMANDER_CMD,
66 | '--usb', disk,
67 | '--resettype', '2', '--reset',]
68 | result = self.run_command(cmd)
69 | return result
70 |
71 |
72 | def load_plugin():
73 | """ Returns plugin available in this module
74 | """
75 | return HostTestPluginResetMethod_SiLabs()
76 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_plugins/module_reset_ublox.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .host_test_plugins import HostTestPluginBase
17 |
18 |
19 | class HostTestPluginResetMethod_ublox(HostTestPluginBase):
20 |
21 | # Plugin interface
22 | name = 'HostTestPluginResetMethod_ublox'
23 | type = 'ResetMethod'
24 | capabilities = ['ublox']
25 | required_parameters = []
26 | stable = False
27 |
28 | def is_os_supported(self, os_name=None):
29 | """! In this implementation this plugin only is supporeted under Windows machines
30 | """
31 | # If no OS name provided use host OS name
32 | if not os_name:
33 | os_name = self.mbed_os_support()
34 |
35 | # This plugin only works on Windows
36 | if os_name and os_name.startswith('Windows'):
37 | return True
38 | return False
39 |
40 | def setup(self, *args, **kwargs):
41 | """! Configure plugin, this function should be called before plugin execute() method is used.
42 | """
43 | # Note you need to have jlink.exe on your system path!
44 | self.JLINK = 'jlink.exe'
45 | return True
46 |
47 | def execute(self, capability, *args, **kwargs):
48 | """! Executes capability by name
49 |
50 | @param capability Capability name
51 | @param args Additional arguments
52 | @param kwargs Additional arguments
53 |
54 | @details Each capability e.g. may directly just call some command line program or execute building pythonic function
55 |
56 | @return Capability call return value
57 | """
58 | result = False
59 | if self.check_parameters(capability, *args, **kwargs) is True:
60 | if capability == 'ublox':
61 | # Example:
62 | # JLINK.exe --CommanderScript aCommandFile
63 | cmd = [self.JLINK,
64 | '-CommanderScript',
65 | r'reset.jlink']
66 | result = self.run_command(cmd)
67 | return result
68 |
69 |
70 | def load_plugin():
71 | """ Returns plugin available in this module
72 | """
73 | return HostTestPluginResetMethod_ublox()
74 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_registry/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | """! @package host_registry
17 |
18 | Host registry is used to store all host tests (by id) which can be called from test framework
19 |
20 | """
21 |
22 | from .host_registry import HostRegistry
23 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_runner/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | """! @package mbed-host-test-runner
17 |
18 | This package contains basic host test implementation with algorithms to flash and reset device.
19 | Functionality can be overridden by set of plugins which can provide specialised flashing and reset implementations.
20 |
21 | """
22 |
23 | from pkg_resources import get_distribution
24 |
25 | __version__ = get_distribution("mbed-os-tools").version
26 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/host_tests_toolbox/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from .host_functional import reset_dev
17 | from .host_functional import flash_dev
18 | from .host_functional import handle_send_break_cmd
19 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/mbed_common_api.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | from subprocess import call, Popen, PIPE
17 |
18 |
19 | def run_cli_command(cmd, shell=True, verbose=False):
20 | """! Runs command from command line
21 | @param shell Shell command (e.g. ls, ps)
22 | @param verbose Verbose mode flag
23 | @return Returns (True, 0) if command was executed successfully else return (False, error code)
24 | """
25 | result = True
26 | ret = 0
27 | try:
28 | ret = call(cmd, shell=shell)
29 | if ret:
30 | result = False
31 | if verbose:
32 | print("mbedgt: [ret=%d] Command: %s"% (int(ret), cmd))
33 | except OSError as e:
34 | result = False
35 | if verbose:
36 | print("mbedgt: [ret=%d] Command: %s"% (int(ret), cmd))
37 | print(str(e))
38 | return (result, ret)
39 |
40 | def run_cli_process(cmd):
41 | """! Runs command as a process and return stdout, stderr and ret code
42 | @param cmd Command to execute
43 | @return Tuple of (stdout, stderr, returncode)
44 | """
45 | try:
46 | p = Popen(cmd, stdout=PIPE, stderr=PIPE)
47 | _stdout, _stderr = p.communicate()
48 | except OSError as e:
49 | print("mbedgt: Command: %s"% (cmd))
50 | print(str(e))
51 | print("mbedgt: traceback...")
52 | print(e.child_traceback)
53 | return str(), str(), -1
54 | return _stdout, _stderr, p.returncode
55 |
--------------------------------------------------------------------------------
/src/mbed_os_tools/test/mbed_coverage_api.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import os
17 |
18 | """
19 | def __default_coverage_start_callback(self, key, value, timestamp):
20 | # {{__coverage_start;PATH;PAYLOAD}}
21 | # PAYLAODED is HEX coded string
22 | lcov_path, lcov_payload = value.split(';')
23 | try:
24 | bin_payload = coverage_pack_hex_payload(lcov_payload)
25 | coverage_dump_file(lcov_path, bin_payload)
26 |
27 | self.log("dumped %d bytes to '%s'"% (len(bin_payload), lcov_path))
28 | except Exception as e:
29 | self.log("LCOV:" + str(e))
30 | """
31 |
32 | def coverage_pack_hex_payload(payload):
33 | """! Convert a block of hex string data back to binary and return the binary data
34 | @param payload String with hex encoded ascii data, e.g.: '6164636772...'
35 | @return bytearray with payload with data
36 | """
37 | # This payload might be packed with dot compression
38 | # where byte value 0x00 is coded as ".", and not as "00"
39 | payload = payload.replace('.', '00')
40 |
41 | hex_pairs = map(''.join, zip(*[iter(payload)] * 2)) # ['61', '64', '63', '67', '72', ... ]
42 | bin_payload = bytearray([int(s, 16) for s in hex_pairs])
43 | return bin_payload
44 |
45 |
46 | def coverage_dump_file(build_path, path, payload):
47 | """! Creates file and dumps payload to it on specified path (even if path doesn't exist)
48 | @param path Path to file
49 | @param payload Binary data to store in a file
50 | @return True if operation was completed
51 | """
52 | result = True
53 | try:
54 | d, filename = os.path.split(path)
55 | if not os.path.isabs(d) and not os.path.exists(d):
56 | # For a relative path that do not exist. Try adding ./build/ prefix
57 | d = build_path
58 | path = os.path.join(d, filename)
59 | if not os.path.exists(d):
60 | os.makedirs(d)
61 | with open(path, "wb") as f:
62 | f.write(payload)
63 | except IOError as e:
64 | print(str(e))
65 | result = False
66 | return result
67 |
--------------------------------------------------------------------------------
/test/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
--------------------------------------------------------------------------------
/test/detect/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | """! @package mbed-ls-test
17 |
18 | Unit tests for mbed-ls package
19 |
20 | """
21 |
--------------------------------------------------------------------------------
/test/detect/detect_os.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 | import os
18 | import sys
19 | import errno
20 | import logging
21 |
22 | import platform
23 | from mbed_os_tools.detect.main import create
24 | from mbed_os_tools.detect.main import mbed_os_support
25 | from mbed_os_tools.detect.main import mbed_lstools_os_info
26 |
27 |
28 | class DetectOSTestCase(unittest.TestCase):
29 | """ Test cases for host OS related functionality. Helpful during porting
30 | """
31 |
32 | def setUp(self):
33 | pass
34 |
35 | def tearDown(self):
36 | pass
37 |
38 | def test_porting_mbed_lstools_os_info(self):
39 | self.assertNotEqual(None, mbed_lstools_os_info())
40 |
41 | def test_porting_mbed_os_support(self):
42 | self.assertNotEqual(None, mbed_os_support())
43 |
44 | def test_porting_create(self):
45 | self.assertNotEqual(None, create())
46 |
47 | def test_supported_os_name(self):
48 | os_names = ['Windows7', 'Ubuntu', 'LinuxGeneric', 'Darwin']
49 | self.assertIn(mbed_os_support(), os_names)
50 |
51 | def test_detect_os_support_ext(self):
52 | os_info = (os.name,
53 | platform.system(),
54 | platform.release(),
55 | platform.version(),
56 | sys.platform)
57 |
58 | self.assertEqual(os_info, mbed_lstools_os_info())
59 |
60 |
61 | if __name__ == '__main__':
62 | unittest.main()
63 |
--------------------------------------------------------------------------------
/test/detect/test_data/efm32pg_stk3401_jlink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/detect/test_data/efm32pg_stk3401_jlink/README.TXT:
--------------------------------------------------------------------------------
1 | Silicon Labs J-Link MSD volume.
2 |
3 | Copying a binary file here will flash it to the MCU.
4 |
5 | Supported binary file formats:
6 | - Intel Hex (.hex)
7 | - Motorola s-records (.mot)
8 | - Binary (.bin/.par/.crd)
9 |
10 | Known limitations:
11 | - Virtual COM port speed is currently fixed at 115200 bps
12 | - Using other kit functionality such as energy profiling or debugger while flashing is
13 | not supported.
14 | Workaround: Pause any energy profiling and disconnect any connected debug sessions
15 | before flashing.
16 |
--------------------------------------------------------------------------------
/test/detect/test_data/efm32pg_stk3401_jlink/sl_kit.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EFM32PG-STK3401 - Pearl Gecko STK
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/detect/test_data/efm32pg_stk3401_jlink/sl_qsg.html:
--------------------------------------------------------------------------------
1 | Simplicity Studio Shortcut
2 |
--------------------------------------------------------------------------------
/test/detect/test_data/k64f_daplink/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | # DAPLink Firmware - see https://mbed.com/daplink
2 | Unique ID: 0240000032044e45000a700a997b00356781000097969900
3 | HIC ID: 97969900
4 | Auto Reset: 0
5 | Automation allowed: 0
6 | Overflow detection: 0
7 | Daplink Mode: Interface
8 | Interface Version: 0244
9 | Git SHA: 363abb00ee17ad50cb407c6d2e299407332e3c85
10 | Local Mods: 1
11 | USB Interfaces: MSD, CDC, HID
12 | Interface CRC: 0xc44e96e1
13 | Remount count: 0
14 |
--------------------------------------------------------------------------------
/test/detect/test_data/k64f_daplink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/detect/test_data/lpc1768/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mbed Website Shortcut
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/detect/test_data/lpc1768/basic.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ARMmbed/mbed-os-tools/c467d6f1498018669872883a95a8c9c9120d6abd/test/detect/test_data/lpc1768/basic.bin
--------------------------------------------------------------------------------
/test/detect/test_data/lpc1768/dirs.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ARMmbed/mbed-os-tools/c467d6f1498018669872883a95a8c9c9120d6abd/test/detect/test_data/lpc1768/dirs.bin
--------------------------------------------------------------------------------
/test/detect/test_data/nrf51_microbit/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | # DAPLink Firmware - see https://mbed.com/daplink
2 | Unique ID: 9900007031324e45000f9019000000340000000097969901
3 | HIC ID: 97969901
4 | Auto Reset: 1
5 | Automation allowed: 0
6 | Overflow detection: 0
7 | Daplink Mode: Interface
8 | Interface Version: 0244
9 | Git SHA: 72ea244a3a9219299c5655c614c955185451e98e
10 | Local Mods: 1
11 | USB Interfaces: MSD, CDC, HID, WebUSB
12 | Interface CRC: 0xfdd0c098
13 | Remount count: 0
14 |
--------------------------------------------------------------------------------
/test/detect/test_data/nrf51_microbit/MICROBIT.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/detect/test_data/nrf52_dk_daplink/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | # DAPLink Firmware - see https://mbed.com/daplink
2 | Unique ID: 110100004420312043574641323032203233303397969903
3 | HIC ID: 97969903
4 | Auto Reset: 0
5 | Automation allowed: 0
6 | Overflow detection: 0
7 | Daplink Mode: Interface
8 | Interface Version: 0245
9 | Git SHA: aace60cd16996cc881567f35eb84db063a9268b7
10 | Local Mods: 0
11 | USB Interfaces: MSD, CDC, HID
12 | Interface CRC: 0xfa307a74
13 | Remount count: 0
14 |
--------------------------------------------------------------------------------
/test/detect/test_data/nrf52_dk_daplink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | mbed Website Shortcut
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/detect/test_data/nrf52_dk_jlink/MBED.HTM:
--------------------------------------------------------------------------------
1 | mbed Website Shortcut
--------------------------------------------------------------------------------
/test/detect/test_data/nrf52_dk_jlink/README.TXT:
--------------------------------------------------------------------------------
1 | SEGGER J-Link MSD volume.
2 | This volume is used to update the flash content of your target device.
--------------------------------------------------------------------------------
/test/detect/test_data/nrf52_dk_jlink/Segger.html:
--------------------------------------------------------------------------------
1 | SEGGER Shortcut
--------------------------------------------------------------------------------
/test/detect/test_data/nrf52_dk_jlink/User Guide.html:
--------------------------------------------------------------------------------
1 | Starter Guide Shortcut
--------------------------------------------------------------------------------
/test/detect/test_data/nucleo_f411re_stlink/DETAILS.TXT:
--------------------------------------------------------------------------------
1 | Version: 0221
2 | Build: Jan 11 2016 16:12:36
3 |
--------------------------------------------------------------------------------
/test/detect/test_data/nucleo_f411re_stlink/MBED.HTM:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mbed Website Shortcut
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/test/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | """! @package mbed-host-tests-test
17 |
18 | Unit tests for mbed-host-tests package
19 |
20 | """
21 |
--------------------------------------------------------------------------------
/test/test/basic_gt.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 |
18 | class BasicTestCase(unittest.TestCase):
19 | """ Basic true asserts to see that testing is executed
20 | """
21 |
22 | def setUp(self):
23 | pass
24 |
25 | def tearDown(self):
26 | pass
27 |
28 | def test_example(self):
29 | self.assertEqual(True, True)
30 | self.assertNotEqual(True, False)
31 |
32 | if __name__ == '__main__':
33 | unittest.main()
34 |
--------------------------------------------------------------------------------
/test/test/basic_ht.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 |
18 | class BasicTestCase(unittest.TestCase):
19 |
20 | def setUp(self):
21 | pass
22 |
23 | def tearDown(self):
24 | pass
25 |
26 | def test_example(self):
27 | self.assertEqual(True, True)
28 | self.assertNotEqual(True, False)
29 |
30 | if __name__ == '__main__':
31 | unittest.main()
32 |
--------------------------------------------------------------------------------
/test/test/event_callback_decorator.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 |
18 | from mbed_os_tools.test.host_tests.base_host_test import BaseHostTest, event_callback
19 |
20 |
21 | class TestEvenCallbackDecorator(unittest.TestCase):
22 | def setUp(self):
23 | pass
24 |
25 | def tearDown(self):
26 | pass
27 |
28 | def test_event_callback_decorator(self):
29 | class Ht(BaseHostTest):
30 |
31 | @event_callback('Hi')
32 | def hi(self, key, value, timestamp):
33 | print('hi')
34 |
35 | @event_callback('Hello')
36 | def hello(self, key, value, timestamp):
37 | print('hello')
38 | h = Ht()
39 | h.setup()
40 | callbacks = h.get_callbacks()
41 | self.assertIn('Hi', callbacks)
42 | self.assertIn('Hello', callbacks)
43 |
--------------------------------------------------------------------------------
/test/test/host_registry.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 | from mbed_os_tools.test.host_tests_registry import HostRegistry
18 | from mbed_os_tools.test import BaseHostTest
19 |
20 |
21 | class HostRegistryTestCase(unittest.TestCase):
22 |
23 | class HostTestClassMock(BaseHostTest):
24 | def setup(self):
25 | pass
26 |
27 | def result(self):
28 | pass
29 |
30 | def teardown(self):
31 | pass
32 |
33 | def setUp(self):
34 | self.HOSTREGISTRY = HostRegistry()
35 |
36 | def tearDown(self):
37 | pass
38 |
39 | def test_register_host_test(self):
40 | self.HOSTREGISTRY.register_host_test('host_test_mock_auto', self.HostTestClassMock())
41 | self.assertEqual(True, self.HOSTREGISTRY.is_host_test('host_test_mock_auto'))
42 |
43 | def test_unregister_host_test(self):
44 | self.HOSTREGISTRY.register_host_test('host_test_mock_2_auto', self.HostTestClassMock())
45 | self.assertEqual(True, self.HOSTREGISTRY.is_host_test('host_test_mock_2_auto'))
46 | self.assertNotEqual(None, self.HOSTREGISTRY.get_host_test('host_test_mock_2_auto'))
47 | self.HOSTREGISTRY.unregister_host_test('host_test_mock_2_auto')
48 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test('host_test_mock_2_auto'))
49 |
50 | def test_get_host_test(self):
51 | self.HOSTREGISTRY.register_host_test('host_test_mock_3_auto', self.HostTestClassMock())
52 | self.assertEqual(True, self.HOSTREGISTRY.is_host_test('host_test_mock_3_auto'))
53 | self.assertNotEqual(None, self.HOSTREGISTRY.get_host_test('host_test_mock_3_auto'))
54 |
55 | def test_is_host_test(self):
56 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test(''))
57 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test(None))
58 | self.assertEqual(False, self.HOSTREGISTRY.is_host_test('xyz'))
59 |
60 | def test_host_test_str_not_empty(self):
61 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
62 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
63 | self.assertNotEqual(None, ht)
64 |
65 | def test_host_test_has_name_attribute(self):
66 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
67 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
68 | self.assertTrue(hasattr(ht, 'setup'))
69 | self.assertTrue(hasattr(ht, 'result'))
70 | self.assertTrue(hasattr(ht, 'teardown'))
71 |
72 |
73 | if __name__ == '__main__':
74 | unittest.main()
75 |
--------------------------------------------------------------------------------
/test/test/host_test_base.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 |
18 | from mbed_os_tools.test.host_tests_registry import HostRegistry
19 |
20 | class BaseHostTestTestCase(unittest.TestCase):
21 |
22 | def setUp(self):
23 | self.HOSTREGISTRY = HostRegistry()
24 |
25 | def tearDown(self):
26 | pass
27 |
28 | def test_host_test_has_setup_teardown_attribute(self):
29 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
30 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
31 | self.assertTrue(hasattr(ht, 'setup'))
32 | self.assertTrue(hasattr(ht, 'teardown'))
33 |
34 | def test_host_test_has_no_rampUpDown_attribute(self):
35 | for ht_name in self.HOSTREGISTRY.HOST_TESTS:
36 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
37 | self.assertFalse(hasattr(ht, 'rampUp'))
38 | self.assertFalse(hasattr(ht, 'rampDown'))
39 |
40 | if __name__ == '__main__':
41 | unittest.main()
42 |
--------------------------------------------------------------------------------
/test/test/host_test_black_box.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 | from copy import copy
18 | from mbed_os_tools.test import init_host_test_cli_params
19 | from mbed_os_tools.test.host_tests_runner.host_test_default import DefaultTestSelector
20 |
21 | from .mocks.environment.linux import MockTestEnvironmentLinux
22 | from .mocks.environment.darwin import MockTestEnvironmentDarwin
23 | from .mocks.environment.windows import MockTestEnvironmentWindows
24 |
25 | mock_platform_info = {
26 | "platform_name": "K64F",
27 | "target_id": "0240000031754e45000c0018948500156461000097969900",
28 | "mount_point": "/mnt/DAPLINK",
29 | "serial_port": "/dev/ttyACM0",
30 | }
31 | mock_image_path = "BUILD/tests/K64F/GCC_ARM/TESTS/network/interface/interface.bin"
32 |
33 | class BlackBoxHostTestTestCase(unittest.TestCase):
34 |
35 | def _run_host_test(self, environment):
36 | with environment as _env:
37 | test_selector = DefaultTestSelector(init_host_test_cli_params())
38 | result = test_selector.execute()
39 | test_selector.finish()
40 |
41 | self.assertEqual(result, 0)
42 |
43 | def test_host_test_linux(self):
44 | self._run_host_test(
45 | MockTestEnvironmentLinux(self, mock_platform_info, mock_image_path)
46 | )
47 |
48 | def test_host_test_darwin(self):
49 | self._run_host_test(
50 | MockTestEnvironmentDarwin(self, mock_platform_info, mock_image_path)
51 | )
52 |
53 | def test_host_test_windows(self):
54 | win_mock_platform_info = copy(mock_platform_info)
55 | win_mock_platform_info["serial_port"] = "COM5"
56 |
57 | self._run_host_test(
58 | MockTestEnvironmentWindows(self, win_mock_platform_info, mock_image_path)
59 | )
60 |
61 | if __name__ == '__main__':
62 | unittest.main()
63 |
--------------------------------------------------------------------------------
/test/test/host_test_default.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 | from mbed_os_tools.test.host_tests_runner.host_test_default import DefaultTestSelector
18 |
19 |
20 | class HostTestDefaultTestCase(unittest.TestCase):
21 |
22 | def test_os_info(self):
23 | expected = {
24 | "grm_module" : "module_name",
25 | "grm_host" : "10.2.123.43",
26 | "grm_port" : "3334",
27 | }
28 |
29 | # Case that includes an IP address but no protocol
30 | arg = [expected["grm_module"], expected["grm_host"], expected["grm_port"]]
31 | result = DefaultTestSelector._parse_grm(":".join(arg))
32 | self.assertEqual(result, expected)
33 |
34 | # Case that includes an IP address but no protocol nor a no port
35 | expected["grm_port"] = None
36 | arg = [expected["grm_module"], expected["grm_host"]]
37 | result = DefaultTestSelector._parse_grm(":".join(arg))
38 | self.assertEqual(result, expected)
39 |
40 | # Case that includes an IP address and a protocol
41 | expected["grm_host"] = "https://10.2.123.43"
42 | expected["grm_port"] = "443"
43 | arg = [expected["grm_module"], expected["grm_host"], expected["grm_port"]]
44 | result = DefaultTestSelector._parse_grm(":".join(arg))
45 | self.assertEqual(result, expected)
46 |
47 | # Case that includes an IP address and a protocol, but no port
48 | expected["grm_port"] = None
49 | arg = [expected["grm_module"], expected["grm_host"]]
50 | result = DefaultTestSelector._parse_grm(":".join(arg))
51 | self.assertEqual(result, expected)
52 |
53 | if __name__ == '__main__':
54 | unittest.main()
55 |
--------------------------------------------------------------------------------
/test/test/host_test_os_detect.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 |
18 | import os
19 | import re
20 | import sys
21 | import platform
22 | from mbed_os_tools.test.host_tests_plugins.host_test_plugins import HostTestPluginBase
23 |
24 |
25 | class HostOSDetectionTestCase(unittest.TestCase):
26 |
27 | def setUp(self):
28 | self.plugin_base = HostTestPluginBase()
29 | self.os_names = ['Windows7', 'Ubuntu', 'LinuxGeneric', 'Darwin']
30 | self.re_float = re.compile("^\d+\.\d+$")
31 |
32 | def tearDown(self):
33 | pass
34 |
35 | def test_os_info(self):
36 | self.assertNotEqual(None, self.plugin_base.mbed_os_info())
37 |
38 | def test_os_support(self):
39 | self.assertNotEqual(None, self.plugin_base.mbed_os_support())
40 |
41 | def test_supported_os_name(self):
42 | self.assertIn(self.plugin_base.mbed_os_support(), self.os_names)
43 |
44 | def test_detect_os_support_ext(self):
45 | os_info = (os.name,
46 | platform.system(),
47 | platform.release(),
48 | platform.version(),
49 | sys.platform)
50 |
51 | self.assertEqual(os_info, self.plugin_base.mbed_os_info())
52 |
53 |
54 | if __name__ == '__main__':
55 | unittest.main()
56 |
--------------------------------------------------------------------------------
/test/test/host_test_plugins.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 |
18 | from mbed_os_tools.test.host_tests_plugins.module_reset_mbed import HostTestPluginResetMethod_Mbed
19 |
20 | class HostOSDetectionTestCase(unittest.TestCase):
21 |
22 | def setUp(self):
23 | self.plugin_reset_mbed = HostTestPluginResetMethod_Mbed()
24 |
25 | def tearDown(self):
26 | pass
27 |
28 | def test_examle(self):
29 | pass
30 |
31 | def test_pyserial_version_detect(self):
32 | self.assertEqual(1.0, self.plugin_reset_mbed.get_pyserial_version("1.0"))
33 | self.assertEqual(1.0, self.plugin_reset_mbed.get_pyserial_version("1.0.0"))
34 | self.assertEqual(2.7, self.plugin_reset_mbed.get_pyserial_version("2.7"))
35 | self.assertEqual(2.7, self.plugin_reset_mbed.get_pyserial_version("2.7.1"))
36 | self.assertEqual(3.0, self.plugin_reset_mbed.get_pyserial_version("3.0"))
37 | self.assertEqual(3.0, self.plugin_reset_mbed.get_pyserial_version("3.0.1"))
38 |
39 |
40 | if __name__ == '__main__':
41 | unittest.main()
42 |
--------------------------------------------------------------------------------
/test/test/host_test_scheme.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import six
17 | import unittest
18 | from mbed_os_tools.test.host_tests_registry import HostRegistry
19 |
20 |
21 | class HostRegistryTestCase(unittest.TestCase):
22 |
23 | def setUp(self):
24 | self.HOSTREGISTRY = HostRegistry()
25 |
26 | def tearDown(self):
27 | pass
28 |
29 | def test_host_test_class_has_test_attr(self):
30 | """ Check if host test has 'result' class member
31 | """
32 | for i, ht_name in enumerate(self.HOSTREGISTRY.HOST_TESTS):
33 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
34 | if ht is not None:
35 | self.assertEqual(True, hasattr(ht, 'result'))
36 |
37 | def test_host_test_class_test_attr_callable(self):
38 | """ Check if host test has callable 'result' class member
39 | """
40 | for i, ht_name in enumerate(self.HOSTREGISTRY.HOST_TESTS):
41 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
42 | if ht:
43 | self.assertEqual(True, hasattr(ht, 'result') and callable(getattr(ht, 'result')))
44 |
45 | def test_host_test_class_test_attr_callable_args_num(self):
46 | """ Check if host test has callable setup(), result() and teardown() class member has 2 arguments
47 | """
48 | for i, ht_name in enumerate(self.HOSTREGISTRY.HOST_TESTS):
49 | ht = self.HOSTREGISTRY.HOST_TESTS[ht_name]
50 | if ht and hasattr(ht, 'setup') and callable(getattr(ht, 'setup')):
51 | self.assertEqual(1, six.get_function_code(ht.setup).co_argcount)
52 | if ht and hasattr(ht, 'result') and callable(getattr(ht, 'result')):
53 | self.assertEqual(1, six.get_function_code(ht.result).co_argcount)
54 | if ht and hasattr(ht, 'teardown') and callable(getattr(ht, 'teardown')):
55 | self.assertEqual(1, six.get_function_code(ht.teardown).co_argcount)
56 |
57 |
58 | if __name__ == '__main__':
59 | unittest.main()
60 |
--------------------------------------------------------------------------------
/test/test/mbed_gt_coverage_api.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import os
17 | import unittest
18 | from mbed_os_tools.test import mbed_coverage_api
19 |
20 |
21 | class GreenteaCoverageAPI(unittest.TestCase):
22 |
23 | def setUp(self):
24 | pass
25 |
26 | def test_x(self):
27 | pass
28 |
29 | def test_coverage_pack_hex_payload(self):
30 | # This function takesstring as input
31 | r = mbed_coverage_api.coverage_pack_hex_payload('')
32 | self.assertEqual(bytearray(b''), r)
33 |
34 | r = mbed_coverage_api.coverage_pack_hex_payload('6164636772')
35 | self.assertEqual(bytearray(b'adcgr'), r)
36 |
37 | r = mbed_coverage_api.coverage_pack_hex_payload('.') # '.' -> 0x00
38 | self.assertEqual(bytearray(b'\x00'), r)
39 |
40 | r = mbed_coverage_api.coverage_pack_hex_payload('...') # '.' -> 0x00
41 | self.assertEqual(bytearray(b'\x00\x00\x00'), r)
42 |
43 | r = mbed_coverage_api.coverage_pack_hex_payload('.6164636772.') # '.' -> 0x00
44 | self.assertEqual(bytearray(b'\x00adcgr\x00'), r)
45 |
46 | def test_coverage_dump_file_valid(self):
47 | import tempfile
48 |
49 | payload = bytearray(b'PAYLOAD')
50 | handle, path = tempfile.mkstemp("test_file")
51 | mbed_coverage_api.coverage_dump_file(".", path, payload)
52 |
53 | with open(path, 'r') as f:
54 | read_data = f.read()
55 |
56 | self.assertEqual(read_data, payload.decode("utf-8", "ignore"))
57 | os.close(handle)
58 | os.remove(path)
59 |
60 | if __name__ == '__main__':
61 | unittest.main()
62 |
--------------------------------------------------------------------------------
/test/test/mocks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ARMmbed/mbed-os-tools/c467d6f1498018669872883a95a8c9c9120d6abd/test/test/mocks/__init__.py
--------------------------------------------------------------------------------
/test/test/mocks/environment/darwin.py:
--------------------------------------------------------------------------------
1 | from builtins import super
2 | from mock import MagicMock
3 |
4 | from .posix import MockTestEnvironmentPosix
5 |
6 | class MockTestEnvironmentDarwin(MockTestEnvironmentPosix):
7 |
8 | def __init__(self, test_case, platform_info, image_path):
9 | super().__init__(test_case, platform_info, image_path)
10 |
11 | self.patch(
12 | 'os.uname',
13 | new=MagicMock(return_value=('Darwin',)),
14 | create=True
15 | )
16 |
17 | def __exit__(self, type, value, traceback):
18 | super().__exit__(type, value, traceback)
19 |
20 | if value:
21 | return False
22 |
23 | # Assert for proper image copy
24 | mocked_call = self.patches[
25 | 'mbed_os_tools.test.host_tests_plugins.host_test_plugins.call'
26 | ]
27 |
28 | second_call_args = mocked_call.call_args_list[1][0][0]
29 | self._test_case.assertEqual(second_call_args, ["sync"])
30 |
31 | # Ensure only two subprocesses were started
32 | self._test_case.assertEqual(len(mocked_call.call_args_list), 2)
33 |
--------------------------------------------------------------------------------
/test/test/mocks/environment/linux.py:
--------------------------------------------------------------------------------
1 | import os
2 | from builtins import super
3 | from mock import MagicMock
4 |
5 | from .posix import MockTestEnvironmentPosix
6 |
7 | class MockTestEnvironmentLinux(MockTestEnvironmentPosix):
8 |
9 | def __init__(self, test_case, platform_info, image_path):
10 | super().__init__(test_case, platform_info, image_path)
11 |
12 | self.patch(
13 | 'os.uname',
14 | new=MagicMock(return_value=('Linux',)),
15 | create=True
16 | )
17 |
18 | def __exit__(self, type, value, traceback):
19 | super().__exit__(type, value, traceback)
20 |
21 | if value:
22 | return False
23 |
24 | # Assert for proper image copy
25 | mocked_call = self.patches[
26 | 'mbed_os_tools.test.host_tests_plugins.host_test_plugins.call'
27 | ]
28 |
29 | second_call_args = mocked_call.call_args_list[1][0][0]
30 | destination_path = os.path.normpath(
31 | os.path.join(
32 | self._platform_info["mount_point"],
33 | os.path.basename(self._image_path)
34 | )
35 | )
36 |
37 | self._test_case.assertEqual(
38 | second_call_args,
39 | ["sync", "-f", destination_path]
40 | )
41 |
42 | # Ensure only two subprocesses were started
43 | self._test_case.assertEqual(len(mocked_call.call_args_list), 2)
44 |
--------------------------------------------------------------------------------
/test/test/mocks/environment/posix.py:
--------------------------------------------------------------------------------
1 | import os
2 | from builtins import super
3 |
4 | from . import MockTestEnvironment
5 |
6 | class MockTestEnvironmentPosix(MockTestEnvironment):
7 |
8 | def __init__(self, test_case, platform_info, image_path):
9 | super().__init__(test_case, platform_info, image_path)
10 |
11 | self.patch('os.name', new='posix')
12 |
13 | def __exit__(self, type, value, traceback):
14 | super().__exit__(type, value, traceback)
15 |
16 | if value:
17 | return False
18 |
19 | # Assert for proper image copy
20 | mocked_call = self.patches[
21 | 'mbed_os_tools.test.host_tests_plugins.host_test_plugins.call'
22 | ]
23 |
24 | first_call_args = mocked_call.call_args_list[0][0][0]
25 | self._test_case.assertEqual(first_call_args[0], "cp")
26 | self._test_case.assertEqual(first_call_args[1], self._image_path)
27 | self._test_case.assertTrue(first_call_args[2].startswith(self._platform_info["mount_point"]))
28 | self._test_case.assertTrue(first_call_args[2].endswith(os.path.splitext(self._image_path)[1]))
29 |
--------------------------------------------------------------------------------
/test/test/mocks/environment/windows.py:
--------------------------------------------------------------------------------
1 | import os
2 | from builtins import super
3 |
4 | from . import MockTestEnvironment
5 |
6 | class MockTestEnvironmentWindows(MockTestEnvironment):
7 |
8 | def __init__(self, test_case, platform_info, image_path):
9 | super().__init__(test_case, platform_info, image_path)
10 |
11 | self.patch('os.name', new='nt')
12 |
13 | def __exit__(self, type, value, traceback):
14 | super().__exit__(type, value, traceback)
15 |
16 | if value:
17 | return False
18 |
19 | # Assert for proper image copy
20 | mocked_call = self.patches[
21 | 'mbed_os_tools.test.host_tests_plugins.host_test_plugins.call'
22 | ]
23 |
24 | first_call_args = mocked_call.call_args_list[0][0][0]
25 | self._test_case.assertEqual(first_call_args[0], "copy")
26 | self._test_case.assertEqual(first_call_args[1], self._image_path)
27 | self._test_case.assertTrue(first_call_args[2].startswith(self._platform_info["mount_point"]))
28 | self._test_case.assertTrue(first_call_args[2].endswith(os.path.splitext(self._image_path)[1]))
29 |
30 | # Ensure only one subprocess was started
31 | self._test_case.assertEqual(len(mocked_call.call_args_list), 1)
32 |
--------------------------------------------------------------------------------
/test/test/mocks/mbed_device.py:
--------------------------------------------------------------------------------
1 | import re
2 |
3 | class MockMbedDevice(object):
4 |
5 | KV_REGEX = re.compile("\{\{([\w\d_-]+);([^\}]+)\}\}")
6 |
7 | def __init__(self, serial):
8 | self._synced = False
9 | self._kvs = []
10 | self._serial = serial
11 | self._serial.on_upstream_write(self.on_write)
12 |
13 | def handle_kv(self, key, value):
14 | if not self._synced:
15 | if key == "__sync":
16 | self._synced = True
17 | self.send_kv(key, value)
18 | self.on_sync()
19 | else:
20 | pass
21 |
22 | def send_kv(self, key, value):
23 | self._serial.downstream_write("{{{{{};{}}}}}\r\n".format(key, value))
24 |
25 | def on_write(self, data):
26 | kvs = self.KV_REGEX.findall(data.decode("utf-8"))
27 |
28 | for key, value in kvs:
29 | self.handle_kv(key, value)
30 | self._kvs.append((key, value))
31 |
32 | def on_sync(self):
33 | self._serial.downstream_write(
34 | "{{__timeout;15}}\r\n"
35 | "{{__host_test_name;default_auto}}\r\n"
36 | "{{end;success}}\n"
37 | "{{__exit;0}}\r\n"
38 | )
39 |
--------------------------------------------------------------------------------
/test/test/mocks/process.py:
--------------------------------------------------------------------------------
1 | from builtins import super
2 | from threading import Thread
3 |
4 | class MockProcess(Thread):
5 | def __init__(self, target=None, args=None):
6 | super().__init__(target=target, args=args)
7 | self._terminates = 0
8 | self.exitcode = 0
9 |
10 | def terminate(self):
11 | self._terminates += 1
12 |
--------------------------------------------------------------------------------
/test/test/mocks/serial.py:
--------------------------------------------------------------------------------
1 | from builtins import super
2 |
3 | class MockSerial(object):
4 | def __init__(self, *args, **kwargs):
5 | super().__init__(*args, **kwargs)
6 | self._args = args
7 | self._kwargs = kwargs
8 | self._open = True
9 | self._rx_counter = 0
10 | self._tx_buffer = b""
11 | self._rx_buffer = b""
12 | self._upstream_write_cb = None
13 |
14 | def read(self, count):
15 | contents = self._rx_buffer[self._rx_counter:count]
16 | self._rx_counter += len(contents)
17 | return contents
18 |
19 | def write(self, data):
20 | self._tx_buffer += data
21 | if self._upstream_write_cb:
22 | self._upstream_write_cb(data)
23 |
24 | def close(self):
25 | self._open = False
26 |
27 | def downstream_write(self, data):
28 | self._rx_buffer += data.encode("utf-8")
29 |
30 | def downstream_write_bytes(self, data):
31 | self._rx_buffer += data
32 |
33 | def on_upstream_write(self, func):
34 | self._upstream_write_cb = func
35 |
--------------------------------------------------------------------------------
/test/test/mps2_copy.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 | import os
18 |
19 | from mbed_os_tools.test.host_tests_plugins.module_copy_mps2 import HostTestPluginCopyMethod_MPS2
20 |
21 | class MPS2CopyTestCase(unittest.TestCase):
22 |
23 | def setUp(self):
24 | self.mps2_copy_plugin = HostTestPluginCopyMethod_MPS2()
25 | self.filename = "toto.bin"
26 | # Create the empty file named self.filename
27 | open(self.filename, "w+").close()
28 |
29 | def tearDown(self):
30 | os.remove(self.filename)
31 |
32 | def test_copy_bin(self):
33 | # Check that file has been copied as "mbed.bin"
34 | self.mps2_copy_plugin.mps2_copy(self.filename, ".")
35 | self.assertTrue(os.path.isfile("mbed.bin"))
36 | os.remove("mbed.bin")
37 |
38 | def test_copy_elf(self):
39 | # Check that file has been copied as "mbed.elf"
40 | os.rename(self.filename, "toto.elf")
41 | self.filename = "toto.elf"
42 | self.mps2_copy_plugin.mps2_copy(self.filename, ".")
43 | self.assertTrue(os.path.isfile("mbed.elf"))
44 | os.remove("mbed.elf")
45 |
46 | if __name__ == '__main__':
47 | unittest.main()
48 |
--------------------------------------------------------------------------------
/test/test/mps2_reset.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 | import mock
18 | import os
19 | import time
20 |
21 | from mbed_os_tools.test.host_tests_plugins.module_reset_mps2 import HostTestPluginResetMethod_MPS2
22 |
23 | class MPS2ResetTestCase(unittest.TestCase):
24 |
25 | def setUp(self):
26 | self.mps2_reset_plugin = HostTestPluginResetMethod_MPS2()
27 |
28 | def tearDown(self):
29 | pass
30 |
31 | @mock.patch("os.name", "posix")
32 | @mock.patch("time.sleep")
33 | @mock.patch("mbed_os_tools.test.host_tests_plugins.module_reset_mps2.HostTestPluginResetMethod_MPS2.run_command")
34 | def test_check_sync(self, run_command_function, sleep_function):
35 | # Check that a sync call has correctly been executed
36 | self.mps2_reset_plugin.execute("reboot.txt", disk=".")
37 | args, _ = run_command_function.call_args
38 | self.assertTrue("sync" in args[0])
39 | os.remove("reboot.txt")
40 |
41 | if __name__ == '__main__':
42 | unittest.main()
43 |
--------------------------------------------------------------------------------
/test/test/report_api.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, Arm Limited and affiliates.
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | import unittest
17 | from mock import patch
18 |
19 | from mbed_os_tools.test.mbed_report_api import exporter_html, \
20 | exporter_memory_metrics_csv, exporter_testcase_junit, \
21 | exporter_testcase_text, exporter_text, exporter_json
22 |
23 |
24 | class ReportEmitting(unittest.TestCase):
25 |
26 |
27 | report_fns = [exporter_html, exporter_memory_metrics_csv,
28 | exporter_testcase_junit, exporter_testcase_text,
29 | exporter_text, exporter_json]
30 | def test_report_zero_tests(self):
31 | test_data = {}
32 | for report_fn in self.report_fns:
33 | report_fn(test_data)
34 |
35 | def test_report_zero_testcases(self):
36 | test_data = {
37 | 'k64f-gcc_arm': {
38 | 'garbage_test_suite' :{
39 | u'single_test_result': u'NOT_RAN',
40 | u'elapsed_time': 0.0,
41 | u'build_path': u'N/A',
42 | u'build_path_abs': u'N/A',
43 | u'copy_method': u'N/A',
44 | u'image_path': u'N/A',
45 | u'single_test_output': u'\x80abc',
46 | u'platform_name': u'k64f',
47 | u'test_bin_name': u'N/A',
48 | u'testcase_result': {},
49 | }
50 | }
51 | }
52 | for report_fn in self.report_fns:
53 | report_fn(test_data)
54 |
--------------------------------------------------------------------------------
/test/test/resources/empty/test/CTestTestfile.cmake:
--------------------------------------------------------------------------------
1 | # CMake generated Testfile for
2 | # Source directory: c:/Work2/mbed-client/test
3 | # Build directory: c:/Work2/mbed-client/build/frdm-k64f-gcc/test
4 | #
5 | # This file includes the relevant testing commands required for
6 | # testing this directory and lists subdirectories to be tested as well.
7 |
--------------------------------------------------------------------------------
/test/test/resources/not-empty/test/CTestTestfile.cmake:
--------------------------------------------------------------------------------
1 | # CMake generated Testfile for
2 | # Source directory: c:/Work2/mbed-client/test
3 | # Build directory: c:/Work2/mbed-client/build/frdm-k64f-gcc/test
4 | #
5 | # This file includes the relevant testing commands required for
6 | # testing this directory and lists subdirectories to be tested as well.
7 | add_test(mbed-client-test-mbedclient-smokeTest "mbed-client-test-mbedclient-smokeTest")
8 | add_test(mbed-client-test-helloworld-mbedclient "mbed-client-test-helloworld-mbedclient")
9 | add_test()
10 |
--------------------------------------------------------------------------------
/test/test/resources/test_spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "builds": {
3 | "K64F-ARM": {
4 | "platform": "K64F",
5 | "toolchain": "ARM",
6 | "base_path": "./BUILD/K64F/ARM",
7 | "baud_rate": 9600,
8 | "tests": {
9 | "tests-example-1": {
10 | "binaries": [
11 | {
12 | "binary_type": "bootable",
13 | "path": "./BUILD/K64F/ARM/tests-mbedmicro-rtos-mbed-mail.bin"
14 | }
15 | ]
16 | },
17 | "tests-example-2": {
18 | "binaries": [
19 | {
20 | "binary_type": "bootable",
21 | "path": "./BUILD/K64F/ARM/tests-mbed_drivers-c_strings.bin"
22 | }
23 | ]
24 | }
25 | }
26 | },
27 | "K64F-GCC": {
28 | "platform": "K64F",
29 | "toolchain": "GCC_ARM",
30 | "base_path": "./BUILD/K64F/GCC_ARM",
31 | "baud_rate": 9600,
32 | "tests": {
33 | "tests-example-7": {
34 | "binaries": [
35 | {
36 | "binary_type": "bootable",
37 | "path": "./BUILD/K64F/GCC_ARM/tests-mbedmicro-rtos-mbed-mail.bin"
38 | }
39 | ]
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/test_requirements.txt:
--------------------------------------------------------------------------------
1 | coverage>=4,<5
2 | coveralls>=1,<2
3 | mock>=2,<4
4 | pytest>=3,<5
5 | wheel>=0.34
6 | setuptools-scm>=4.1
7 |
--------------------------------------------------------------------------------