From 6f1f98dc3cc7efe3d47bca588efb5dc0b20ba29e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 7 Feb 2019 10:24:52 +1100 Subject: [PATCH] Tools: autotest: add assumption run_tests is only called once - remove hasInit --- Tools/autotest/apmrover2.py | 3 --- Tools/autotest/arducopter.py | 2 -- Tools/autotest/arduplane.py | 2 -- Tools/autotest/ardusub.py | 3 --- Tools/autotest/common.py | 8 ++++++-- Tools/autotest/quadplane.py | 2 -- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Tools/autotest/apmrover2.py b/Tools/autotest/apmrover2.py index 51c757ab6f..17bcf391af 100644 --- a/Tools/autotest/apmrover2.py +++ b/Tools/autotest/apmrover2.py @@ -56,7 +56,6 @@ class AutoTestRover(AutoTest): self.speedup = speedup self.sitl = None - self.hasInit = False self.log_name = "APMrover2" @@ -96,8 +95,6 @@ class AutoTestRover(AutoTest): self.get_mavlink_connection_going() - self.hasInit = True - self.apply_defaultfile_parameters() self.progress("Ready to start testing!") diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index a79870cb81..92ad834288 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -61,7 +61,6 @@ class AutoTestCopter(AutoTest): self.log_name = "ArduCopter" self.sitl = None - self.hasInit = False def mavproxy_options(self): ret = super(AutoTestCopter, self).mavproxy_options() @@ -113,7 +112,6 @@ class AutoTestCopter(AutoTest): self.progress("Started simulator") - self.hasInit = True self.progress("Ready to start testing!") def close(self): diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index 02004eb3be..f4386f5880 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -50,7 +50,6 @@ class AutoTestPlane(AutoTest): self.speedup = speedup self.sitl = None - self.hasInit = False self.log_name = "ArduPlane" @@ -90,7 +89,6 @@ class AutoTestPlane(AutoTest): self.get_mavlink_connection_going() - self.hasInit = True self.progress("Ready to start testing!") def is_plane(self): diff --git a/Tools/autotest/ardusub.py b/Tools/autotest/ardusub.py index ff38c2e0e0..1238e0f29e 100644 --- a/Tools/autotest/ardusub.py +++ b/Tools/autotest/ardusub.py @@ -45,7 +45,6 @@ class AutoTestSub(AutoTest): self.speedup = speedup self.sitl = None - self.hasInit = False self.log_name = "ArduSub" @@ -86,8 +85,6 @@ class AutoTestSub(AutoTest): self.get_mavlink_connection_going() - self.hasInit = True - self.apply_defaultfile_parameters() # FIXME: diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index eaf2ccc8dd..bbe9b30cb9 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -168,6 +168,7 @@ class AutoTest(ABC): self.last_wp_load = 0 self.forced_post_test_sitl_reboots = 0 self.skip_list = [] + self.run_tests_called = False @staticmethod def progress(text): @@ -2040,8 +2041,11 @@ switch value''' def run_tests(self, tests): """Autotest vehicle in SITL.""" self.check_test_syntax(test_file=os.path.realpath(__file__)) - if not self.hasInit: - self.init() + if self.run_tests_called: + raise ValueError("run_tests called twice") + self.run_tests_called = True + + self.init() self.fail_list = [] diff --git a/Tools/autotest/quadplane.py b/Tools/autotest/quadplane.py index 24e3949faf..bdcc93ed15 100644 --- a/Tools/autotest/quadplane.py +++ b/Tools/autotest/quadplane.py @@ -48,7 +48,6 @@ class AutoTestQuadPlane(AutoTest): self.logfile = None self.sitl = None - self.hasInit = False def init(self): if self.frame is None: @@ -86,7 +85,6 @@ class AutoTestQuadPlane(AutoTest): self.get_mavlink_connection_going() - self.hasInit = True self.progress("Ready to start testing!") def is_plane(self):