mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
refactor mavsdk_tests: move code into separate classes & extract mavsdk-specifics
Allows it to be reused for other integration tests, like ros.
This commit is contained in:
-2
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
+8
-9
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import queue
|
import queue
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
@@ -9,7 +7,7 @@ import shutil
|
|||||||
import threading
|
import threading
|
||||||
import errno
|
import errno
|
||||||
from typing import Any, Dict, List, TextIO, Optional
|
from typing import Any, Dict, List, TextIO, Optional
|
||||||
from logger_helper import colorize, color
|
from .logger_helper import colorize, color
|
||||||
|
|
||||||
PX4_SITL_GAZEBO_PATH = "Tools/simulation/gazebo-classic/sitl_gazebo-classic"
|
PX4_SITL_GAZEBO_PATH = "Tools/simulation/gazebo-classic/sitl_gazebo-classic"
|
||||||
|
|
||||||
@@ -97,7 +95,7 @@ class Runner:
|
|||||||
|
|
||||||
def wait(self, timeout_min: float) -> Optional[int]:
|
def wait(self, timeout_min: float) -> Optional[int]:
|
||||||
try:
|
try:
|
||||||
return self.process.wait(timeout=timeout_min*60)
|
return self.process.wait(timeout=timeout_min * 60)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
print("Timeout of {} min{} reached, stopping...".
|
print("Timeout of {} min{} reached, stopping...".
|
||||||
format(timeout_min, "s" if timeout_min > 1 else ""))
|
format(timeout_min, "s" if timeout_min > 1 else ""))
|
||||||
@@ -153,11 +151,12 @@ class Runner:
|
|||||||
class Px4Runner(Runner):
|
class Px4Runner(Runner):
|
||||||
def __init__(self, workspace_dir: str, log_dir: str,
|
def __init__(self, workspace_dir: str, log_dir: str,
|
||||||
model: str, case: str, speed_factor: float,
|
model: str, case: str, speed_factor: float,
|
||||||
debugger: str, verbose: bool, build_dir: str):
|
debugger: str, verbose: bool, build_dir: str,
|
||||||
|
rootfs_base_dirname: str):
|
||||||
super().__init__(log_dir, model, case, verbose)
|
super().__init__(log_dir, model, case, verbose)
|
||||||
self.name = "px4"
|
self.name = "px4"
|
||||||
self.cwd = os.path.join(workspace_dir, build_dir,
|
self.cwd = os.path.join(workspace_dir, build_dir,
|
||||||
"tmp_mavsdk_tests/rootfs")
|
rootfs_base_dirname, "rootfs")
|
||||||
self.cmd = "nice"
|
self.cmd = "nice"
|
||||||
self.args = [
|
self.args = [
|
||||||
"--20",
|
"--20",
|
||||||
@@ -259,7 +258,7 @@ class GzserverRunner(Runner):
|
|||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if 'Connected to gazebo master' in line:
|
if 'Connected to gazebo master' in line:
|
||||||
return True
|
return True
|
||||||
time.sleep(float(timeout_s)/float(steps))
|
time.sleep(float(timeout_s) / float(steps))
|
||||||
|
|
||||||
print("gzserver did not connect within {}s"
|
print("gzserver did not connect within {}s"
|
||||||
.format(timeout_s))
|
.format(timeout_s))
|
||||||
@@ -321,7 +320,7 @@ class GzmodelspawnRunner(Runner):
|
|||||||
for _ in range(steps):
|
for _ in range(steps):
|
||||||
returncode = self.process.poll()
|
returncode = self.process.poll()
|
||||||
if returncode is None:
|
if returncode is None:
|
||||||
time.sleep(float(timeout_s)/float(steps))
|
time.sleep(float(timeout_s) / float(steps))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open(self.log_filename, 'r') as f:
|
with open(self.log_filename, 'r') as f:
|
||||||
@@ -355,7 +354,7 @@ class GzclientRunner(Runner):
|
|||||||
"--verbose"]
|
"--verbose"]
|
||||||
|
|
||||||
|
|
||||||
class TestRunner(Runner):
|
class TestRunnerMavsdk(Runner):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
workspace_dir: str,
|
workspace_dir: str,
|
||||||
log_dir: str,
|
log_dir: str,
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user