Skip to content

Commit 3a48a76

Browse files
committed
Tools: test_param_upgrade.py: take a --master-branch parameter
Allows testing against things which are not the master branch This requires getting nasty in terms of removing the build directory because of our missing-dependecy-file waf issues. Also requires handling branches that don't have the "novehicle" model.
1 parent 484ce40 commit 3a48a76

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

Tools/autotest/test_param_upgrade.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import argparse
1515
import subprocess
1616
import time
17+
import shutil
1718
import string
1819
import pathlib
1920

@@ -50,10 +51,18 @@ def vehicleinfo_key(self):
5051
return "ArduCopter"
5152
raise ValueError("Can't determine vehicleinfo_key from binary path")
5253

54+
def model(self):
55+
path = self.binary.lower()
56+
if "plane" in path:
57+
return "quadplane"
58+
if "copter" in path:
59+
return "X"
60+
raise ValueError("Can't determine vehicleinfo_key from binary path")
61+
5362
def run(self):
5463
self.start_SITL(
5564
binary=self.binary,
56-
model="novehicle",
65+
model=self.model(),
5766
wipe=True,
5867
sitl_home="1,1,1,1",
5968
)
@@ -90,10 +99,18 @@ def vehicleinfo_key(self):
9099
return "ArduCopter"
91100
raise ValueError("Can't determine vehicleinfo_key from binary path")
92101

102+
def model(self):
103+
path = self.binary.lower()
104+
if "plane" in path:
105+
return "quadplane"
106+
if "copter" in path:
107+
return "X"
108+
raise ValueError("Can't determine vehicleinfo_key from binary path")
109+
93110
def run(self):
94111
self.start_SITL(
95112
binary=self.binary,
96-
model="novehicle",
113+
model=self.model(),
97114
sitl_home="1,1,1,1",
98115
wipe=False,
99116
)
@@ -243,6 +260,7 @@ def run(self):
243260

244261
self.run_git(["checkout", master_commit], show_output=False)
245262
self.run_git(["submodule", "update", "--recursive"], show_output=False)
263+
shutil.rmtree("build", ignore_errors=True)
246264
board = "sitl"
247265
if "AP_Periph" in self.vehicle:
248266
board = "sitl_periph_universal"
@@ -257,6 +275,7 @@ def run(self):
257275

258276
self.run_git(["checkout", branch], show_output=False)
259277
self.run_git(["submodule", "update", "--recursive"], show_output=False)
278+
shutil.rmtree("build", ignore_errors=True)
260279
util.build_SITL(
261280
self.build_target_name(self.vehicle),
262281
board=board,
@@ -281,12 +300,14 @@ def __init__(self,
281300
vehicles=None,
282301
run_eedump_before=False,
283302
run_eedump_after=False,
303+
master_branch="master",
284304
):
285305
self.vehicles = vehicles
286306
self.param_changes = param_changes
287307
self.vehicles = vehicles
288308
self.run_eedump_before = run_eedump_before
289309
self.run_eedump_after = run_eedump_after
310+
self.master_branch = master_branch
290311

291312
if self.vehicles is None:
292313
self.vehicles = self.all_vehicles()
@@ -310,6 +331,7 @@ def run(self):
310331
self.param_changes,
311332
run_eedump_before=self.run_eedump_before,
312333
run_eedump_after=self.run_eedump_after,
334+
master_branch=self.master_branch,
313335
)
314336
s.run()
315337

@@ -346,7 +368,12 @@ def run(self):
346368
default=False,
347369
help="run the (already-compiled) eedump tool on eeprom.bin after doing conversion",
348370
)
349-
371+
parser.add_argument(
372+
"--master-branch",
373+
type=str,
374+
default="master",
375+
help="master branch to use",
376+
)
350377
args = parser.parse_args()
351378

352379
param_changes = []
@@ -374,5 +401,6 @@ def run(self):
374401
vehicles=vehicles,
375402
run_eedump_before=args.run_eedump_before,
376403
run_eedump_after=args.run_eedump_after,
404+
master_branch=args.master_branch,
377405
)
378406
x.run()

0 commit comments

Comments
 (0)