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:
Julian Oes 2020-09-01 15:15:36 +02:00 committed by Daniel Agar
parent 517114042a
commit e7651c94f6
2 changed files with 18 additions and 13 deletions

View File

@ -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],

View File

@ -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,