mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 02:23:35 +08:00
mavsdk_tests: use custom rootfs, reset it
Instead of messing with existing params, use a separate rootfs for tests, as suggested by @bkueng.
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import glob
|
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
@@ -326,8 +325,6 @@ class Tester:
|
|||||||
def run_test_case(self, test: Dict[str, Any],
|
def run_test_case(self, test: Dict[str, Any],
|
||||||
case: str, log_dir: str) -> bool:
|
case: str, log_dir: str) -> bool:
|
||||||
|
|
||||||
self.clear_params()
|
|
||||||
|
|
||||||
self.start_runners(log_dir, test, case)
|
self.start_runners(log_dir, test, case)
|
||||||
|
|
||||||
logfile_path = self.determine_logfile_path(log_dir, 'combined')
|
logfile_path = self.determine_logfile_path(log_dir, 'combined')
|
||||||
@@ -369,15 +366,6 @@ class Tester:
|
|||||||
print(" - {}".format(runner.get_log_filename()))
|
print(" - {}".format(runner.get_log_filename()))
|
||||||
return is_success
|
return is_success
|
||||||
|
|
||||||
def clear_params(self) -> None:
|
|
||||||
param_files = glob.glob(
|
|
||||||
"build/px4_sitl_default/tmp/rootfs/eeprom/parameters_*",
|
|
||||||
recursive=False)
|
|
||||||
for param_file in param_files:
|
|
||||||
if self.verbose:
|
|
||||||
print("Deleting param file: {}".format(param_file))
|
|
||||||
os.unlink(param_file)
|
|
||||||
|
|
||||||
def start_runners(self,
|
def start_runners(self,
|
||||||
log_dir: str,
|
log_dir: str,
|
||||||
test: Dict[str, Any],
|
test: Dict[str, Any],
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import time
|
|||||||
import os
|
import os
|
||||||
import atexit
|
import atexit
|
||||||
import subprocess
|
import subprocess
|
||||||
|
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
|
||||||
@@ -139,7 +140,8 @@ class Px4Runner(Runner):
|
|||||||
super().__init__(log_dir, model, case, verbose)
|
super().__init__(log_dir, model, case, verbose)
|
||||||
self.name = "px4"
|
self.name = "px4"
|
||||||
self.cmd = workspace_dir + "/build/px4_sitl_default/bin/px4"
|
self.cmd = workspace_dir + "/build/px4_sitl_default/bin/px4"
|
||||||
self.cwd = workspace_dir + "/build/px4_sitl_default/tmp/rootfs"
|
self.cwd = workspace_dir + \
|
||||||
|
"/build/px4_sitl_default/tmp_mavsdk_tests/rootfs"
|
||||||
self.args = [
|
self.args = [
|
||||||
workspace_dir + "/build/px4_sitl_default/etc",
|
workspace_dir + "/build/px4_sitl_default/etc",
|
||||||
"-s",
|
"-s",
|
||||||
@@ -151,6 +153,8 @@ class Px4Runner(Runner):
|
|||||||
self.env["PX4_SIM_MODEL"] = self.model
|
self.env["PX4_SIM_MODEL"] = self.model
|
||||||
self.env["PX4_SIM_SPEED_FACTOR"] = str(speed_factor)
|
self.env["PX4_SIM_SPEED_FACTOR"] = str(speed_factor)
|
||||||
self.debugger = debugger
|
self.debugger = debugger
|
||||||
|
self.clear_rootfs()
|
||||||
|
self.create_rootfs()
|
||||||
|
|
||||||
if not self.debugger:
|
if not self.debugger:
|
||||||
pass
|
pass
|
||||||
@@ -169,6 +173,19 @@ class Px4Runner(Runner):
|
|||||||
self.args = [self.cmd] + self.args
|
self.args = [self.cmd] + self.args
|
||||||
self.cmd = self.debugger
|
self.cmd = self.debugger
|
||||||
|
|
||||||
|
def clear_rootfs(self) -> None:
|
||||||
|
rootfs_path = self.cwd
|
||||||
|
if self.verbose:
|
||||||
|
print("Deleting rootfs: {}".format(rootfs_path))
|
||||||
|
if os.path.isdir(rootfs_path):
|
||||||
|
shutil.rmtree(rootfs_path)
|
||||||
|
|
||||||
|
def create_rootfs(self) -> None:
|
||||||
|
rootfs_path = self.cwd
|
||||||
|
if self.verbose:
|
||||||
|
print("Creating rootfs: {}".format(rootfs_path))
|
||||||
|
os.makedirs(rootfs_path)
|
||||||
|
|
||||||
|
|
||||||
class GzserverRunner(Runner):
|
class GzserverRunner(Runner):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
|||||||
Reference in New Issue
Block a user