Skip to content
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

Make update.py test compile examples prior to updating mbed-os version. #3048

Merged
merged 6 commits into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 101 additions & 7 deletions tools/test/examples/examples.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,102 @@
{
"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-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"], "toolchains":["GCC_ARM"]}
}
"examples": [
{
"name": "mbed-os-example-blinky",
"github": "https://github.com/ARMmbed/mbed-os-example-blinky",
"mbed": [
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky"
],
"features" : [],
"targets" : [],
"toolchains" : [],
"auto-update" : true
},
{
"name": "mbed-os-example-tls",
"github": "https://github.com/ARMmbed/mbed-os-example-tls",
"mbed": [
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-benchmark",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-tls-client",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-hashing",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-authcrypt"
],
"features" : [],
"targets" : [],
"toolchains" : [],
"auto-update" : true
},
{
"name": "mbed-os-example-mesh-minimal",
"github":"https://github.com/ARMmbed/mbed-os-example-mesh-minimal",
"mbed": [
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-mesh-minimal"
],
"features" : ["IPV6"],
"targets" : [],
"toolchains" : [],
"auto-update" : true
},
{
"name": "mbed-os-example-ble",
"github":"https://github.com/ARMmbed/mbed-os-example-ble",
"mbed": [
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-URIBeacon",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Thermometer",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-LEDBlinker",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-LED",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-GAPButton",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-EddystoneService",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-EddystoneObserver",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Button",
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-BatteryLevel"
],
"features" : ["BLE"],
"targets" : [],
"toolchains" : [],
"auto-update" : true
},
{
"name": "mbed-os-example-client",
"github":"https://github.com/ARMmbed/mbed-os-example-client",
"mbed": [
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-client"
],
"features" : ["IPV6"],
"targets" : [],
"toolchains" : [],
"auto-update" : true
},
{
"name": "mbed-os-example-sockets",
"github":"https://github.com/ARMmbed/mbed-os-example-sockets",
"mbed": [
],
"features" : ["IPV6"],
"targets" : [],
"toolchains" : [],
"auto-update" : true
},
{
"name": "mbed-os-example-wifi",
"github":"https://github.com/ARMmbed/mbed-os-example-wifi",
"mbed": [
],
"features" : [],
"targets" : [],
"toolchains" : [],
"auto-update" : true
},
{
"name": "mbed-os-example-uvisor",
"github":"https://github.com/ARMmbed/mbed-os-example-uvisor",
"mbed": [
],
"features" : [],
"targets" : ["K64F"],
"toolchains" : ["GCC_ARM"],
"auto-update" : false
}
]
}
91 changes: 25 additions & 66 deletions tools/test/examples/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,95 +11,54 @@
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(),
toolchains=SUPPORTED_TOOLCHAINS):
"""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
toolchains - a list of available toolchains
"""
for release_target, release_toolchains in get_mbed_official_release("5"):
for toolchain in release_toolchains:
if (toolchain in allowed_toolchains and
toolchain in toolchains and
release_target in targets and
all(feature in TARGET_MAP[release_target].features
for feature in features)):
yield release_target, toolchain
import examples_lib as lib
from examples_lib import SUPPORTED_TOOLCHAINS


def main():
"""Entry point"""
parser = ArgumentParser()
parser.add_argument("-c", dest="config", default="examples.json")
subparsers = parser.add_subparsers()
import_cmd = subparsers.add_parser("import")
import_cmd.set_defaults(fn=do_import)
version_cmd = subparsers.add_parser("tag")
version_cmd.add_argument("tag")
version_cmd.set_defaults(fn=do_versionning)
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)
config = json.load(open(os.path.join(os.path.dirname(__file__),
args.config)))

return args.fn(args, config)

def do_import(_):

def do_import(_, config):
"""Do the import step of this process"""
for example, _ in EXAMPLES.iteritems():
subprocess.call(["mbed-cli", "import", example])
lib.source_repos(config)
return 0


def do_compile(args):
def do_compile(args, config):
"""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("..")
results = {}
results = lib.compile_repos(config, args.toolchains)

lib.print_compilation_summary(results)
failures = lib.get_num_failures(results)
print("Number of failures = %d" % failures)
return failures

def do_versionning(args, config):
""" Test update the mbed-os to the version specified by the tag """
lib.update_mbedos_version(config, args.tag)
return 0

print_stuff("Passed", sucesses)
print_stuff("Failed", failures)
return len(failures)

if __name__ == "__main__":
sys.exit(main())
Loading