From 47aea5f44ce83ab14a213e6f8d48c67ce892a0f8 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 1 Jan 2021 10:30:36 +1100 Subject: [PATCH] autotest: print stack traces for caught exceptions --- Tools/autotest/arducopter.py | 18 ++++++++++++++++++ Tools/autotest/arduplane.py | 4 ++++ Tools/autotest/rover.py | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index 8820b5f64c..51db5a006f 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -482,6 +482,8 @@ class AutoTestCopter(AutoTest): self.wait_disarmed() except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.context_pop() @@ -866,6 +868,8 @@ class AutoTestCopter(AutoTest): try: self.test_battery_failsafe(timeout=timeout) except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.set_parameter('BATT_LOW_VOLT', 0) @@ -1741,6 +1745,8 @@ class AutoTestCopter(AutoTest): self.set_parameter('SIM_SPEEDUP', old_speedup) self.do_RTL() except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.set_message_rate_hz(mavutil.mavlink.MAVLINK_MSG_ID_ATTITUDE, 0) sr = self.sitl_streamrate() @@ -1794,6 +1800,8 @@ class AutoTestCopter(AutoTest): self.wait_groundspeed(10, 100, timeout=60) except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.set_rc(2, 1500) @@ -2154,6 +2162,8 @@ class AutoTestCopter(AutoTest): else: raise NotAchievedException("Detected peak %.1f Hz %.2f dB" % (freq, peakdB)) except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.context_pop() @@ -4049,6 +4059,8 @@ class AutoTestCopter(AutoTest): raise except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.context_pop() @@ -4775,6 +4787,8 @@ class AutoTestCopter(AutoTest): raise NotAchievedException("Failed to maintain takeoff alt") self.progress("takeoff OK") except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.land_and_disarm() @@ -5689,6 +5703,8 @@ class AutoTestCopter(AutoTest): except Exception as e: self.disarm_vehicle(force=True) + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.context_pop() if ex is not None: @@ -6408,6 +6424,8 @@ class AutoTestHeli(AutoTestCopter): self.progress("takeoff OK") except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.land_and_disarm() diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index b0c44da3f4..f9c05d356c 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -791,6 +791,8 @@ class AutoTestPlane(AutoTest): self.progress("Flaps OK") except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.context_pop() if ex: @@ -1620,6 +1622,8 @@ class AutoTestPlane(AutoTest): raise NotAchievedException("Got collision message when I shouldn't have") except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.context_pop() self.reboot_sitl() diff --git a/Tools/autotest/rover.py b/Tools/autotest/rover.py index c5773ffe62..8a8622ed54 100644 --- a/Tools/autotest/rover.py +++ b/Tools/autotest/rover.py @@ -4893,6 +4893,8 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm) self.reboot_sitl() self.delay_sim_time(10) except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.remove_example_script(example_script) self.reboot_sitl() @@ -4935,6 +4937,8 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm) self.remove_example_script(script) except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.reboot_sitl() @@ -4969,6 +4973,8 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm) self.reboot_sitl() self.wait_statustext('hello, world', check_context=True, timeout=30) except Exception as e: + self.progress("Caught exception: %s" % + self.get_exception_stacktrace(e)) ex = e self.remove_example_script(example_script)