Skip to content

Commit 4d985ea

Browse files
Merge pull request #4385 from bridadan/examples_choose_source
Allow examples to specify which repo source to use for testing
2 parents 186f406 + 3966139 commit 4d985ea

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

tools/test/examples/examples.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"mbed": [
77
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky"
88
],
9+
"test-repo-source": "github",
910
"features" : [],
1011
"targets" : [],
1112
"toolchains" : [],
@@ -23,6 +24,7 @@
2324
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-hashing",
2425
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-authcrypt"
2526
],
27+
"test-repo-source": "mbed",
2628
"features" : [],
2729
"targets" : ["K64F", "NUCLEO_F429ZI"],
2830
"toolchains" : ["GCC_ARM", "ARM"],
@@ -37,6 +39,7 @@
3739
"mbed": [
3840
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-mesh-minimal"
3941
],
42+
"test-repo-source": "github",
4043
"features" : [],
4144
"targets" : ["DISCO_F469NI", "DISCO_F746NG", "K64F", "K66F",
4245
"NUCLEO_F429ZI", "NUCLEO_F439ZI", "NUCLEO_F746ZG",
@@ -63,6 +66,7 @@
6366
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Button",
6467
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-BatteryLevel"
6568
],
69+
"test-repo-source": "mbed",
6670
"features" : ["BLE"],
6771
"targets" : ["NRF51_DK", "NRF52_DK", "K64F", "NUCLEO_F401RE"],
6872
"toolchains" : [],
@@ -77,6 +81,7 @@
7781
"mbed": [
7882
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-client"
7983
],
84+
"test-repo-source": "github",
8085
"features" : ["LWIP"],
8186
"targets" : [],
8287
"toolchains" : [],
@@ -90,6 +95,7 @@
9095
"github":"https://github.com/ARMmbed/mbed-os-example-sockets",
9196
"mbed": [
9297
],
98+
"test-repo-source": "github",
9399
"features" : ["LWIP"],
94100
"targets" : [],
95101
"toolchains" : [],
@@ -103,6 +109,7 @@
103109
"github":"https://github.com/ARMmbed/mbed-os-example-wifi",
104110
"mbed": [
105111
],
112+
"test-repo-source": "github",
106113
"features" : [],
107114
"targets" : [],
108115
"toolchains" : [],
@@ -115,6 +122,7 @@
115122
"name": "mbed-os-example-uvisor",
116123
"github":"https://github.com/ARMmbed/mbed-os-example-uvisor",
117124
"mbed": [],
125+
"test-repo-source": "github",
118126
"features" : [],
119127
"targets" : ["K64F"],
120128
"toolchains" : ["GCC_ARM"],
@@ -127,6 +135,7 @@
127135
"name": "mbed-os-example-uvisor-thread",
128136
"github":"https://github.com/ARMmbed/mbed-os-example-uvisor-thread",
129137
"mbed": [],
138+
"test-repo-source": "github",
130139
"features" : [],
131140
"targets" : ["K64F"],
132141
"toolchains" : ["GCC_ARM"],
@@ -139,6 +148,7 @@
139148
"name": "mbed-os-example-uvisor-number-store",
140149
"github":"https://github.com/ARMmbed/mbed-os-example-uvisor-number-store",
141150
"mbed": [],
151+
"test-repo-source": "github",
142152
"features" : [],
143153
"targets" : ["K64F"],
144154
"toolchains" : ["GCC_ARM"],
@@ -153,6 +163,7 @@
153163
"mbed": [
154164
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-bootloader"
155165
],
166+
"test-repo-source": "github",
156167
"features" : [],
157168
"targets" : ["K64F", "NUCLEO_F429ZI", "UBLOX_EVK_ODIN_W2"],
158169
"toolchains" : [],
@@ -167,6 +178,7 @@
167178
"mbed": [
168179
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-fat-filesystem"
169180
],
181+
"test-repo-source": "github",
170182
"features" : [],
171183
"targets" : ["K64F"],
172184
"toolchains" : [],
@@ -179,6 +191,7 @@
179191
"name": "nanostack-border-router",
180192
"github":"https://github.com/ARMmbed/nanostack-border-router",
181193
"mbed": [],
194+
"test-repo-source": "github",
182195
"features" : [],
183196
"targets" : ["K64F", "K66F", "NUCLEO_F429ZI"],
184197
"toolchains" : [],

tools/test/examples/examples_lib.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
""" Import and bulid a bunch of example programs
22
3-
This library includes functions that are shared between the examples.py and
3+
This library includes functions that are shared between the examples.py and
44
the update.py modules.
5-
5+
66
"""
77
import os
88
from os.path import dirname, abspath, basename
@@ -123,20 +123,19 @@ def target_cross_ide(allowed_targets, allowed_ides, features=[], toolchains=[]):
123123

124124

125125
def get_repo_list(example):
126-
""" Returns a list of all the repos associated with the specific example in the json
127-
config file.
128-
If there are repos listed under the mbed section then these will be returned as a
129-
list. If not then the github single repo with be returned.
130-
NOTE: This does not currently deal with multiple examples underneath a github
126+
""" Returns a list of all the repos and their types associated with the
127+
specific example in the json config file.
128+
If the key 'test-repo-source' is set to 'mbed', then it will return the
129+
mbed section as a list. Otherwise, it will return the single github repo.
130+
NOTE: This does not currently deal with multiple examples underneath a github
131131
sourced exampe repo.
132132
133133
Args:
134134
example - Example for which the repo list is requested
135-
repos - The list of repos and types contained within that example in the json file
136135
137136
"""
138137
repos = []
139-
if len(example['mbed']) > 0:
138+
if example['test-repo-source'] == 'mbed':
140139
for repo in example['mbed']:
141140
repos.append({
142141
'repo': repo,
@@ -156,7 +155,7 @@ def source_repos(config, examples):
156155
there is already a clone of the repo then it will first be removed to
157156
ensure a clean, up to date cloning.
158157
Args:
159-
config - the json object imported from the file.
158+
config - the json object imported from the file.
160159
161160
"""
162161
print("\nImporting example repos....\n")
@@ -214,7 +213,7 @@ def get_num_failures(results, export=False):
214213
Args:
215214
results - results summary of the compilation stage. See compile_repos() for
216215
details of the format.
217-
num_failures
216+
num_failures
218217
219218
"""
220219
num_failures = 0
@@ -314,23 +313,23 @@ def status(message):
314313

315314
def compile_repos(config, toolchains, targets, examples):
316315
"""Compiles combinations of example programs, targets and compile chains.
317-
316+
318317
The results are returned in a [key: value] dictionary format:
319318
Where key = The example name from the json config file
320319
value = a list containing: pass_status, successes, and failures
321-
320+
322321
where pass_status = The overall pass status for the compilation of the full
323322
set of example programs comprising the example suite.
324323
True if all examples pass, false otherwise
325-
successes = list of passing examples.
324+
successes = list of passing examples.
326325
failures = list of failing examples.
327-
326+
328327
Both successes and failures contain the example name, target and compile chain
329328
330329
Args:
331-
config - the json object imported from the file.
330+
config - the json object imported from the file.
332331
toolchains - List of toolchains to compile for.
333-
results - results of the compilation stage.
332+
results - results of the compilation stage.
334333
335334
"""
336335
results = {}
@@ -349,8 +348,8 @@ def compile_repos(config, toolchains, targets, examples):
349348
for repo_info in get_repo_list(example):
350349
name = basename(repo_info['repo'])
351350
os.chdir(name)
352-
353-
# Check that the target, toolchain and features combinations are valid and return a
351+
352+
# Check that the target, toolchain and features combinations are valid and return a
354353
# list of valid combinations to work through
355354
for target, toolchain in target_cross_toolchain(valid_choices(example['targets'], targets),
356355
valid_choices(example['toolchains'], toolchains),
@@ -365,7 +364,7 @@ def compile_repos(config, toolchains, targets, examples):
365364
else:
366365
successes.append(example_summary)
367366
os.chdir("..")
368-
367+
369368
# If there are any compilation failures for the example 'set' then the overall status is fail.
370369
if len(failures) > 0:
371370
pass_status = False
@@ -378,14 +377,14 @@ def compile_repos(config, toolchains, targets, examples):
378377

379378

380379
def update_mbedos_version(config, tag, examples):
381-
""" For each example repo identified in the config json object, update the version of
380+
""" For each example repo identified in the config json object, update the version of
382381
mbed-os to that specified by the supplied GitHub tag. This function assumes that each
383382
example repo has already been cloned.
384-
383+
385384
Args:
386-
config - the json object imported from the file.
385+
config - the json object imported from the file.
387386
tag - GitHub tag corresponding to a version of mbed-os to upgrade to.
388-
387+
389388
"""
390389
print("Updating mbed-os in examples to version %s\n" % tag)
391390
for example in config['examples']:
@@ -397,4 +396,3 @@ def update_mbedos_version(config, tag, examples):
397396
os.chdir(update_dir)
398397
subprocess.call(["mbed-cli", "update", tag, "--clean"])
399398
os.chdir("../..")
400-

0 commit comments

Comments
 (0)