Skip to content

Commit f7a1d1f

Browse files
committed
Move to feature filter for target and toolchain detection; print passed tests
1 parent 78028a9 commit f7a1d1f

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

tools/test/examples/examples.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"https://developer.mbed.org/teams/mbed/code/mbed_blinky" : ["K64F"],
3-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon" : ["NRF51_DK"],
4-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate" : ["NRF51_DK"],
5-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-mesh-minimal" :["K64F"],
6-
"https://github.com/ARMmbed/mbed-os-example-client" : ["K64F"],
7-
"https://github.com/ARMmbed/mbed-os-example-sockets" : ["K64F", "VK_RZ_A1H", "LPC1768"]
2+
"https://developer.mbed.org/teams/mbed/code/mbed_blinky" : [],
3+
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon" : ["BLE"],
4+
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate" : ["BLE"],
5+
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-mesh-minimal" :["IPV4"],
6+
"https://github.com/ARMmbed/mbed-os-example-client" : ["IPV4"],
7+
"https://github.com/ARMmbed/mbed-os-example-sockets" : ["IPV4"]
88
}

tools/test/examples/examples.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,55 @@
11
""" import and bulid a bunch of example programs """
22

33
import os
4+
from os.path import dirname, abspath, basename
45
import os.path
56
import sys
67
import subprocess
78
import json
89

10+
ROOT = abspath(dirname(dirname(dirname(dirname(__file__)))))
11+
sys.path.insert(0, ROOT)
12+
13+
from tools.build_api import get_mbed_official_release
14+
from tools.targets import TARGET_MAP
15+
916

1017
EXAMPLES = json.load(open(os.path.join(os.path.dirname(__file__),
1118
"examples.json")))
1219

13-
BUILD_TOOLCHAINS = [
14-
"ARM",
15-
"GCC_ARM",
16-
"IAR",
17-
]
20+
def print_stuff(name, lst):
21+
if list:
22+
print("#"*80)
23+
print("# {} example combinations".format(name))
24+
print("#")
25+
for thing in lst:
26+
print(thing)
27+
1828

1929
def main():
2030
"""Entry point"""
2131
failures = []
22-
for example, build_targets in EXAMPLES.iteritems():
32+
sucesses = []
33+
for example, build_features in EXAMPLES.iteritems():
2334
subprocess.call(["mbed-cli", "import", example])
24-
os.chdir(os.path.basename(example))
25-
for toolchain in BUILD_TOOLCHAINS:
26-
for target in build_targets:
35+
os.chdir(basename(example))
36+
for target, toolchains in [(target, toolchains) for target, toolchains
37+
in get_mbed_official_release("5") if
38+
all(feature in TARGET_MAP[target].features
39+
for feature in build_features)]:
40+
for toolchain in toolchains:
2741
proc = subprocess.Popen(["mbed-cli", "compile", "-t",
2842
toolchain, "-m", target])
2943
proc.wait()
44+
example_name = "{} {} {}".format(basename(example), target,
45+
toolchain)
3046
if proc.returncode:
31-
failures.append("{} {} {}".format(example, target,
32-
toolchain))
47+
failures.append(example_name)
48+
else:
49+
sucesses.append(example_name)
3350
os.chdir("..")
34-
if failures:
35-
print("#"*80)
36-
print("# Failed example combinations")
37-
print("#")
38-
for fail in failures:
39-
print(fail)
51+
print_stuff("Passed", sucesses)
52+
print_stuff("Failed", failures)
4053
return len(failures)
4154

4255
if __name__ == "__main__":

0 commit comments

Comments
 (0)