Skip to content

Commit

Permalink
autotest: add autotest for invalid battery backend checks
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Sep 26, 2024
1 parent bec2be6 commit 5073b01
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Tools/autotest/rover.py
Original file line number Diff line number Diff line change
Expand Up @@ -6845,6 +6845,37 @@ def met(self, m):
if len(requirements) == 0 and low_sats_seen and seen_bad_loc:
break

def BatteryInvalid(self):
'''check Battery prearms report useful data to user'''
self.start_subtest("Changing battery types makes no difference")
self.set_parameter("BATT_MONITOR", 0)
self.assert_prearm_failure("Battery 1 unhealthy", other_prearm_failures_fatal=False)
self.set_parameter("BATT_MONITOR", 4)
self.wait_ready_to_arm()

self.start_subtest("No battery monitor should be armable")
self.set_parameter("BATT_MONITOR", 0)
self.reboot_sitl()
self.wait_ready_to_arm()

self.set_parameter("BATT_MONITOR", 4)
self.assert_prearm_failure("Battery 1 unhealthy", other_prearm_failures_fatal=False)
self.reboot_sitl()
self.wait_ready_to_arm()

self.start_subtest("Invalid backend should have a clear error")
self.set_parameter("BATT_MONITOR", 98)
self.reboot_sitl()
self.assert_prearm_failure("Battery 1 unhealthy", other_prearm_failures_fatal=False)

self.start_subtest("Switching from an invalid backend to a valid backend should require a reboot")
self.set_parameter("BATT_MONITOR", 4)
self.assert_prearm_failure("Battery 1 unhealthy", other_prearm_failures_fatal=False)

self.start_subtest("Switching to None should NOT require a reboot")
self.set_parameter("BATT_MONITOR", 0)
self.wait_ready_to_arm()

def tests(self):
'''return list of all tests'''
ret = super(AutoTestRover, self).tests()
Expand Down Expand Up @@ -6941,6 +6972,7 @@ def tests(self):
self.RCDuplicateOptionsExist,
self.ClearMission,
self.JammingSimulation,
self.BatteryInvalid,
])
return ret

Expand Down

0 comments on commit 5073b01

Please sign in to comment.