-
Notifications
You must be signed in to change notification settings - Fork 3k
Add smoke test that builds example programs with mbed-cli #2576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
eb11561
Add smoke test that builds example programs with mbed-cli
theotherjimmy 95ee4f6
Use json for the example to target mapping and print failures
theotherjimmy 78028a9
Move example tests to their own folder
theotherjimmy f7a1d1f
Move to feature filter for target and toolchain detection; print pass…
theotherjimmy 1f0afeb
Allow command-line filtering of toolchains
theotherjimmy 4b1dcd3
Allow filtering by target as well as by features
theotherjimmy 64e71e2
Use IPV6 feature for filtering mesh, client, and sockets
theotherjimmy 41ec0af
Update Docstring
theotherjimmy ac5c685
Use mbed-os 5 example instead of the mbed 2 one
theotherjimmy f983292
Separate the import and compile steps for better integration with Jen…
theotherjimmy 3437829
return the number of failures from the script
theotherjimmy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky" : {}, | ||
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon" : | ||
{"features": ["BLE"]}, | ||
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate" : | ||
{"features": ["BLE"]}, | ||
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-mesh-minimal" : | ||
{"features": ["IPV6"]}, | ||
"https://github.com/ARMmbed/mbed-os-example-client" : {"features": ["IPV6"]}, | ||
"https://github.com/ARMmbed/mbed-os-example-sockets" : {"features": ["IPV6"]}, | ||
"https://github.com/ARMmbed/mbed-os-example-uvisor" : {"targets": ["K64F"]} | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
""" import and bulid a bunch of example programs """ | ||
|
||
from argparse import ArgumentParser | ||
import os | ||
from os.path import dirname, abspath, basename | ||
import os.path | ||
import sys | ||
import subprocess | ||
import json | ||
|
||
ROOT = abspath(dirname(dirname(dirname(dirname(__file__))))) | ||
sys.path.insert(0, ROOT) | ||
|
||
from tools.build_api import get_mbed_official_release | ||
from tools.targets import TARGET_MAP | ||
from tools.utils import argparse_force_uppercase_type | ||
|
||
|
||
EXAMPLES = json.load(open(os.path.join(os.path.dirname(__file__), | ||
"examples.json"))) | ||
|
||
def print_stuff(name, lst): | ||
if lst: | ||
print("#"*80) | ||
print("# {} example combinations".format(name)) | ||
print("#") | ||
for thing in lst: | ||
print(thing) | ||
|
||
|
||
SUPPORTED_TOOLCHAINS = ["ARM", "IAR", "GCC_ARM"] | ||
|
||
|
||
def target_cross_toolchain(allowed_toolchains, | ||
features=[], targets=TARGET_MAP.keys()): | ||
"""Generate pairs of target and toolchains | ||
|
||
Args: | ||
allowed_toolchains - a list of all possible toolchains | ||
|
||
Kwargs: | ||
features - the features that must be in the features array of a | ||
target | ||
targets - a list of available targets | ||
""" | ||
for target, toolchains in get_mbed_official_release("5"): | ||
for toolchain in toolchains: | ||
if (toolchain in allowed_toolchains and | ||
target in targets and | ||
all(feature in TARGET_MAP[target].features | ||
for feature in features)): | ||
yield target, toolchain | ||
|
||
|
||
def main(): | ||
"""Entry point""" | ||
parser = ArgumentParser() | ||
subparsers = parser.add_subparsers() | ||
import_cmd = subparsers.add_parser("import") | ||
import_cmd.set_defaults(fn=do_import) | ||
compile_cmd = subparsers.add_parser("compile") | ||
compile_cmd.set_defaults(fn=do_compile) | ||
compile_cmd.add_argument( | ||
"toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS, | ||
type=argparse_force_uppercase_type(SUPPORTED_TOOLCHAINS, | ||
"toolchain")) | ||
args = parser.parse_args() | ||
return args.fn(args) | ||
|
||
|
||
def do_import(_): | ||
"""Do the import step of this process""" | ||
for example, _ in EXAMPLES.iteritems(): | ||
subprocess.call(["mbed-cli", "import", example]) | ||
return 0 | ||
|
||
|
||
def do_compile(args): | ||
"""Do the compile step""" | ||
failures = [] | ||
sucesses = [] | ||
for example, requirements in EXAMPLES.iteritems(): | ||
os.chdir(basename(example)) | ||
for target, toolchain in target_cross_toolchain(args.toolchains, | ||
**requirements): | ||
proc = subprocess.Popen(["mbed-cli", "compile", "-t", toolchain, | ||
"-m", target, "--silent"]) | ||
proc.wait() | ||
example_name = "{} {} {}".format(basename(example), target, | ||
toolchain) | ||
if proc.returncode: | ||
failures.append(example_name) | ||
else: | ||
sucesses.append(example_name) | ||
os.chdir("..") | ||
|
||
print_stuff("Passed", sucesses) | ||
print_stuff("Failed", failures) | ||
return len(failures) | ||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add uvisor example