autotest: move script helper functions from rover to common
This commit is contained in:
parent
3d562046da
commit
3eb164fb6a
@ -5612,6 +5612,41 @@ Also, ignores heartbeats not from our target system'''
|
|||||||
self.remove_message_hook(mh)
|
self.remove_message_hook(mh)
|
||||||
return statustext_full
|
return statustext_full
|
||||||
|
|
||||||
|
# routines helpful for testing LUA scripting:
|
||||||
|
def script_example_source_path(self, scriptname):
|
||||||
|
return os.path.join(self.rootdir(), "libraries", "AP_Scripting", "examples", scriptname)
|
||||||
|
|
||||||
|
def script_test_source_path(self, scriptname):
|
||||||
|
return os.path.join(self.rootdir(), "libraries", "AP_Scripting", "tests", scriptname)
|
||||||
|
|
||||||
|
def installed_script_path(self, scriptname):
|
||||||
|
return os.path.join("scripts", scriptname)
|
||||||
|
|
||||||
|
def install_script(self, source, scriptname):
|
||||||
|
dest = self.installed_script_path(scriptname)
|
||||||
|
destdir = os.path.dirname(dest)
|
||||||
|
if not os.path.exists(destdir):
|
||||||
|
os.mkdir(destdir)
|
||||||
|
self.progress("Copying (%s) to (%s)" % (source, dest))
|
||||||
|
shutil.copy(source, dest)
|
||||||
|
|
||||||
|
def install_example_script(self, scriptname):
|
||||||
|
source = self.script_example_source_path(scriptname)
|
||||||
|
self.install_script(source, scriptname)
|
||||||
|
|
||||||
|
def install_test_script(self, scriptname):
|
||||||
|
source = self.script_test_source_path(scriptname)
|
||||||
|
self.install_script(source, scriptname)
|
||||||
|
|
||||||
|
def remove_example_script(self, scriptname):
|
||||||
|
dest = self.installed_script_path(scriptname)
|
||||||
|
try:
|
||||||
|
os.unlink(dest)
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
def get_mavlink_connection_going(self):
|
def get_mavlink_connection_going(self):
|
||||||
# get a mavlink connection going
|
# get a mavlink connection going
|
||||||
try:
|
try:
|
||||||
|
@ -13,7 +13,6 @@ import copy
|
|||||||
import math
|
import math
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -4943,40 +4942,6 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
|
|||||||
target_component=target_component,
|
target_component=target_component,
|
||||||
)
|
)
|
||||||
|
|
||||||
def script_example_source_path(self, scriptname):
|
|
||||||
return os.path.join(self.rootdir(), "libraries", "AP_Scripting", "examples", scriptname)
|
|
||||||
|
|
||||||
def script_test_source_path(self, scriptname):
|
|
||||||
return os.path.join(self.rootdir(), "libraries", "AP_Scripting", "tests", scriptname)
|
|
||||||
|
|
||||||
def installed_script_path(self, scriptname):
|
|
||||||
return os.path.join("scripts", scriptname)
|
|
||||||
|
|
||||||
def install_script(self, source, scriptname):
|
|
||||||
dest = self.installed_script_path(scriptname)
|
|
||||||
destdir = os.path.dirname(dest)
|
|
||||||
if not os.path.exists(destdir):
|
|
||||||
os.mkdir(destdir)
|
|
||||||
self.progress("Copying (%s) to (%s)" % (source, dest))
|
|
||||||
shutil.copy(source, dest)
|
|
||||||
|
|
||||||
def install_example_script(self, scriptname):
|
|
||||||
source = self.script_example_source_path(scriptname)
|
|
||||||
self.install_script(source, scriptname)
|
|
||||||
|
|
||||||
def install_test_script(self, scriptname):
|
|
||||||
source = self.script_test_source_path(scriptname)
|
|
||||||
self.install_script(source, scriptname)
|
|
||||||
|
|
||||||
def remove_example_script(self, scriptname):
|
|
||||||
dest = self.installed_script_path(scriptname)
|
|
||||||
try:
|
|
||||||
os.unlink(dest)
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_scripting_simple_loop(self):
|
def test_scripting_simple_loop(self):
|
||||||
self.start_subtest("Scripting simple loop")
|
self.start_subtest("Scripting simple loop")
|
||||||
ex = None
|
ex = None
|
||||||
|
Loading…
Reference in New Issue
Block a user