Nathan Yonkee
/
Nucleo_sinewave_output_copy
init
mbed-os/tools/check_release.py@10:46a4cf51ee38, 2018-03-02 (annotated)
- Committer:
- Nathan Yonkee
- Date:
- Fri Mar 02 07:16:49 2018 -0700
- Revision:
- 10:46a4cf51ee38
- Parent:
- 9:d58e77ebd769
remove mbed-os
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nathan Yonkee |
9:d58e77ebd769 | 1 | # Script to check a new mbed 2 release by compiling a set of specified test apps |
Nathan Yonkee |
9:d58e77ebd769 | 2 | # for all currently supported platforms. Each test app must include an mbed library. |
Nathan Yonkee |
9:d58e77ebd769 | 3 | # This can either be the pre-compiled version 'mbed' or the source version 'mbed-dev'. |
Nathan Yonkee |
9:d58e77ebd769 | 4 | # |
Nathan Yonkee |
9:d58e77ebd769 | 5 | # Setup: |
Nathan Yonkee |
9:d58e77ebd769 | 6 | # 1. Set up your global .hgrc file |
Nathan Yonkee |
9:d58e77ebd769 | 7 | # |
Nathan Yonkee |
9:d58e77ebd769 | 8 | # If you don't already have a .hgrc file in your $HOME directory, create one there. |
Nathan Yonkee |
9:d58e77ebd769 | 9 | # Then add the following section: |
Nathan Yonkee |
9:d58e77ebd769 | 10 | # |
Nathan Yonkee |
9:d58e77ebd769 | 11 | # [auth] |
Nathan Yonkee |
9:d58e77ebd769 | 12 | # x.prefix = * |
Nathan Yonkee |
9:d58e77ebd769 | 13 | # x.username = <put your mbed org username here> |
Nathan Yonkee |
9:d58e77ebd769 | 14 | # x.password = <put your mbed org password here> |
Nathan Yonkee |
9:d58e77ebd769 | 15 | # |
Nathan Yonkee |
9:d58e77ebd769 | 16 | # This has 2 purposes, the first means you don't get prompted for your password |
Nathan Yonkee |
9:d58e77ebd769 | 17 | # whenever you run hg commands on the commandline. The second is that this script |
Nathan Yonkee |
9:d58e77ebd769 | 18 | # reads these details in order to fully automate the Mercurial commands. |
Nathan Yonkee |
9:d58e77ebd769 | 19 | # |
Nathan Yonkee |
9:d58e77ebd769 | 20 | # Edit "check_release.json". This has the following structure: |
Nathan Yonkee |
9:d58e77ebd769 | 21 | #{ |
Nathan Yonkee |
9:d58e77ebd769 | 22 | # "config" : { |
Nathan Yonkee |
9:d58e77ebd769 | 23 | # "mbed_repo_path" : "C:/Users/annbri01/Work/Mercurial" |
Nathan Yonkee |
9:d58e77ebd769 | 24 | # }, |
Nathan Yonkee |
9:d58e77ebd769 | 25 | # "test_list" : [ |
Nathan Yonkee |
9:d58e77ebd769 | 26 | # { |
Nathan Yonkee |
9:d58e77ebd769 | 27 | # "name" : "test_compile_mbed_lib", |
Nathan Yonkee |
9:d58e77ebd769 | 28 | # "lib" : "mbed" |
Nathan Yonkee |
9:d58e77ebd769 | 29 | # }, |
Nathan Yonkee |
9:d58e77ebd769 | 30 | # { |
Nathan Yonkee |
9:d58e77ebd769 | 31 | # "name" : "test_compile_mbed_dev", |
Nathan Yonkee |
9:d58e77ebd769 | 32 | # "lib" : "mbed-dev" |
Nathan Yonkee |
9:d58e77ebd769 | 33 | # } |
Nathan Yonkee |
9:d58e77ebd769 | 34 | # ], |
Nathan Yonkee |
9:d58e77ebd769 | 35 | # "target_list" : [] |
Nathan Yonkee |
9:d58e77ebd769 | 36 | #} |
Nathan Yonkee |
9:d58e77ebd769 | 37 | # |
Nathan Yonkee |
9:d58e77ebd769 | 38 | # The mbed_repo_path field should be changed to point to where your local |
Nathan Yonkee |
9:d58e77ebd769 | 39 | # working directory is for Mercurial repositories. |
Nathan Yonkee |
9:d58e77ebd769 | 40 | # For each test app you wish to run, add an entry to the test list. The example |
Nathan Yonkee |
9:d58e77ebd769 | 41 | # above has 2 test apps |
Nathan Yonkee |
9:d58e77ebd769 | 42 | # "test_compile_mbed_lib" and "test_compile_mbed_dev" |
Nathan Yonkee |
9:d58e77ebd769 | 43 | # The lib field in each says which type of mbed 2 library the app contains. |
Nathan Yonkee |
9:d58e77ebd769 | 44 | # These test apps MUST be available as repos in the user's online Mercurial area. |
Nathan Yonkee |
9:d58e77ebd769 | 45 | # The target_list allows the user to override the set of targets/platforms used |
Nathan Yonkee |
9:d58e77ebd769 | 46 | # for the compilation. |
Nathan Yonkee |
9:d58e77ebd769 | 47 | # E.g to just compile for 2 targets, K64F and K22F : |
Nathan Yonkee |
9:d58e77ebd769 | 48 | # "target_list" : ["K64F", "K22F"] |
Nathan Yonkee |
9:d58e77ebd769 | 49 | # |
Nathan Yonkee |
9:d58e77ebd769 | 50 | # Run the script from the mbed-os directory as follows: |
Nathan Yonkee |
9:d58e77ebd769 | 51 | # > python tools/check_release.py |
Nathan Yonkee |
9:d58e77ebd769 | 52 | # |
Nathan Yonkee |
9:d58e77ebd769 | 53 | # It will look for local clones of the test app repos. If they don't exist |
Nathan Yonkee |
9:d58e77ebd769 | 54 | # it will clone them. It will then read the latest versions of mbed and mbed-dev |
Nathan Yonkee |
9:d58e77ebd769 | 55 | # (an assumption is made that both of these are already cloned in your Mercurial area). |
Nathan Yonkee |
9:d58e77ebd769 | 56 | # The lib files within the test apps are then updated to the corresponding version in |
Nathan Yonkee |
9:d58e77ebd769 | 57 | # the associated lib itself. The test apps are then committed and pushed back to the users |
Nathan Yonkee |
9:d58e77ebd769 | 58 | # fork. |
Nathan Yonkee |
9:d58e77ebd769 | 59 | # The test apps will then be compiled for all supported targets and a % result output at |
Nathan Yonkee |
9:d58e77ebd769 | 60 | # the end. |
Nathan Yonkee |
9:d58e77ebd769 | 61 | # |
Nathan Yonkee |
9:d58e77ebd769 | 62 | # Uses the online compiler API at https://mbed.org/handbook/Compile-API |
Nathan Yonkee |
9:d58e77ebd769 | 63 | # Based on the example from https://mbed.org/teams/mbed/code/mbed-API-helper/ |
Nathan Yonkee |
9:d58e77ebd769 | 64 | |
Nathan Yonkee |
9:d58e77ebd769 | 65 | |
Nathan Yonkee |
9:d58e77ebd769 | 66 | import os, getpass, sys, json, time, requests, logging |
Nathan Yonkee |
9:d58e77ebd769 | 67 | from os.path import dirname, abspath, basename, join |
Nathan Yonkee |
9:d58e77ebd769 | 68 | import argparse |
Nathan Yonkee |
9:d58e77ebd769 | 69 | import subprocess |
Nathan Yonkee |
9:d58e77ebd769 | 70 | import re |
Nathan Yonkee |
9:d58e77ebd769 | 71 | import hglib |
Nathan Yonkee |
9:d58e77ebd769 | 72 | import argparse |
Nathan Yonkee |
9:d58e77ebd769 | 73 | |
Nathan Yonkee |
9:d58e77ebd769 | 74 | # Be sure that the tools directory is in the search path |
Nathan Yonkee |
9:d58e77ebd769 | 75 | ROOT = abspath(join(dirname(__file__), "..")) |
Nathan Yonkee |
9:d58e77ebd769 | 76 | sys.path.insert(0, ROOT) |
Nathan Yonkee |
9:d58e77ebd769 | 77 | |
Nathan Yonkee |
9:d58e77ebd769 | 78 | from tools.build_api import get_mbed_official_release |
Nathan Yonkee |
9:d58e77ebd769 | 79 | |
Nathan Yonkee |
9:d58e77ebd769 | 80 | OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2') |
Nathan Yonkee |
9:d58e77ebd769 | 81 | |
Nathan Yonkee |
9:d58e77ebd769 | 82 | def get_compilation_failure(messages): |
Nathan Yonkee |
9:d58e77ebd769 | 83 | """ Reads the json formatted 'messages' and checks for compilation errors. |
Nathan Yonkee |
9:d58e77ebd769 | 84 | If there is a genuine compilation error then there should be a new |
Nathan Yonkee |
9:d58e77ebd769 | 85 | message containing a severity field = Error and an accompanying message |
Nathan Yonkee |
9:d58e77ebd769 | 86 | with the compile error text. Any other combination is considered an |
Nathan Yonkee |
9:d58e77ebd769 | 87 | internal compile engine failure |
Nathan Yonkee |
9:d58e77ebd769 | 88 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 89 | messages - json formatted text returned by the online compiler API. |
Nathan Yonkee |
9:d58e77ebd769 | 90 | |
Nathan Yonkee |
9:d58e77ebd769 | 91 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 92 | Either "Error" or "Internal" to indicate an actual compilation error or an |
Nathan Yonkee |
9:d58e77ebd769 | 93 | internal IDE API fault. |
Nathan Yonkee |
9:d58e77ebd769 | 94 | |
Nathan Yonkee |
9:d58e77ebd769 | 95 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 96 | for m in messages: |
Nathan Yonkee |
9:d58e77ebd769 | 97 | # Get message text if it exists |
Nathan Yonkee |
9:d58e77ebd769 | 98 | try: |
Nathan Yonkee |
9:d58e77ebd769 | 99 | message = m['message'] |
Nathan Yonkee |
9:d58e77ebd769 | 100 | message = message + "\n" |
Nathan Yonkee |
9:d58e77ebd769 | 101 | except KeyError: |
Nathan Yonkee |
9:d58e77ebd769 | 102 | # Skip this message as it has no 'message' field |
Nathan Yonkee |
9:d58e77ebd769 | 103 | continue |
Nathan Yonkee |
9:d58e77ebd769 | 104 | |
Nathan Yonkee |
9:d58e77ebd769 | 105 | # Get type of message text |
Nathan Yonkee |
9:d58e77ebd769 | 106 | try: |
Nathan Yonkee |
9:d58e77ebd769 | 107 | msg_type = m['type'] |
Nathan Yonkee |
9:d58e77ebd769 | 108 | except KeyError: |
Nathan Yonkee |
9:d58e77ebd769 | 109 | # Skip this message as it has no 'type' field |
Nathan Yonkee |
9:d58e77ebd769 | 110 | continue |
Nathan Yonkee |
9:d58e77ebd769 | 111 | |
Nathan Yonkee |
9:d58e77ebd769 | 112 | if msg_type == 'error' or msg_type == 'tool_error': |
Nathan Yonkee |
9:d58e77ebd769 | 113 | rel_log.error(message) |
Nathan Yonkee |
9:d58e77ebd769 | 114 | return "Error" |
Nathan Yonkee |
9:d58e77ebd769 | 115 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 116 | rel_log.debug(message) |
Nathan Yonkee |
9:d58e77ebd769 | 117 | |
Nathan Yonkee |
9:d58e77ebd769 | 118 | return "Internal" |
Nathan Yonkee |
9:d58e77ebd769 | 119 | |
Nathan Yonkee |
9:d58e77ebd769 | 120 | def invoke_api(payload, url, auth, polls, begin="start/"): |
Nathan Yonkee |
9:d58e77ebd769 | 121 | """ Sends an API command request to the online IDE. Waits for a task completed |
Nathan Yonkee |
9:d58e77ebd769 | 122 | response before returning the results. |
Nathan Yonkee |
9:d58e77ebd769 | 123 | |
Nathan Yonkee |
9:d58e77ebd769 | 124 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 125 | payload - Configuration parameters to be passed to the API |
Nathan Yonkee |
9:d58e77ebd769 | 126 | url - THe URL for the online compiler API |
Nathan Yonkee |
9:d58e77ebd769 | 127 | auth - Tuple containing authentication credentials |
Nathan Yonkee |
9:d58e77ebd769 | 128 | polls - Number of times to poll for results |
Nathan Yonkee |
9:d58e77ebd769 | 129 | begin - Default value = "start/", start command to be appended to URL |
Nathan Yonkee |
9:d58e77ebd769 | 130 | |
Nathan Yonkee |
9:d58e77ebd769 | 131 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 132 | result - True/False indicating the success/failure of the compilation |
Nathan Yonkee |
9:d58e77ebd769 | 133 | fail_type - the failure text if the compilation failed, else None |
Nathan Yonkee |
9:d58e77ebd769 | 134 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 135 | |
Nathan Yonkee |
9:d58e77ebd769 | 136 | # send task to api |
Nathan Yonkee |
9:d58e77ebd769 | 137 | rel_log.debug(url + begin + "| data: " + str(payload)) |
Nathan Yonkee |
9:d58e77ebd769 | 138 | r = requests.post(url + begin, data=payload, auth=auth) |
Nathan Yonkee |
9:d58e77ebd769 | 139 | rel_log.debug(r.request.body) |
Nathan Yonkee |
9:d58e77ebd769 | 140 | |
Nathan Yonkee |
9:d58e77ebd769 | 141 | if r.status_code != 200: |
Nathan Yonkee |
9:d58e77ebd769 | 142 | rel_log.error("HTTP code %d reported.", r.status_code) |
Nathan Yonkee |
9:d58e77ebd769 | 143 | return False, "Internal" |
Nathan Yonkee |
9:d58e77ebd769 | 144 | |
Nathan Yonkee |
9:d58e77ebd769 | 145 | response = r.json() |
Nathan Yonkee |
9:d58e77ebd769 | 146 | rel_log.debug(response) |
Nathan Yonkee |
9:d58e77ebd769 | 147 | uuid = response['result']['data']['task_id'] |
Nathan Yonkee |
9:d58e77ebd769 | 148 | rel_log.debug("Task accepted and given ID: %s", uuid) |
Nathan Yonkee |
9:d58e77ebd769 | 149 | result = False |
Nathan Yonkee |
9:d58e77ebd769 | 150 | fail_type = None |
Nathan Yonkee |
9:d58e77ebd769 | 151 | |
Nathan Yonkee |
9:d58e77ebd769 | 152 | # It currently seems to take the onlide IDE API ~30s to process the compile |
Nathan Yonkee |
9:d58e77ebd769 | 153 | # request and provide a response. Set the poll time to half that in case it |
Nathan Yonkee |
9:d58e77ebd769 | 154 | # does manage to compile quicker. |
Nathan Yonkee |
9:d58e77ebd769 | 155 | poll_delay = 15 |
Nathan Yonkee |
9:d58e77ebd769 | 156 | rel_log.debug("Running with a poll for response delay of: %ss", poll_delay) |
Nathan Yonkee |
9:d58e77ebd769 | 157 | |
Nathan Yonkee |
9:d58e77ebd769 | 158 | # poll for output |
Nathan Yonkee |
9:d58e77ebd769 | 159 | for check in range(polls): |
Nathan Yonkee |
9:d58e77ebd769 | 160 | time.sleep(poll_delay) |
Nathan Yonkee |
9:d58e77ebd769 | 161 | |
Nathan Yonkee |
9:d58e77ebd769 | 162 | try: |
Nathan Yonkee |
9:d58e77ebd769 | 163 | r = requests.get(url + "output/%s" % uuid, auth=auth) |
Nathan Yonkee |
9:d58e77ebd769 | 164 | |
Nathan Yonkee |
9:d58e77ebd769 | 165 | except ConnectionError: |
Nathan Yonkee |
9:d58e77ebd769 | 166 | return "Internal" |
Nathan Yonkee |
9:d58e77ebd769 | 167 | |
Nathan Yonkee |
9:d58e77ebd769 | 168 | response = r.json() |
Nathan Yonkee |
9:d58e77ebd769 | 169 | |
Nathan Yonkee |
9:d58e77ebd769 | 170 | data = response['result']['data'] |
Nathan Yonkee |
9:d58e77ebd769 | 171 | if data['task_complete']: |
Nathan Yonkee |
9:d58e77ebd769 | 172 | # Task completed. Now determine the result. Should be one of : |
Nathan Yonkee |
9:d58e77ebd769 | 173 | # 1) Successful compilation |
Nathan Yonkee |
9:d58e77ebd769 | 174 | # 2) Failed compilation with an error message |
Nathan Yonkee |
9:d58e77ebd769 | 175 | # 3) Internal failure of the online compiler |
Nathan Yonkee |
9:d58e77ebd769 | 176 | result = bool(data['compilation_success']) |
Nathan Yonkee |
9:d58e77ebd769 | 177 | if result: |
Nathan Yonkee |
9:d58e77ebd769 | 178 | rel_log.info("COMPILATION SUCCESSFUL\n") |
Nathan Yonkee |
9:d58e77ebd769 | 179 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 180 | # Did this fail due to a genuine compilation error or a failue of |
Nathan Yonkee |
9:d58e77ebd769 | 181 | # the api itself ? |
Nathan Yonkee |
9:d58e77ebd769 | 182 | rel_log.info("COMPILATION FAILURE\n") |
Nathan Yonkee |
9:d58e77ebd769 | 183 | fail_type = get_compilation_failure(data['new_messages']) |
Nathan Yonkee |
9:d58e77ebd769 | 184 | break |
Nathan Yonkee |
9:d58e77ebd769 | 185 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 186 | rel_log.info("COMPILATION FAILURE\n") |
Nathan Yonkee |
9:d58e77ebd769 | 187 | |
Nathan Yonkee |
9:d58e77ebd769 | 188 | if not result and fail_type == None: |
Nathan Yonkee |
9:d58e77ebd769 | 189 | fail_type = "Internal" |
Nathan Yonkee |
9:d58e77ebd769 | 190 | |
Nathan Yonkee |
9:d58e77ebd769 | 191 | return result, fail_type |
Nathan Yonkee |
9:d58e77ebd769 | 192 | |
Nathan Yonkee |
9:d58e77ebd769 | 193 | |
Nathan Yonkee |
9:d58e77ebd769 | 194 | def build_repo(target, program, user, pw, polls=25, |
Nathan Yonkee |
9:d58e77ebd769 | 195 | url="https://developer.mbed.org/api/v2/tasks/compiler/"): |
Nathan Yonkee |
9:d58e77ebd769 | 196 | """ Wrapper for sending an API command request to the online IDE. Sends a |
Nathan Yonkee |
9:d58e77ebd769 | 197 | build request. |
Nathan Yonkee |
9:d58e77ebd769 | 198 | |
Nathan Yonkee |
9:d58e77ebd769 | 199 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 200 | target - Target to be built |
Nathan Yonkee |
9:d58e77ebd769 | 201 | program - Test program to build |
Nathan Yonkee |
9:d58e77ebd769 | 202 | user - mbed username |
Nathan Yonkee |
9:d58e77ebd769 | 203 | pw - mbed password |
Nathan Yonkee |
9:d58e77ebd769 | 204 | polls - Number of times to poll for results |
Nathan Yonkee |
9:d58e77ebd769 | 205 | url - THe URL for the online compiler API |
Nathan Yonkee |
9:d58e77ebd769 | 206 | |
Nathan Yonkee |
9:d58e77ebd769 | 207 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 208 | result - True/False indicating the success/failure of the compilation |
Nathan Yonkee |
9:d58e77ebd769 | 209 | fail_type - the failure text if the compilation failed, else None |
Nathan Yonkee |
9:d58e77ebd769 | 210 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 211 | payload = {'clean':True, 'target':target, 'program':program} |
Nathan Yonkee |
9:d58e77ebd769 | 212 | auth = (user, pw) |
Nathan Yonkee |
9:d58e77ebd769 | 213 | return invoke_api(payload, url, auth, polls) |
Nathan Yonkee |
9:d58e77ebd769 | 214 | |
Nathan Yonkee |
9:d58e77ebd769 | 215 | def run_cmd(command, exit_on_failure=False): |
Nathan Yonkee |
9:d58e77ebd769 | 216 | """ Passes a command to the system and returns a True/False result once the |
Nathan Yonkee |
9:d58e77ebd769 | 217 | command has been executed, indicating success/failure. Commands are passed |
Nathan Yonkee |
9:d58e77ebd769 | 218 | as a list of tokens. |
Nathan Yonkee |
9:d58e77ebd769 | 219 | E.g. The command 'git remote -v' would be passed in as ['git', 'remote', '-v'] |
Nathan Yonkee |
9:d58e77ebd769 | 220 | |
Nathan Yonkee |
9:d58e77ebd769 | 221 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 222 | command - system command as a list of tokens |
Nathan Yonkee |
9:d58e77ebd769 | 223 | exit_on_failure - If True exit the program on failure (default = False) |
Nathan Yonkee |
9:d58e77ebd769 | 224 | |
Nathan Yonkee |
9:d58e77ebd769 | 225 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 226 | result - True/False indicating the success/failure of the command |
Nathan Yonkee |
9:d58e77ebd769 | 227 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 228 | rel_log.debug('[Exec] %s', ' '.join(command)) |
Nathan Yonkee |
9:d58e77ebd769 | 229 | return_code = subprocess.call(command, shell=True) |
Nathan Yonkee |
9:d58e77ebd769 | 230 | |
Nathan Yonkee |
9:d58e77ebd769 | 231 | if return_code: |
Nathan Yonkee |
9:d58e77ebd769 | 232 | rel_log.warning("The command '%s' failed with return code: %s", |
Nathan Yonkee |
9:d58e77ebd769 | 233 | (' '.join(command), return_code)) |
Nathan Yonkee |
9:d58e77ebd769 | 234 | if exit_on_failure: |
Nathan Yonkee |
9:d58e77ebd769 | 235 | sys.exit(1) |
Nathan Yonkee |
9:d58e77ebd769 | 236 | |
Nathan Yonkee |
9:d58e77ebd769 | 237 | return return_code |
Nathan Yonkee |
9:d58e77ebd769 | 238 | |
Nathan Yonkee |
9:d58e77ebd769 | 239 | def run_cmd_with_output(command, exit_on_failure=False): |
Nathan Yonkee |
9:d58e77ebd769 | 240 | """ Passes a command to the system and returns a True/False result once the |
Nathan Yonkee |
9:d58e77ebd769 | 241 | command has been executed, indicating success/failure. If the command was |
Nathan Yonkee |
9:d58e77ebd769 | 242 | successful then the output from the command is returned to the caller. |
Nathan Yonkee |
9:d58e77ebd769 | 243 | Commands are passed as a list of tokens. |
Nathan Yonkee |
9:d58e77ebd769 | 244 | E.g. The command 'git remote -v' would be passed in as ['git', 'remote', '-v'] |
Nathan Yonkee |
9:d58e77ebd769 | 245 | |
Nathan Yonkee |
9:d58e77ebd769 | 246 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 247 | command - system command as a list of tokens |
Nathan Yonkee |
9:d58e77ebd769 | 248 | exit_on_failure - If True exit the program on failure (default = False) |
Nathan Yonkee |
9:d58e77ebd769 | 249 | |
Nathan Yonkee |
9:d58e77ebd769 | 250 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 251 | result - True/False indicating the success/failure of the command |
Nathan Yonkee |
9:d58e77ebd769 | 252 | output - The output of the command if it was successful, else empty string |
Nathan Yonkee |
9:d58e77ebd769 | 253 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 254 | rel_log.debug('[Exec] %s', ' '.join(command)) |
Nathan Yonkee |
9:d58e77ebd769 | 255 | returncode = 0 |
Nathan Yonkee |
9:d58e77ebd769 | 256 | output = "" |
Nathan Yonkee |
9:d58e77ebd769 | 257 | try: |
Nathan Yonkee |
9:d58e77ebd769 | 258 | output = subprocess.check_output(command, shell=True) |
Nathan Yonkee |
9:d58e77ebd769 | 259 | except subprocess.CalledProcessError as e: |
Nathan Yonkee |
9:d58e77ebd769 | 260 | rel_log.warning("The command '%s' failed with return code: %s", |
Nathan Yonkee |
9:d58e77ebd769 | 261 | (' '.join(command), e.returncode)) |
Nathan Yonkee |
9:d58e77ebd769 | 262 | returncode = e.returncode |
Nathan Yonkee |
9:d58e77ebd769 | 263 | if exit_on_failure: |
Nathan Yonkee |
9:d58e77ebd769 | 264 | sys.exit(1) |
Nathan Yonkee |
9:d58e77ebd769 | 265 | return returncode, output |
Nathan Yonkee |
9:d58e77ebd769 | 266 | |
Nathan Yonkee |
9:d58e77ebd769 | 267 | def upgrade_test_repo(test, user, library, ref, repo_path): |
Nathan Yonkee |
9:d58e77ebd769 | 268 | """ Upgrades a local version of a test repo to the latest version of its |
Nathan Yonkee |
9:d58e77ebd769 | 269 | embedded library. |
Nathan Yonkee |
9:d58e77ebd769 | 270 | If the test repo is not present in the user area specified in the json |
Nathan Yonkee |
9:d58e77ebd769 | 271 | config file, then it will first be cloned. |
Nathan Yonkee |
9:d58e77ebd769 | 272 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 273 | test - Mercurial test repo name |
Nathan Yonkee |
9:d58e77ebd769 | 274 | user - Mercurial user name |
Nathan Yonkee |
9:d58e77ebd769 | 275 | library - library name |
Nathan Yonkee |
9:d58e77ebd769 | 276 | ref - SHA corresponding to the latest version of the library |
Nathan Yonkee |
9:d58e77ebd769 | 277 | repo_path - path to the user's repo area |
Nathan Yonkee |
9:d58e77ebd769 | 278 | |
Nathan Yonkee |
9:d58e77ebd769 | 279 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 280 | updated - True if library was updated, False otherwise |
Nathan Yonkee |
9:d58e77ebd769 | 281 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 282 | rel_log.info("Updating test repo: '%s' to SHA: %s", test, ref) |
Nathan Yonkee |
9:d58e77ebd769 | 283 | cwd = os.getcwd() |
Nathan Yonkee |
9:d58e77ebd769 | 284 | |
Nathan Yonkee |
9:d58e77ebd769 | 285 | repo = "https://" + user + '@developer.mbed.org/users/' + user + '/code/' + test |
Nathan Yonkee |
9:d58e77ebd769 | 286 | |
Nathan Yonkee |
9:d58e77ebd769 | 287 | # Clone the repo if it doesn't already exist |
Nathan Yonkee |
9:d58e77ebd769 | 288 | path = abspath(repo_path + '/' + test) |
Nathan Yonkee |
9:d58e77ebd769 | 289 | if not os.path.exists(path): |
Nathan Yonkee |
9:d58e77ebd769 | 290 | rel_log.info("Test repo doesn't exist, cloning...") |
Nathan Yonkee |
9:d58e77ebd769 | 291 | os.chdir(abspath(repo_path)) |
Nathan Yonkee |
9:d58e77ebd769 | 292 | clone_cmd = ['hg', 'clone', repo] |
Nathan Yonkee |
9:d58e77ebd769 | 293 | run_cmd(clone_cmd, exit_on_failure=True) |
Nathan Yonkee |
9:d58e77ebd769 | 294 | |
Nathan Yonkee |
9:d58e77ebd769 | 295 | os.chdir(path) |
Nathan Yonkee |
9:d58e77ebd769 | 296 | |
Nathan Yonkee |
9:d58e77ebd769 | 297 | client = hglib.open(path) |
Nathan Yonkee |
9:d58e77ebd769 | 298 | |
Nathan Yonkee |
9:d58e77ebd769 | 299 | lib_file = library + '.lib' |
Nathan Yonkee |
9:d58e77ebd769 | 300 | if os.path.isfile(lib_file): |
Nathan Yonkee |
9:d58e77ebd769 | 301 | # Rename command will fail on some OS's if the target file already exist, |
Nathan Yonkee |
9:d58e77ebd769 | 302 | # so ensure if it does, it is deleted first. |
Nathan Yonkee |
9:d58e77ebd769 | 303 | bak_file = library + '_bak' |
Nathan Yonkee |
9:d58e77ebd769 | 304 | if os.path.isfile(bak_file): |
Nathan Yonkee |
9:d58e77ebd769 | 305 | os.remove(bak_file) |
Nathan Yonkee |
9:d58e77ebd769 | 306 | |
Nathan Yonkee |
9:d58e77ebd769 | 307 | os.rename(lib_file, bak_file) |
Nathan Yonkee |
9:d58e77ebd769 | 308 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 309 | rel_log.error("Failure to backup lib file prior to updating.") |
Nathan Yonkee |
9:d58e77ebd769 | 310 | return False |
Nathan Yonkee |
9:d58e77ebd769 | 311 | |
Nathan Yonkee |
9:d58e77ebd769 | 312 | # mbed 2 style lib file contains one line with the following format |
Nathan Yonkee |
9:d58e77ebd769 | 313 | # e.g. https://developer.mbed.org/users/<user>/code/mbed-dev/#156823d33999 |
Nathan Yonkee |
9:d58e77ebd769 | 314 | exp = 'https://developer.mbed.org/users/' + user + '/code/' + library + '/#[A-Za-z0-9]+' |
Nathan Yonkee |
9:d58e77ebd769 | 315 | lib_re = re.compile(exp) |
Nathan Yonkee |
9:d58e77ebd769 | 316 | updated = False |
Nathan Yonkee |
9:d58e77ebd769 | 317 | |
Nathan Yonkee |
9:d58e77ebd769 | 318 | # Scan through mbed-os.lib line by line, looking for lib version and update |
Nathan Yonkee |
9:d58e77ebd769 | 319 | # it if found |
Nathan Yonkee |
9:d58e77ebd769 | 320 | with open(bak_file, 'r') as ip, open(lib_file, 'w') as op: |
Nathan Yonkee |
9:d58e77ebd769 | 321 | for line in ip: |
Nathan Yonkee |
9:d58e77ebd769 | 322 | |
Nathan Yonkee |
9:d58e77ebd769 | 323 | opline = line |
Nathan Yonkee |
9:d58e77ebd769 | 324 | |
Nathan Yonkee |
9:d58e77ebd769 | 325 | regexp = lib_re.match(line) |
Nathan Yonkee |
9:d58e77ebd769 | 326 | if regexp: |
Nathan Yonkee |
9:d58e77ebd769 | 327 | opline = 'https://developer.mbed.org/users/' + user + '/code/' + library + '/#' + ref |
Nathan Yonkee |
9:d58e77ebd769 | 328 | updated = True |
Nathan Yonkee |
9:d58e77ebd769 | 329 | |
Nathan Yonkee |
9:d58e77ebd769 | 330 | op.write(opline) |
Nathan Yonkee |
9:d58e77ebd769 | 331 | |
Nathan Yonkee |
9:d58e77ebd769 | 332 | if updated: |
Nathan Yonkee |
9:d58e77ebd769 | 333 | |
Nathan Yonkee |
9:d58e77ebd769 | 334 | # Setup the default commit message |
Nathan Yonkee |
9:d58e77ebd769 | 335 | commit_message = '"Updating ' + library + ' to ' + ref + '"' |
Nathan Yonkee |
9:d58e77ebd769 | 336 | |
Nathan Yonkee |
9:d58e77ebd769 | 337 | # Setup and run the commit command. Need to use the rawcommand in the hglib |
Nathan Yonkee |
9:d58e77ebd769 | 338 | # for this in order to pass the string value to the -m option. run_cmd using |
Nathan Yonkee |
9:d58e77ebd769 | 339 | # subprocess does not like this syntax. |
Nathan Yonkee |
9:d58e77ebd769 | 340 | try: |
Nathan Yonkee |
9:d58e77ebd769 | 341 | client.rawcommand(['commit','-m '+commit_message, lib_file]) |
Nathan Yonkee |
9:d58e77ebd769 | 342 | |
Nathan Yonkee |
9:d58e77ebd769 | 343 | cmd = ['hg', 'push', '-f', repo] |
Nathan Yonkee |
9:d58e77ebd769 | 344 | run_cmd(cmd, exit_on_failure=True) |
Nathan Yonkee |
9:d58e77ebd769 | 345 | |
Nathan Yonkee |
9:d58e77ebd769 | 346 | except: |
Nathan Yonkee |
9:d58e77ebd769 | 347 | rel_log.info("Lib file already up to date and thus nothing to commit") |
Nathan Yonkee |
9:d58e77ebd769 | 348 | |
Nathan Yonkee |
9:d58e77ebd769 | 349 | os.chdir(cwd) |
Nathan Yonkee |
9:d58e77ebd769 | 350 | return updated |
Nathan Yonkee |
9:d58e77ebd769 | 351 | |
Nathan Yonkee |
9:d58e77ebd769 | 352 | def get_sha(repo_path, library): |
Nathan Yonkee |
9:d58e77ebd769 | 353 | """ Gets the latest SHA for the library specified. The library is assumed to be |
Nathan Yonkee |
9:d58e77ebd769 | 354 | located at the repo_path. If a SHA cannot be obtained this script will exit. |
Nathan Yonkee |
9:d58e77ebd769 | 355 | |
Nathan Yonkee |
9:d58e77ebd769 | 356 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 357 | library - library name |
Nathan Yonkee |
9:d58e77ebd769 | 358 | repo_path - path to the user's repo area |
Nathan Yonkee |
9:d58e77ebd769 | 359 | |
Nathan Yonkee |
9:d58e77ebd769 | 360 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 361 | sha - last commit SHA |
Nathan Yonkee |
9:d58e77ebd769 | 362 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 363 | cwd = os.getcwd() |
Nathan Yonkee |
9:d58e77ebd769 | 364 | sha = None |
Nathan Yonkee |
9:d58e77ebd769 | 365 | os.chdir(abspath(repo_path + '/' + library)) |
Nathan Yonkee |
9:d58e77ebd769 | 366 | |
Nathan Yonkee |
9:d58e77ebd769 | 367 | cmd = ['hg', 'log', '-l', '1'] |
Nathan Yonkee |
9:d58e77ebd769 | 368 | ret, output = run_cmd_with_output(cmd, exit_on_failure=True) |
Nathan Yonkee |
9:d58e77ebd769 | 369 | |
Nathan Yonkee |
9:d58e77ebd769 | 370 | # Output should contain a 4 line string of the form: |
Nathan Yonkee |
9:d58e77ebd769 | 371 | # changeset: 135:176b8275d35d |
Nathan Yonkee |
9:d58e77ebd769 | 372 | # tag: tip |
Nathan Yonkee |
9:d58e77ebd769 | 373 | # user: <> |
Nathan Yonkee |
9:d58e77ebd769 | 374 | # date: Thu Feb 02 16:02:30 2017 +0000 |
Nathan Yonkee |
9:d58e77ebd769 | 375 | # summary: Release 135 of the mbed library |
Nathan Yonkee |
9:d58e77ebd769 | 376 | # All we want is the changeset string after version number |
Nathan Yonkee |
9:d58e77ebd769 | 377 | |
Nathan Yonkee |
9:d58e77ebd769 | 378 | lines = output.split('\n') |
Nathan Yonkee |
9:d58e77ebd769 | 379 | fields = lines[0].split(':') |
Nathan Yonkee |
9:d58e77ebd769 | 380 | sha = fields[2] |
Nathan Yonkee |
9:d58e77ebd769 | 381 | |
Nathan Yonkee |
9:d58e77ebd769 | 382 | os.chdir(cwd) |
Nathan Yonkee |
9:d58e77ebd769 | 383 | return sha |
Nathan Yonkee |
9:d58e77ebd769 | 384 | |
Nathan Yonkee |
9:d58e77ebd769 | 385 | def get_latest_library_versions(repo_path): |
Nathan Yonkee |
9:d58e77ebd769 | 386 | """ Returns the latest library versions (SHAs) for 'mbed' and 'mbed-dev'. |
Nathan Yonkee |
9:d58e77ebd769 | 387 | If the SHAs cannot be obtained this script will exit. |
Nathan Yonkee |
9:d58e77ebd769 | 388 | |
Nathan Yonkee |
9:d58e77ebd769 | 389 | Args: |
Nathan Yonkee |
9:d58e77ebd769 | 390 | repo_path - path to the user's repo area |
Nathan Yonkee |
9:d58e77ebd769 | 391 | |
Nathan Yonkee |
9:d58e77ebd769 | 392 | Returns: |
Nathan Yonkee |
9:d58e77ebd769 | 393 | mbed - last commit SHA for mbed library |
Nathan Yonkee |
9:d58e77ebd769 | 394 | mbed_dev - last commit SHA for mbed_dev library |
Nathan Yonkee |
9:d58e77ebd769 | 395 | |
Nathan Yonkee |
9:d58e77ebd769 | 396 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 397 | |
Nathan Yonkee |
9:d58e77ebd769 | 398 | mbed = get_sha(repo_path, 'mbed') |
Nathan Yonkee |
9:d58e77ebd769 | 399 | mbed_dev = get_sha(repo_path, 'mbed-dev') |
Nathan Yonkee |
9:d58e77ebd769 | 400 | |
Nathan Yonkee |
9:d58e77ebd769 | 401 | return mbed, mbed_dev |
Nathan Yonkee |
9:d58e77ebd769 | 402 | |
Nathan Yonkee |
9:d58e77ebd769 | 403 | def log_results(lst, title): |
Nathan Yonkee |
9:d58e77ebd769 | 404 | if len(lst) == 0: |
Nathan Yonkee |
9:d58e77ebd769 | 405 | rel_log.info("%s - None", title) |
Nathan Yonkee |
9:d58e77ebd769 | 406 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 407 | for entry in lst: |
Nathan Yonkee |
9:d58e77ebd769 | 408 | rel_log.info("%s - Test: %s, Target: %s", title, entry[0], entry[1]) |
Nathan Yonkee |
9:d58e77ebd769 | 409 | |
Nathan Yonkee |
9:d58e77ebd769 | 410 | |
Nathan Yonkee |
9:d58e77ebd769 | 411 | if __name__ == '__main__': |
Nathan Yonkee |
9:d58e77ebd769 | 412 | |
Nathan Yonkee |
9:d58e77ebd769 | 413 | parser = argparse.ArgumentParser(description=__doc__, |
Nathan Yonkee |
9:d58e77ebd769 | 414 | formatter_class=argparse.RawDescriptionHelpFormatter) |
Nathan Yonkee |
9:d58e77ebd769 | 415 | parser.add_argument('-l', '--log-level', |
Nathan Yonkee |
9:d58e77ebd769 | 416 | help="Level for providing logging output", |
Nathan Yonkee |
9:d58e77ebd769 | 417 | default='INFO') |
Nathan Yonkee |
9:d58e77ebd769 | 418 | args = parser.parse_args() |
Nathan Yonkee |
9:d58e77ebd769 | 419 | |
Nathan Yonkee |
9:d58e77ebd769 | 420 | default = getattr(logging, 'INFO') |
Nathan Yonkee |
9:d58e77ebd769 | 421 | level = getattr(logging, args.log_level.upper(), default) |
Nathan Yonkee |
9:d58e77ebd769 | 422 | |
Nathan Yonkee |
9:d58e77ebd769 | 423 | # Set logging level |
Nathan Yonkee |
9:d58e77ebd769 | 424 | logging.basicConfig(level=level) |
Nathan Yonkee |
9:d58e77ebd769 | 425 | rel_log = logging.getLogger("check-release") |
Nathan Yonkee |
9:d58e77ebd769 | 426 | |
Nathan Yonkee |
9:d58e77ebd769 | 427 | # Read configuration data |
Nathan Yonkee |
9:d58e77ebd769 | 428 | with open(os.path.join(os.path.dirname(__file__), "check_release.json")) as config: |
Nathan Yonkee |
9:d58e77ebd769 | 429 | json_data = json.load(config) |
Nathan Yonkee |
9:d58e77ebd769 | 430 | |
Nathan Yonkee |
9:d58e77ebd769 | 431 | supported_targets = [] |
Nathan Yonkee |
9:d58e77ebd769 | 432 | |
Nathan Yonkee |
9:d58e77ebd769 | 433 | if len(json_data["target_list"]) > 0: |
Nathan Yonkee |
9:d58e77ebd769 | 434 | # Compile user supplied subset of targets |
Nathan Yonkee |
9:d58e77ebd769 | 435 | supported_targets = json_data["target_list"] |
Nathan Yonkee |
9:d58e77ebd769 | 436 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 437 | # Get a list of the officially supported mbed-os 2 targets |
Nathan Yonkee |
9:d58e77ebd769 | 438 | for tgt in OFFICIAL_MBED_LIBRARY_BUILD: |
Nathan Yonkee |
9:d58e77ebd769 | 439 | supported_targets.append(tgt[0]) |
Nathan Yonkee |
9:d58e77ebd769 | 440 | |
Nathan Yonkee |
9:d58e77ebd769 | 441 | ignore_list = [] |
Nathan Yonkee |
9:d58e77ebd769 | 442 | |
Nathan Yonkee |
9:d58e77ebd769 | 443 | if len(json_data["ignore_list"]) > 0: |
Nathan Yonkee |
9:d58e77ebd769 | 444 | # List of tuples of (test, target) to be ignored in this test |
Nathan Yonkee |
9:d58e77ebd769 | 445 | ignore_list = json_data["ignore_list"] |
Nathan Yonkee |
9:d58e77ebd769 | 446 | |
Nathan Yonkee |
9:d58e77ebd769 | 447 | config = json_data["config"] |
Nathan Yonkee |
9:d58e77ebd769 | 448 | test_list = json_data["test_list"] |
Nathan Yonkee |
9:d58e77ebd769 | 449 | repo_path = config["mbed_repo_path"] |
Nathan Yonkee |
9:d58e77ebd769 | 450 | tests = [] |
Nathan Yonkee |
9:d58e77ebd769 | 451 | |
Nathan Yonkee |
9:d58e77ebd769 | 452 | # get username |
Nathan Yonkee |
9:d58e77ebd769 | 453 | cmd = ['hg', 'config', 'auth.x.username'] |
Nathan Yonkee |
9:d58e77ebd769 | 454 | ret, output = run_cmd_with_output(cmd, exit_on_failure=True) |
Nathan Yonkee |
9:d58e77ebd769 | 455 | output = output.split('\n') |
Nathan Yonkee |
9:d58e77ebd769 | 456 | user = output[0] |
Nathan Yonkee |
9:d58e77ebd769 | 457 | |
Nathan Yonkee |
9:d58e77ebd769 | 458 | # get password |
Nathan Yonkee |
9:d58e77ebd769 | 459 | cmd = ['hg', 'config', 'auth.x.password'] |
Nathan Yonkee |
9:d58e77ebd769 | 460 | ret, output = run_cmd_with_output(cmd, exit_on_failure=True) |
Nathan Yonkee |
9:d58e77ebd769 | 461 | output = output.split('\n') |
Nathan Yonkee |
9:d58e77ebd769 | 462 | password = output[0] |
Nathan Yonkee |
9:d58e77ebd769 | 463 | |
Nathan Yonkee |
9:d58e77ebd769 | 464 | mbed, mbed_dev = get_latest_library_versions(repo_path) |
Nathan Yonkee |
9:d58e77ebd769 | 465 | |
Nathan Yonkee |
9:d58e77ebd769 | 466 | if not mbed or not mbed_dev: |
Nathan Yonkee |
9:d58e77ebd769 | 467 | rel_log.error("Could not obtain latest versions of library files!!") |
Nathan Yonkee |
9:d58e77ebd769 | 468 | exit(1) |
Nathan Yonkee |
9:d58e77ebd769 | 469 | |
Nathan Yonkee |
9:d58e77ebd769 | 470 | rel_log.info("Latest mbed lib version = %s", mbed) |
Nathan Yonkee |
9:d58e77ebd769 | 471 | rel_log.info("Latest mbed-dev lib version = %s", mbed_dev) |
Nathan Yonkee |
9:d58e77ebd769 | 472 | |
Nathan Yonkee |
9:d58e77ebd769 | 473 | # First update test repos to latest versions of their embedded libraries |
Nathan Yonkee |
9:d58e77ebd769 | 474 | for test in test_list: |
Nathan Yonkee |
9:d58e77ebd769 | 475 | tests.append(test['name']) |
Nathan Yonkee |
9:d58e77ebd769 | 476 | upgrade_test_repo(test['name'], user, test['lib'], |
Nathan Yonkee |
9:d58e77ebd769 | 477 | mbed if test['lib'] == "mbed" else mbed_dev, |
Nathan Yonkee |
9:d58e77ebd769 | 478 | repo_path) |
Nathan Yonkee |
9:d58e77ebd769 | 479 | |
Nathan Yonkee |
9:d58e77ebd769 | 480 | total = len(supported_targets) * len(tests) |
Nathan Yonkee |
9:d58e77ebd769 | 481 | current = 0 |
Nathan Yonkee |
9:d58e77ebd769 | 482 | retries = 10 |
Nathan Yonkee |
9:d58e77ebd769 | 483 | passes = 0 |
Nathan Yonkee |
9:d58e77ebd769 | 484 | failures = [] |
Nathan Yonkee |
9:d58e77ebd769 | 485 | skipped = [] |
Nathan Yonkee |
9:d58e77ebd769 | 486 | |
Nathan Yonkee |
9:d58e77ebd769 | 487 | # Compile each test for each supported target |
Nathan Yonkee |
9:d58e77ebd769 | 488 | for test in tests: |
Nathan Yonkee |
9:d58e77ebd769 | 489 | for target in supported_targets: |
Nathan Yonkee |
9:d58e77ebd769 | 490 | |
Nathan Yonkee |
9:d58e77ebd769 | 491 | combo = [test, target] |
Nathan Yonkee |
9:d58e77ebd769 | 492 | |
Nathan Yonkee |
9:d58e77ebd769 | 493 | if combo in ignore_list: |
Nathan Yonkee |
9:d58e77ebd769 | 494 | rel_log.info("SKIPPING TEST: %s, TARGET: %s", test, target) |
Nathan Yonkee |
9:d58e77ebd769 | 495 | total -= 1 |
Nathan Yonkee |
9:d58e77ebd769 | 496 | skipped.append(combo) |
Nathan Yonkee |
9:d58e77ebd769 | 497 | continue |
Nathan Yonkee |
9:d58e77ebd769 | 498 | |
Nathan Yonkee |
9:d58e77ebd769 | 499 | current += 1 |
Nathan Yonkee |
9:d58e77ebd769 | 500 | for retry in range(0, retries): |
Nathan Yonkee |
9:d58e77ebd769 | 501 | rel_log.info("COMPILING (%d/%d): TEST %s, TARGET: %s , attempt %u\n", current, total, test, target, retry) |
Nathan Yonkee |
9:d58e77ebd769 | 502 | result, mesg = build_repo(target, test, user, password) |
Nathan Yonkee |
9:d58e77ebd769 | 503 | if not result: |
Nathan Yonkee |
9:d58e77ebd769 | 504 | if mesg == 'Internal': |
Nathan Yonkee |
9:d58e77ebd769 | 505 | # Internal compiler error thus retry |
Nathan Yonkee |
9:d58e77ebd769 | 506 | continue |
Nathan Yonkee |
9:d58e77ebd769 | 507 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 508 | # Actual error thus move on to next compilation |
Nathan Yonkee |
9:d58e77ebd769 | 509 | failures.append(combo) |
Nathan Yonkee |
9:d58e77ebd769 | 510 | break |
Nathan Yonkee |
9:d58e77ebd769 | 511 | |
Nathan Yonkee |
9:d58e77ebd769 | 512 | passes += (int)(result) |
Nathan Yonkee |
9:d58e77ebd769 | 513 | break |
Nathan Yonkee |
9:d58e77ebd769 | 514 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 515 | rel_log.error("Compilation failed due to internal errors.") |
Nathan Yonkee |
9:d58e77ebd769 | 516 | rel_log.error("Skipping test/target combination.") |
Nathan Yonkee |
9:d58e77ebd769 | 517 | total -= 1 |
Nathan Yonkee |
9:d58e77ebd769 | 518 | skipped.append(combo) |
Nathan Yonkee |
9:d58e77ebd769 | 519 | |
Nathan Yonkee |
9:d58e77ebd769 | 520 | rel_log.info(" SUMMARY OF COMPILATION RESULTS") |
Nathan Yonkee |
9:d58e77ebd769 | 521 | rel_log.info(" ------------------------------") |
Nathan Yonkee |
9:d58e77ebd769 | 522 | rel_log.info(" NUMBER OF TEST APPS: %d, NUMBER OF TARGETS: %d", |
Nathan Yonkee |
9:d58e77ebd769 | 523 | len(tests), len(supported_targets)) |
Nathan Yonkee |
9:d58e77ebd769 | 524 | log_results(failures, " FAILED") |
Nathan Yonkee |
9:d58e77ebd769 | 525 | log_results(skipped, " SKIPPED") |
Nathan Yonkee |
9:d58e77ebd769 | 526 | |
Nathan Yonkee |
9:d58e77ebd769 | 527 | # Output a % pass rate, indicate a failure if not 100% successful |
Nathan Yonkee |
9:d58e77ebd769 | 528 | pass_rate = (float(passes) / float(total)) * 100.0 |
Nathan Yonkee |
9:d58e77ebd769 | 529 | rel_log.info(" PASS RATE %.1f %%\n", pass_rate) |
Nathan Yonkee |
9:d58e77ebd769 | 530 | sys.exit(not (pass_rate == 100)) |