Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
perform_test_mbedOS.py
00001 # ----------------------------------------------------------------------- 00002 # Copyright (c) 2016 ARM Limited. All rights reserved. 00003 # SPDX-License-Identifier: Apache-2.0 00004 # Licensed under the Apache License, Version 2.0 (the License); you may 00005 # not use this file except in compliance with the License. 00006 # You may obtain a copy of the License at 00007 # 00008 # http://www.apache.org/licenses/LICENSE-2.0 00009 # 00010 # Unless required by applicable law or agreed to in writing, software 00011 # distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 # See the License for the specific language governing permissions and 00014 # limitations under the License. 00015 # ----------------------------------------------------------------------- 00016 00017 ##################################################################### 00018 # Install and run PAL tests for mbed targets. 00019 # 00020 # Arguments: One or more binary files containing tests to execute. 00021 # 00022 # Output: <binary file>_result.txt - Textual result summary 00023 # <binary file>.xml - Junit result summary 00024 # ARM 00025 # Clive Bluston 00026 ##################################################################### 00027 from mbed import MBED 00028 import os 00029 import sys 00030 import unity_to_junit 00031 from time import sleep 00032 00033 # Check that at least one test is specified on the command line 00034 if len(sys.argv) < 2: 00035 sys.exit() 00036 else: 00037 tests = sys.argv[1:] 00038 00039 # List of textual result files. 00040 resultFiles = [] 00041 00042 # Supported mbed devices. Can add to this list 00043 deviceList = ["K64F"] 00044 00045 # Loop over attached mbed devices. 00046 for device in deviceList: 00047 mbed = MBED(device) 00048 deviceDetected = mbed.detect() 00049 if deviceDetected: 00050 # Loop over tests 00051 for test in tests: 00052 mbed.install_bin(test) 00053 noSuffix = os.path.splitext(test)[0] 00054 intermediateResultsFile = noSuffix+".int" 00055 # Remove intermediate file just in case it was left over from a failed run. 00056 if os.path.isfile(intermediateResultsFile): 00057 os.remove(intermediateResultsFile) 00058 resultFile = noSuffix+"_result.txt" 00059 # This delay is to allow output that was generated before the reset to be discarded. 00060 sleep(30) 00061 # Capture test results from the serial port 00062 if mbed.run_and_capture_till_timeout(intermediateResultsFile,baud=9600,read_timeout=10,endOfData="***END OF TESTS**"): 00063 # Success. Convert results to Junit format and write to xml file. 00064 unity_to_junit.unity_to_junit("mbedos_" + os.path.basename(noSuffix), intermediateResultsFile, noSuffix+".xml", resultFile) 00065 # Output intermediate results to the console. 00066 with open(intermediateResultsFile, 'r') as fin: 00067 print fin.read() 00068 os.remove(intermediateResultsFile) 00069 # Add result file name to list 00070 resultFiles.append(resultFile) 00071 else: 00072 response = raw_input("Connect Serial port. Enter when ready") 00073 # Clean up. True parameter closes the device opened by mbed.detect() 00074 mbed.end_run(False,True) 00075 00076 00077 # Copy result files to standard output 00078 for file in resultFiles: 00079 with open(file, 'r') as fin: 00080 print fin.read() 00081 00082 00083
Generated on Tue Jul 12 2022 21:20:29 by
1.7.2