@@ -67,7 +67,15 @@ def wrap_fd(pipeout):
67
67
68
68
def lets_run_a_test (name ):
69
69
sitl_args = ['dronekit-sitl' , 'copter-3.3-rc5' , '-I0' , '-S' , '--model' , 'quad' , '--home=-35.363261,149.165230,584,353' ]
70
+
71
+ speedup = os .environ .get ('TEST_SPEEDUP' , '1' )
72
+ rate = os .environ .get ('TEST_RATE' , '200' )
73
+ sitl_args += ['--speedup' , str (speedup ), '-r' , str (rate )]
74
+
75
+ # Change CPU core affinity.
76
+ # TODO change affinity on osx/linux
70
77
if sys .platform == 'win32' :
78
+ # 0x14 = 0b1110 = all cores except cpu 1
71
79
sitl = Popen (['start' , '/affinity' , '14' , '/realtime' , '/b' , '/wait' ] + sitl_args , shell = True , stdout = PIPE , stderr = PIPE )
72
80
else :
73
81
sitl = Popen (sitl_args , stdout = PIPE , stderr = PIPE )
@@ -104,36 +112,47 @@ def lets_run_a_test(name):
104
112
sys .stdout .flush ()
105
113
sys .stderr .flush ()
106
114
107
- # APPVEYOR = SLOW
108
- timeout = 15 * 60 if sys .platform == 'win32' else 5 * 60
115
+ mavproxy_verbose = False
116
+ timeout = 5 * 60
117
+
109
118
try :
110
- p = Popen ([sys .executable , '-m' , 'MAVProxy.mavproxy' , '--logfile=' + tempfile .mkstemp ()[1 ], '--master=tcp:127.0.0.1:5760' ], cwd = testpath , env = newenv , stdin = PIPE , stdout = PIPE ) # , stderr=PIPE)
119
+ p = Popen ([sys .executable , '-m' , 'MAVProxy.mavproxy' , '--logfile=' + tempfile .mkstemp ()[1 ], '--master=tcp:127.0.0.1:5760' ], cwd = testpath , env = newenv , stdin = PIPE , stdout = PIPE , stderr = PIPE if not mavproxy_verbose else None )
111
120
bg .append (p )
112
121
122
+ # TODO this sleep is only for us to waiting until
123
+ # all parameters to be received; would prefer to
124
+ # move this to testlib.py and happen asap
113
125
while p .poll () == None :
114
126
line = p .stdout .readline ()
115
- sys .stdout .write (line )
116
- sys .stdout .flush ()
127
+ if mavproxy_verbose :
128
+ sys .stdout .write (line )
129
+ sys .stdout .flush ()
117
130
if 'parameters' in line :
118
131
break
119
132
120
- # TODO this sleep is only for us to waiting until
121
- # all parameters to be received; would prefer to
122
- # move this to testlib.py and happen asap
123
133
time .sleep (3 )
124
- p .stdin .write ('module load droneapi.module.api\n ' )
134
+
135
+ # NOTE these are *very inappropriate settings*
136
+ # to make on a real vehicle. They are leveraged
137
+ # exclusively for simulation. Take heed!!!
125
138
p .stdin .write ('param set ARMING_CHECK 0\n ' )
139
+ p .stdin .write ('param set FS_THR_ENABLE 0\n ' )
140
+ p .stdin .write ('param set FS_GCS_ENABLE 0\n ' )
141
+ p .stdin .write ('param set EKF_CHECK_THRESH 0\n ' )
142
+
143
+ p .stdin .write ('module load droneapi.module.api\n ' )
126
144
p .stdin .write ('api start testlib.py\n ' )
127
145
p .stdin .flush ()
128
146
129
- while True :
130
- nextline = p .stdout .readline ()
131
- if nextline == '' and p .poll () != None :
132
- break
133
- sys .stdout .write (nextline )
134
- sys .stdout .flush ()
135
-
136
- # wait_timeout(p, timeout)
147
+ if mavproxy_verbose :
148
+ while True :
149
+ nextline = p .stdout .readline ()
150
+ if nextline == '' and p .poll () != None :
151
+ break
152
+ sys .stdout .write (nextline )
153
+ sys .stdout .flush ()
154
+ else :
155
+ wait_timeout (p , timeout )
137
156
except RuntimeError :
138
157
kill (p .pid )
139
158
p .returncode = 143
@@ -148,17 +167,29 @@ def lets_run_a_test(name):
148
167
bg .remove (sitl )
149
168
150
169
if p .returncode != 0 :
151
- print ('[runner] ...aborting with dronekit error code ' + str (p .returncode ))
152
- sys . stdout . flush ()
153
- sys . stderr . flush ( )
154
- sys . exit ( p . returncode )
155
-
156
- print ( '[runner] ...success.' )
170
+ print ('[runner] ...failed with dronekit error code ' + str (p .returncode ))
171
+ else :
172
+ print ( '[runner] ...success.' )
173
+
174
+ sys . stdout . flush ()
175
+ sys . stderr . flush ( )
157
176
time .sleep (5 )
177
+ return p .returncode
158
178
159
- for i in os .listdir (testpath ):
160
- if i .startswith ('test_' ) and i .endswith ('.py' ):
161
- lets_run_a_test (i [:- 3 ])
179
+ retry = int (os .environ .get ('TEST_RETRY' , '1' ))
180
+ for path in os .listdir (testpath ):
181
+ if path .startswith ('test_' ) and path .endswith ('.py' ):
182
+ name = path [:- 3 ]
183
+ i = retry
184
+ while True :
185
+ ret = lets_run_a_test (name )
186
+ if ret == 0 :
187
+ break
188
+ i = i - 1
189
+ if i == 0 :
190
+ print ('[runner] aborting after failed test.' )
191
+ sys .exit (ret )
192
+ print ('[runner] retrying %s %s more times' % (name , i , ))
162
193
163
194
print ('[runner] finished.' )
164
195
sys .stdout .flush ()
0 commit comments