1
+ properties ([[$class : ' ParametersDefinitionProperty' , parameterDefinitions : [
2
+ [$class : ' StringParameterDefinition' , name : ' mbed_os_revision' , defaultValue : ' mbed-os-5.4' , description : ' Revision of mbed-os to build' ],
3
+ [$class : ' BooleanParameterDefinition' , name : ' smoke_test' , defaultValue : false , description : ' Runs HW smoke tests on Cellular devices' ]
4
+ ]]])
5
+
6
+ echo " Run smoke tests: ${ params.smoke_test} "
7
+
8
+ try {
9
+ echo " Verifying build with mbed-os version ${ mbed_os_revision} "
10
+ env. MBED_OS_REVISION = " ${ mbed_os_revision} "
11
+ } catch (err) {
12
+ def mbed_os_revision = " master"
13
+ echo " Verifying build with mbed-os version ${ mbed_os_revision} "
14
+ env. MBED_OS_REVISION = " ${ mbed_os_revision} "
15
+ }
16
+
17
+ // Map RaaS instances to corresponding test suites
18
+ def raas = [
19
+ " cellular_minimal_smoke_ublox.json" : " 8072"
20
+ ]
21
+
22
+ // List of targets with supported modem families
23
+ def targets = [
24
+ " UBLOX" : [" UBLOX_C027" , " UBLOX_C027" ],
25
+ " MTS_DRAGONFLY" : [" MTS_DRAGONFLY" ]
26
+ ]
27
+
28
+ // Supported Modems
29
+ def modems = [
30
+ " UBLOX_C027" ,
31
+ " UBLOX_C027" ,
32
+ " MTS_DRAGONFLY"
33
+ ]
34
+
35
+ // Map toolchains to compilers
36
+ def toolchains = [
37
+ ARM : " armcc" ,
38
+ GCC_ARM : " arm-none-eabi-gcc" ,
39
+ IAR : " iar_arm"
40
+ ]
41
+
42
+ def stepsForParallel = [:]
43
+
44
+ // Jenkins pipeline does not support map.each, we need to use oldschool for loop
45
+ for (int i = 0 ; i < targets. size(); i++ ) {
46
+ for (int j = 0 ; j < toolchains. size(); j++ ) {
47
+ def target = targets. keySet(). asList(). get(i)
48
+ def allowed_modem_type = targets. get(target)
49
+ def toolchain = toolchains. keySet(). asList(). get(j)
50
+ def compilerLabel = toolchains. get(toolchain)
51
+
52
+ // Skip unwanted combination
53
+ if (target == " NUCLEO_F401RE" && toolchain == " IAR" ) {
54
+ continue
55
+ }
56
+
57
+ def stepName = " ${ target} ${ toolchain} "
58
+ if (allowed_modem_type. contains(modems)) {
59
+ stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain)
60
+ }
61
+ }
62
+ }
63
+
64
+
65
+ def parallelRunSmoke = [:]
66
+
67
+ // Need to compare boolean against string value
68
+ if ( params. smoke_test == true ) {
69
+ // Generate smoke tests based on suite amount
70
+ for (int i = 0 ; i < raas. size(); i++ ) {
71
+ def suite_to_run = raas. keySet(). asList(). get(i)
72
+ def raasPort = raas. get(suite_to_run)
73
+ // Parallel execution needs unique step names. Remove .json file ending.
74
+ def smokeStep = " ${ raasPort} ${ suite_to_run.substring(0, suite_to_run.indexOf('.'))} "
75
+ parallelRunSmoke[smokeStep] = run_smoke(targets, toolchains, raasPort, suite_to_run, modems)
76
+ }
77
+ }
78
+
79
+ timestamps {
80
+ parallel stepsForParallel
81
+ parallel parallelRunSmoke
82
+ }
83
+
84
+ def buildStep (target , compilerLabel , toolchain ) {
85
+ return {
86
+ stage (" ${ target} _${ compilerLabel} " ) {
87
+ node (" ${ compilerLabel} " ) {
88
+ deleteDir()
89
+ dir(" mbed-os-example-cellular-minimal" ) {
90
+ checkout scm
91
+ def config_file = " mbed_app.json"
92
+
93
+ // Activate traces
94
+ execute(" sed -i 's/\" mbed-trace.enable\" : false/\" mbed-trace.enable\" : true/' ${ config_file} " )
95
+
96
+ // Set mbed-os to revision received as parameter
97
+ execute (" mbed deploy --protocol ssh" )
98
+ dir (" mbed-os" ) {
99
+ execute (" git checkout ${ env.MBED_OS_REVISION} " )
100
+ }
101
+
102
+ execute (" mbed compile --build out/${ target} _${ toolchain} / -m ${ target} -t ${ toolchain} -c --app-config ${ config_file} " )
103
+ }
104
+ stash name : " ${ target} _${ toolchain} " , includes : ' **/mbed-os-example-cellular-minimal.bin'
105
+ archive ' **/mbed-os-example-cellular-minimal.bin'
106
+ step([$class : ' WsCleanup' ])
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ def run_smoke (targets , toolchains , raasPort , suite_to_run , modems ) {
113
+ return {
114
+ // Remove .json from suite name
115
+ def suiteName = suite_to_run. substring(0 , suite_to_run. indexOf(' .' ))
116
+ stage (" smoke_${ raasPort} _${ suiteName} " ) {
117
+ node (" cellular-test" ) {
118
+ deleteDir()
119
+ dir(" mbed-clitest" ) {
120
+ git
" [email protected] :ARMmbed/mbed-clitest.git"
121
+ execute(" git checkout ${ env.LATEST_CLITEST_REL} " )
122
+ execute(" git submodule update --init --recursive testcases" )
123
+
124
+ dir(" testcases" ) {
125
+ execute(" git checkout master" )
126
+ dir(" 6lowpan" ) {
127
+ execute(" git checkout master" )
128
+ }
129
+ }
130
+
131
+ for (int i = 0 ; i < targets. size(); i++ ) {
132
+ for (int j = 0 ; j < toolchains. size(); j++ ) {
133
+ def target = targets. keySet(). asList(). get(i)
134
+ def allowed_modems = targets. get(target)
135
+ def toolchain = toolchains. keySet(). asList(). get(j)
136
+ }
137
+ }
138
+
139
+ env. RAAS_USERNAME = " user"
140
+ env. RAAS_PASSWORD = " user"
141
+ execute(" python clitest.py --suitedir testcases/suites/ --suite ${ suite_to_run} --type hardware --reset --raas 193.208.80.31:${ raasPort} --failure_return_value -vvv -w --log log_${ raasPort} _${ suiteName} " )
142
+ archive " log_${ raasPort} _${ suiteName} /**/*"
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
0 commit comments