test(mavsdk): leave tests backwards compatible but enable SIH

This reverts some of the changes to keep runners of classic Gazebo in
there but leave it optional, so we can still use it if required.
This commit is contained in:
Julian Oes
2026-01-25 09:52:19 +13:00
committed by Ramon Roche
parent 69d17b14aa
commit eaaf6f676a
8 changed files with 79 additions and 33 deletions

View File

@@ -92,7 +92,7 @@ jobs:
PX4_HOME_LAT: ${{matrix.config.latitude}} PX4_HOME_LAT: ${{matrix.config.latitude}}
PX4_HOME_LON: ${{matrix.config.longitude}} PX4_HOME_LON: ${{matrix.config.longitude}}
PX4_HOME_ALT: ${{matrix.config.altitude}} PX4_HOME_ALT: ${{matrix.config.altitude}}
run: test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 10 --abort-early --model ${{matrix.config.model}} test/mavsdk_tests/configs/sitl.json --verbose --force-color run: test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 10 --abort-early --model ${{matrix.config.model}} test/mavsdk_tests/configs/gazebo-classic-sitl.json --verbose --force-color
timeout-minutes: 45 timeout-minutes: 45
- name: Upload failed logs - name: Upload failed logs

View File

@@ -491,16 +491,14 @@ rostest: px4_sitl_default
@$(MAKE) --no-print-directory px4_sitl_default sitl_gazebo-classic @$(MAKE) --no-print-directory px4_sitl_default sitl_gazebo-classic
tests_integration: px4_sitl_default tests_integration: px4_sitl_default
@$(MAKE) --no-print-directory px4_sitl_default sitl_gazebo-classic
@$(MAKE) --no-print-directory px4_sitl_default mavsdk_tests @$(MAKE) --no-print-directory px4_sitl_default mavsdk_tests
@"$(SRC_DIR)"/test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 test/mavsdk_tests/configs/sitl.json @"$(SRC_DIR)"/test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 test/mavsdk_tests/configs/sih-sitl.json
tests_integration_coverage: tests_integration_coverage:
@$(MAKE) clean @$(MAKE) clean
@$(MAKE) --no-print-directory px4_sitl_default PX4_CMAKE_BUILD_TYPE=Coverage @$(MAKE) --no-print-directory px4_sitl_default PX4_CMAKE_BUILD_TYPE=Coverage
@$(MAKE) --no-print-directory px4_sitl_default sitl_gazebo-classic
@$(MAKE) --no-print-directory px4_sitl_default mavsdk_tests @$(MAKE) --no-print-directory px4_sitl_default mavsdk_tests
@"$(SRC_DIR)"/test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 test/mavsdk_tests/configs/sitl.json @"$(SRC_DIR)"/test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 test/mavsdk_tests/configs/sih-sitl.json
@mkdir -p coverage @mkdir -p coverage
@lcov --directory build/px4_sitl_default --base-directory build/px4_sitl_default --gcov-tool gcov --capture -o coverage/lcov.info @lcov --directory build/px4_sitl_default --base-directory build/px4_sitl_default --gcov-tool gcov --capture -o coverage/lcov.info

View File

@@ -45,10 +45,10 @@ Install either from binaries or source:
## Run All PX4 Tests ## Run All PX4 Tests
To run all SITL tests as defined in [sitl.json](https://github.com/PX4/PX4-Autopilot/blob/main/test/mavsdk_tests/configs/sitl.json), do: To run all SITL tests using the SIH simulator as defined in [sih-sitl.json](https://github.com/PX4/PX4-Autopilot/blob/main/test/mavsdk_tests/configs/sih-sitl.json), do:
```sh ```sh
test/mavsdk_tests/mavsdk_test_runner.py test/mavsdk_tests/configs/sitl.json --speed-factor 10 test/mavsdk_tests/mavsdk_test_runner.py test/mavsdk_tests/configs/sih-sitl.json --speed-factor 10
``` ```
This will list all the tests and then run them sequentially. This will list all the tests and then run them sequentially.
@@ -87,10 +87,10 @@ options:
## Run a Single Test ## Run a Single Test
Run a single test by specifying the `model` and test `case` as command line options. Run a single test by specifying the `model` and test `case` as command line options.
For example, to test flying a tailsitter in a mission you might run: For example, to test a multicopter mission using the SIH simulator:
```sh ```sh
test/mavsdk_tests/mavsdk_test_runner.py test/mavsdk_tests/configs/sitl.json --speed-factor 10 --model tailsitter --case 'Fly VTOL mission' test/mavsdk_tests/mavsdk_test_runner.py test/mavsdk_tests/configs/sih-sitl.json --speed-factor 10 --model quadx --case 'Fly square Multicopter Missions including RTL'
``` ```
The easiest way to find out the current set of models and their associated test cases is to run all PX4 tests [as shown above](#run-all-px4-tests) (note, you can then cancel the build if you wish to test just one). The easiest way to find out the current set of models and their associated test cases is to run all PX4 tests [as shown above](#run-all-px4-tests) (note, you can then cancel the build if you wish to test just one).

View File

@@ -1,18 +1,17 @@
{ {
"mode": "sitl", "mode": "sitl",
"simulator": "gazebo", "simulator": "gazebo",
"model_prefix": "gazebo-classic_",
"mavlink_connection": "udpin://0.0.0.0:14540", "mavlink_connection": "udpin://0.0.0.0:14540",
"tests": "tests":
[ [
{ {
"model": "iris", "model": "iris",
"vehicle": "iris",
"test_filter": "[multicopter],[offboard],[offboard_attitude]", "test_filter": "[multicopter],[offboard],[offboard_attitude]",
"timeout_min": 10 "timeout_min": 10
}, },
{ {
"model": "iris", "model": "iris",
"vehicle": "iris",
"test_filter": "[offboard_attitude]", "test_filter": "[offboard_attitude]",
"timeout_min": 10, "timeout_min": 10,
"env": { "env": {
@@ -28,13 +27,11 @@
}, },
{ {
"model": "tailsitter", "model": "tailsitter",
"vehicle": "tailsitter",
"test_filter": "[vtol]", "test_filter": "[vtol]",
"timeout_min": 10 "timeout_min": 10
}, },
{ {
"model": "typhoon_h480", "model": "typhoon_h480",
"vehicle": "typhoon_h480",
"test_filter": "[controlallocation]", "test_filter": "[controlallocation]",
"timeout_min": 10 "timeout_min": 10
} }

View File

@@ -0,0 +1,27 @@
{
"mode": "sitl",
"model_prefix": "sihsim_",
"mavlink_connection": "udpin://0.0.0.0:14540",
"tests":
[
{
"model": "quadx",
"test_filter": "[multicopter],[offboard],[offboard_attitude]",
"timeout_min": 10
},
{
"model": "quadx",
"test_filter": "[offboard_attitude]",
"timeout_min": 10,
"env": {
"PX4_PARAM_EKF2_EN": 0,
"PX4_PARAM_ATT_EN": 1
}
},
{
"model": "standard_vtol",
"test_filter": "[vtol]",
"timeout_min": 10
}
]
}

View File

@@ -168,7 +168,7 @@ class Px4Runner(Runner):
os.path.join(workspace_dir, "test_data"), os.path.join(workspace_dir, "test_data"),
"-d" "-d"
] ]
self.env["PX4_SIM_MODEL"] = "sihsim_quadx" self.env["PX4_SIM_MODEL"] = 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.clear_rootfs()

View File

@@ -306,7 +306,7 @@ class Tester:
self.active_runners = [] self.active_runners = []
if self.config['mode'] == 'sitl': if self.config['mode'] == 'sitl':
if self.config['simulator'] == 'gazebo': if self.config.get('simulator') == 'gazebo':
# Use RegEx to extract worldname.world from case name # Use RegEx to extract worldname.world from case name
match = re.search(r'\((.*?\.world)\)', case) match = re.search(r'\((.*?\.world)\)', case)
if match: if match:
@@ -314,24 +314,52 @@ class Tester:
else: else:
world_name = 'empty.world' world_name = 'empty.world'
# We must start the PX4 instance at the end, as starting gzserver_runner = ph.GzserverRunner(
# it in the beginning, then connecting Gazebo server freaks
# out the PX4 (it needs to have data coming in when started),
# and can lead to EKF to freak out, or the instance itself
# to die unexpectedly.
px4_runner = ph.Px4Runner(
os.getcwd(), os.getcwd(),
log_dir, log_dir,
test['model'], test['model'],
case, case,
self.get_max_speed_factor(test), self.get_max_speed_factor(test),
self.debugger,
self.verbose, self.verbose,
self.build_dir, self.build_dir,
self.tester_interface.rootfs_base_dirname()) world_name)
for env_key in test.get('env', []): self.active_runners.append(gzserver_runner)
px4_runner.env[env_key] = str(test['env'][env_key])
self.active_runners.append(px4_runner) gzmodelspawn_runner = ph.GzmodelspawnRunner(
os.getcwd(),
log_dir,
test['model'],
case,
self.verbose,
self.build_dir)
self.active_runners.append(gzmodelspawn_runner)
if self.gui:
gzclient_runner = ph.GzclientRunner(
os.getcwd(),
log_dir,
test['model'],
case,
self.verbose)
self.active_runners.append(gzclient_runner)
# Determine PX4_SIM_MODEL using model_prefix from config
model_prefix = self.config.get('model_prefix', '')
px4_model = model_prefix + test['model']
px4_runner = ph.Px4Runner(
os.getcwd(),
log_dir,
px4_model,
case,
self.get_max_speed_factor(test),
self.debugger,
self.verbose,
self.build_dir,
self.tester_interface.rootfs_base_dirname())
for env_key in test.get('env', []):
px4_runner.env[env_key] = str(test['env'][env_key])
self.active_runners.append(px4_runner)
self.active_runners.append(self.tester_interface.create_test_runner( self.active_runners.append(self.tester_interface.create_test_runner(
os.getcwd(), os.getcwd(),

View File

@@ -136,11 +136,9 @@ def is_everything_ready(config: Dict[str, str], build_dir: str) -> bool:
result = False result = False
if not os.path.isfile(os.path.join(build_dir, 'bin/px4')): if not os.path.isfile(os.path.join(build_dir, 'bin/px4')):
print("PX4 SITL is not built\n" print("PX4 SITL is not built\n"
"run `DONT_RUN=1 " "run `DONT_RUN=1 make px4_sitl_default mavsdk_tests`")
"make px4_sitl gazebo mavsdk_tests` or "
"`DONT_RUN=1 make px4_sitl_default gazebo mavsdk_tests`")
result = False result = False
if config['simulator'] == 'gazebo': if config.get('simulator') == 'gazebo':
if is_running('gzserver'): if is_running('gzserver'):
print("gzserver process already running\n" print("gzserver process already running\n"
"run `killall gzserver` and try again") "run `killall gzserver` and try again")
@@ -153,9 +151,7 @@ def is_everything_ready(config: Dict[str, str], build_dir: str) -> bool:
if not os.path.isfile(os.path.join(build_dir, if not os.path.isfile(os.path.join(build_dir,
'mavsdk_tests/mavsdk_tests')): 'mavsdk_tests/mavsdk_tests')):
print("Test runner is not built\n" print("Test runner is not built\n"
"run `DONT_RUN=1 " "run `DONT_RUN=1 make px4_sitl_default mavsdk_tests`")
"make px4_sitl gazebo mavsdk_tests` or "
"`DONT_RUN=1 make px4_sitl_default gazebo mavsdk_tests`")
result = False result = False
return result return result