autotest: Use contexts to control script lifetimes in networking tests

this way if the test gets an exception part-way through the scripts are removed from the directories appropriately
This commit is contained in:
Peter Barker 2024-01-03 13:24:13 +11:00 committed by Peter Barker
parent dd0a7a551b
commit 24f7ff7b61

View File

@ -6646,7 +6646,8 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
'''web server'''
applet_script = "net_webserver.lua"
self.install_applet_script(applet_script)
self.context_push()
self.install_applet_script_context(applet_script)
self.set_parameters({
"SCR_ENABLE": 1,
@ -6672,14 +6673,15 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
self.TestWebServer("http://127.0.0.1:8081")
self.context_pop()
self.remove_installed_script(applet_script)
self.context_pop()
self.reboot_sitl()
def NetworkingWebServerPPP(self):
'''web server over PPP'''
applet_script = "net_webserver.lua"
self.install_applet_script(applet_script)
self.context_push()
self.install_applet_script_context(applet_script)
self.set_parameters({
"SCR_ENABLE": 1,
@ -6718,7 +6720,7 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
self.TestWebServer("http://192.168.14.13:8081")
self.context_pop()
self.remove_installed_script(applet_script)
self.context_pop()
# restore rover without ppp enabled for next test
os.unlink('build/sitl/bin/ardurover')