diff --git a/test/mavsdk_tests/mavsdk_test_runner.py b/test/mavsdk_tests/mavsdk_test_runner.py index 9c8148b33b..4360202070 100755 --- a/test/mavsdk_tests/mavsdk_test_runner.py +++ b/test/mavsdk_tests/mavsdk_test_runner.py @@ -3,7 +3,6 @@ import argparse import datetime import fnmatch -import glob import json import math import os @@ -326,8 +325,6 @@ class Tester: def run_test_case(self, test: Dict[str, Any], case: str, log_dir: str) -> bool: - self.clear_params() - self.start_runners(log_dir, test, case) logfile_path = self.determine_logfile_path(log_dir, 'combined') @@ -369,15 +366,6 @@ class Tester: print(" - {}".format(runner.get_log_filename())) 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, log_dir: str, test: Dict[str, Any], diff --git a/test/mavsdk_tests/process_helper.py b/test/mavsdk_tests/process_helper.py index 1f3a205071..5c35a20d40 100644 --- a/test/mavsdk_tests/process_helper.py +++ b/test/mavsdk_tests/process_helper.py @@ -5,6 +5,7 @@ import time import os import atexit import subprocess +import shutil import threading import errno from typing import Any, Dict, List, TextIO, Optional @@ -139,7 +140,8 @@ class Px4Runner(Runner): super().__init__(log_dir, model, case, verbose) self.name = "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 = [ workspace_dir + "/build/px4_sitl_default/etc", "-s", @@ -151,6 +153,8 @@ class Px4Runner(Runner): self.env["PX4_SIM_MODEL"] = self.model self.env["PX4_SIM_SPEED_FACTOR"] = str(speed_factor) self.debugger = debugger + self.clear_rootfs() + self.create_rootfs() if not self.debugger: pass @@ -169,6 +173,19 @@ class Px4Runner(Runner): self.args = [self.cmd] + self.args 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): def __init__(self,