mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 16:51:16 +08:00
ci(ros2): test PR firmware in the ROS development container
Build each PR firmware and matching ROS workspace from source against the digest-pinned Jazzy toolchain. Run the interface library unit and SIH integration suites without reusing stale firmware or generated messages. Assisted-by: Copilot:gpt-6-astra
This commit is contained in:
1 parent
f7052b281c
commit
b28ba0eedb
8 files changed
+231
-156
No files matched your search
@@ -1,21 +0,0 @@
|
||||
name: Build Gazebo Classic SITL
|
||||
description: Build PX4 firmware and Gazebo Classic plugins with ccache stats
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Build - PX4 Firmware (SITL)
|
||||
shell: bash
|
||||
run: make px4_sitl_default
|
||||
|
||||
- name: Cache - Stats after PX4 Firmware
|
||||
shell: bash
|
||||
run: ccache -s
|
||||
|
||||
- name: Build - Gazebo Classic Plugins
|
||||
shell: bash
|
||||
run: make px4_sitl_default sitl_gazebo-classic
|
||||
|
||||
- name: Cache - Stats after Gazebo Plugins
|
||||
shell: bash
|
||||
run: ccache -s
|
||||
@@ -1,144 +1,102 @@
|
||||
# NOTE: this workflow is now running on Dronecode / PX4 AWS account.
|
||||
# - If you want to keep the tests running in GitHub Actions you need to uncomment the "runs-on: ubuntu-latest" lines
|
||||
# and comment the "runs-on: [runs-on,runner=..." lines.
|
||||
# - If you would like to duplicate this setup try setting up "RunsOn" on your own AWS account try https://runs-on.com
|
||||
|
||||
name: ROS Integration Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
branches: [main]
|
||||
paths-ignore: ['docs/**']
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
branches: ['**']
|
||||
paths-ignore: ['docs/**']
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
px4_ros2_ref:
|
||||
description: 'Interface-library commit SHA; empty uses Tools/ros2/ros2.repos'
|
||||
type: string
|
||||
default: ''
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
|
||||
container:
|
||||
image: px4io/px4-dev-ros2-galactic:2021-09-08
|
||||
options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
|
||||
image: ghcr.io/px4/px4-dev-ros2:main-jazzy@sha256:975ade27fd951721bc1ca96519b004998358fa289d27b8c967548b8ab83d8689
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
env:
|
||||
PX4_SBOM_DISABLE: 1
|
||||
CMAKE_BUILD_PARALLEL_LEVEL: 8
|
||||
steps:
|
||||
- uses: runs-on/action@v2
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Configure Git Safe Directory
|
||||
run: git config --system --add safe.directory '*'
|
||||
- uses: runs-on/action@v2
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Update ROS Keys
|
||||
run: |
|
||||
sudo rm /etc/apt/sources.list.d/ros2.list && \
|
||||
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
|
||||
- name: Configure checkout ownership
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
|
||||
- name: Install gazebo
|
||||
run: |
|
||||
apt update && apt install -y gazebo11 libgazebo11-dev gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly libgstreamer-plugins-base1.0-dev
|
||||
- uses: ./.github/actions/setup-ccache
|
||||
id: ccache
|
||||
with:
|
||||
cache-key-prefix: ccache-ros-integration-jazzy-${{ runner.arch }}
|
||||
max-size: 1G
|
||||
|
||||
- uses: ./.github/actions/setup-ccache
|
||||
id: ccache
|
||||
with:
|
||||
cache-key-prefix: ccache-ros-integration
|
||||
max-size: 400M
|
||||
- name: Test ROS runner arguments
|
||||
run: python3 -m unittest discover -s test -p 'test_ros_test_runner.py'
|
||||
|
||||
- name: Cache - Restore Micro-XRCE-DDS Agent
|
||||
id: cache-xrce-agent
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: /opt/Micro-XRCE-DDS-Agent
|
||||
key: xrce-agent-v2.2.1-fastdds-2.8.2-galactic-2021-09-08
|
||||
- name: Build PR firmware
|
||||
run: |
|
||||
git rev-parse HEAD
|
||||
make px4_sitl_sih
|
||||
test -x build/px4_sitl_sih/bin/px4
|
||||
|
||||
- name: Build - Micro-XRCE-DDS Agent (v2.2.1)
|
||||
if: steps.cache-xrce-agent.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cd /opt
|
||||
git clone --recursive https://github.com/eProsima/Micro-XRCE-DDS-Agent.git
|
||||
cd Micro-XRCE-DDS-Agent
|
||||
git checkout v2.2.1 # recent versions require cmake 3.22, but px4-dev-ros2-galactic:2021-09-08 is on 3.16
|
||||
sed -i 's/_fastdds_tag 2.8.x/_fastdds_tag 2.8.2/g' CMakeLists.txt
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j2
|
||||
- name: Prepare matching ROS sources
|
||||
env:
|
||||
PX4_ROS2_REF: ${{ inputs.px4_ros2_ref }}
|
||||
run: |
|
||||
python3 Tools/ros2/prepare_workspace.py /opt/px4_ros2_ci "$PX4_ROS2_REF"
|
||||
|
||||
- name: Cache - Restore PX4 ROS 2 Interface Library Workspace
|
||||
id: cache-px4-ros2-ws
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: /opt/px4_ws
|
||||
# Bump 'v1' when the cached workspace layout changes in a way
|
||||
# that is not captured by the message/service hash below.
|
||||
key: px4-ros2-ws-v1-galactic-2021-09-08-${{ hashFiles('msg/*.msg', 'msg/versioned/*.msg', 'srv/*.srv') }}
|
||||
- name: Build ROS workspace
|
||||
run: |
|
||||
source /opt/ros/jazzy/setup.bash
|
||||
cd /opt/px4_ros2_ci
|
||||
sudo apt-get update -qq
|
||||
rosdep update --rosdistro jazzy
|
||||
rosdep install --from-paths src --ignore-src --rosdistro jazzy -y
|
||||
colcon build --symlink-install --executor sequential --cmake-args \
|
||||
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
colcon test --packages-select px4_ros2_cpp --ctest-args -R unit_tests
|
||||
colcon test-result --verbose
|
||||
|
||||
- name: Build - PX4 ROS 2 Interface Library
|
||||
if: steps.cache-px4-ros2-ws.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
PX4_DIR="$(pwd)"
|
||||
. /opt/ros/galactic/setup.bash
|
||||
mkdir -p /opt/px4_ws/src
|
||||
cd /opt/px4_ws/src
|
||||
# On a PR, target the branch we're merging into (main or release/X.Y).
|
||||
# On a direct push, fall back to the branch we're running on.
|
||||
BRANCH="${GITHUB_BASE_REF:-$GITHUB_REF_NAME}"
|
||||
REPO_URL="https://github.com/Auterion/px4-ros2-interface-lib.git"
|
||||
if git ls-remote --heads "$REPO_URL" "$BRANCH" | grep -q "$BRANCH"; then
|
||||
echo "Cloning px4-ros2-interface-lib with matching branch: $BRANCH"
|
||||
git clone --recursive --branch "$BRANCH" "$REPO_URL"
|
||||
else
|
||||
echo "Branch '$BRANCH' not found in px4-ros2-interface-lib, using default (main)"
|
||||
git clone --recursive "$REPO_URL"
|
||||
fi
|
||||
# Ignore python packages due to compilation issue (can be enabled when updating ROS)
|
||||
touch px4-ros2-interface-lib/px4_ros2_py/COLCON_IGNORE || true
|
||||
touch px4-ros2-interface-lib/examples/python/COLCON_IGNORE || true
|
||||
cd ..
|
||||
# Copy messages to ROS workspace
|
||||
"${PX4_DIR}/Tools/copy_to_ros_ws.sh" "$(pwd)"
|
||||
rm -rf src/translation_node src/px4_msgs_old
|
||||
colcon build --symlink-install
|
||||
- name: Run SIH integration tests
|
||||
run: |
|
||||
source /opt/px4_ros2_ci/install/setup.bash
|
||||
test/ros_test_runner.py --verbose --model quadx --force-color \
|
||||
--config-file test/ros_tests/config-sih.json \
|
||||
--build-dir build/px4_sitl_sih \
|
||||
--px4-ros2-interface-lib-build-dir /opt/px4_ros2_ci/build/px4_ros2_cpp \
|
||||
--log-dir logs/ros-sih
|
||||
timeout-minutes: 45
|
||||
|
||||
- uses: ./.github/actions/build-gazebo-sitl
|
||||
- uses: ./.github/actions/save-ccache
|
||||
if: always() && steps.ccache.outcome == 'success'
|
||||
with:
|
||||
cache-primary-key: ${{ steps.ccache.outputs.cache-primary-key }}
|
||||
|
||||
- name: Core dump settings
|
||||
run: |
|
||||
ulimit -c unlimited
|
||||
echo "`pwd`/%e.core" > /proc/sys/kernel/core_pattern
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
. /opt/px4_ws/install/setup.bash
|
||||
# The Agent is started (and restarted between tests) by ros_test_runner.py
|
||||
# so DDS graph state from a previous PX4 instance does not leak into the
|
||||
# next test. Make the Agent binary discoverable on PATH.
|
||||
export PATH="/opt/Micro-XRCE-DDS-Agent/build:$PATH"
|
||||
test/ros_test_runner.py --verbose --model iris --force-color
|
||||
timeout-minutes: 45
|
||||
|
||||
- uses: ./.github/actions/save-ccache
|
||||
if: always()
|
||||
with:
|
||||
cache-primary-key: ${{ steps.ccache.outputs.cache-primary-key }}
|
||||
|
||||
- name: Upload failed logs
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: failed-logs.zip
|
||||
path: |
|
||||
logs/**/**/**/*.log
|
||||
logs/**/**/**/*.ulg
|
||||
build/px4_sitl_default/tmp_ros_tests/rootfs/fs/log/**/*.ulg
|
||||
- name: Upload failed logs
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ros-integration-failed-logs
|
||||
path: |
|
||||
logs/**/**/**/*.log
|
||||
logs/**/**/**/*.ulg
|
||||
build/px4_sitl_sih/tmp_ros_tests/rootfs/fs/log/**/*.ulg
|
||||
/opt/px4_ros2_ci/log
|
||||
@@ -22,11 +22,11 @@ Tools/packaging/
|
||||
test_sih_mission.py
|
||||
Tools/ros2/
|
||||
prepare_workspace.py Checkout-matched ROS source workspace preparation
|
||||
ros2.repos Shared immutable source pins for ROS development images
|
||||
ros2.repos Shared immutable source pins for images and integration CI
|
||||
```
|
||||
|
||||
The generated `docker-context/` remains a flat staging directory; it is not the source layout.
|
||||
ROS workspace preparation is separate from packaging because it is also used for source development.
|
||||
ROS workspace preparation is separate from packaging because it is also used for development and integration tests.
|
||||
|
||||
## Build And Publish Flow
|
||||
|
||||
@@ -67,7 +67,7 @@ Every successful `RUN` creates a cacheable layer.
|
||||
A failed step is not committed as an image layer.
|
||||
Changing an input invalidates its layer and subsequent layers, not earlier ones.
|
||||
|
||||
`Tools/ros2/ros2.repos` pins the ROS repositories to immutable commits for ROS images.
|
||||
`Tools/ros2/ros2.repos` pins the ROS repositories to immutable commits for both images and integration tests.
|
||||
The interface-library pin includes the manual WaitSet ownership fixes merged in [Auterion/px4-ros2-interface-lib#222](https://github.com/Auterion/px4-ros2-interface-lib/pull/222).
|
||||
To test another interface-library commit in an image, pass `--set ros2.args.PX4_ROS2_REF=<40-hex-SHA>` to Bake.
|
||||
`PX4_MSGS_REF` can similarly override the message-package metadata; the definitions always come from the PX4 checkout.
|
||||
@@ -100,11 +100,11 @@ Cached installs do not automatically refresh upstream packages: rebuild without
|
||||
|
||||
Source pins are maintained manually through reviewed pull requests, not advanced automatically when images are built.
|
||||
Update the full commit SHA in `Tools/ros2/ros2.repos` when adopting upstream changes.
|
||||
Run the container builds before accepting an update.
|
||||
The same manifest is consumed by both container builds and ROS integration CI; run both workflows before accepting an update.
|
||||
|
||||
The `px4_msgs` pin selects package metadata and build logic, not the message definitions used to build the workspace.
|
||||
Definitions always come from the PX4 checkout, so ordinary message changes do not require a pin update.
|
||||
Image and workspace-helper SHA overrides are for testing candidates; adopting a candidate requires updating the shared manifest.
|
||||
Image and workflow SHA overrides are for testing candidates; adopting a candidate requires updating the shared manifest.
|
||||
|
||||
## Testing A PX4 Checkout With ROS
|
||||
|
||||
@@ -118,6 +118,8 @@ Pushing a `v*` Git tag publishes `<git-tag>-jazzy`, such as `v1.18.0-jazzy`, wit
|
||||
Each publication also provides `sha-<full-PX4-commit>-jazzy`, identifying the repository revision used to build the toolchain.
|
||||
Release-line toolchains can use tags such as `v1.18-jazzy` through the manual publisher's `tag` input when that release line is maintained.
|
||||
The source revision and intended PX4 release line do not change which firmware a checkout builds.
|
||||
ROS integration CI pins the image by digest so publishing a new moving tag cannot silently change the test environment.
|
||||
When adopting a rebuilt toolchain, update the digest in `.github/workflows/ros_integration_tests.yml`.
|
||||
|
||||
The optional `ros2-dev` Bake target builds this image without `.deb` packages or a published SITL parent:
|
||||
|
||||
@@ -153,6 +155,9 @@ colcon test --packages-select px4_ros2_cpp --ctest-args -R unit_tests
|
||||
colcon test-result --verbose
|
||||
source install/setup.bash
|
||||
cd "$PX4_DIR"
|
||||
python3 test/ros_test_runner.py --config-file test/ros_tests/config-sih.json \
|
||||
--build-dir build/px4_sitl_sih --model quadx \
|
||||
--px4-ros2-interface-lib-build-dir /opt/px4_ros2_ci/build/px4_ros2_cpp
|
||||
```
|
||||
|
||||
The workspace helper requires a new or empty directory, imports the standard `ros2.repos` manifest with vcstool, and replaces message/service definitions with those from the current PX4 checkout, including removal of deleted definitions.
|
||||
@@ -161,6 +166,11 @@ It preserves all library packages, examples and Python tests.
|
||||
An optional second argument selects another interface-library commit using its full 40-character SHA.
|
||||
The helper prints the resolved source manifest, repository commits and PX4 commit; it does not build the workspace.
|
||||
|
||||
ROS integration CI builds PX4 afresh for each pull request and only sources the Jazzy underlay before building this separate workspace.
|
||||
Its manual `px4_ros2_ref` input selects a full interface-library commit SHA; leaving it empty uses `ros2.repos`.
|
||||
CI prepares and builds the ROS workspace on every run using the current checkout's message/service definitions.
|
||||
Only the compiler cache is restored, not an old source, build or install workspace.
|
||||
Ccache validates compiler contents and compilation inputs, including changed library sources and generated messages.
|
||||
`CACHE_GHA=true` uses an independent `ros2-dev-<architecture>` image cache, without replacing the published SITL image caches.
|
||||
The `ros_dev_container.yml` workflow builds the standalone target on every `main` push and on pull requests that change its watched paths, without publishing.
|
||||
It publishes to GHCR only on `v*` tag pushes or manual runs with `deploy_to_registry=true`.
|
||||
@@ -168,7 +178,7 @@ Manual runs use the `tag` input, which defaults to `main-jazzy`; the deployment
|
||||
Architecture tags use `sha-<full-PX4-commit>-jazzy-<architecture>`; the final selected tag and `sha-<full-PX4-commit>-jazzy` indexes preserve both architectures and their SBOMs.
|
||||
Use `--set ros2-dev.args.PX4_ROS2_REF=<40-hex-SHA>` to build the development image with another interface-library commit.
|
||||
|
||||
Both ROS development images reuse `Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools` and its Python requirements.
|
||||
Both ROS development images and the CI toolchain reuse `Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools` and its Python requirements.
|
||||
Already installed Ubuntu/Jazzy Python versions are constrained during installation instead of gratuitously upgrading the ROS stack.
|
||||
The SIH image does not acquire Gazebo or the NuttX toolchain.
|
||||
Installing the complete source-build toolset increases cold image-build time and size; existing native architecture and incremental cache boundaries remain in use.
|
||||
|
||||
@@ -176,6 +176,7 @@ When testing modified PX4 firmware, rebuild the ROS workspace against its messag
|
||||
Use `--entrypoint /bin/bash` and source `/opt/ros/jazzy/setup.bash` to start without the bundled workspace.
|
||||
For source builds and selecting an interface-library commit, see [Testing A PX4 Checkout With ROS](../dev_setup/sitl_container_builds.md#testing-a-px4-checkout-with-ros).
|
||||
The standalone `ghcr.io/px4/px4-dev-ros2:main-jazzy` toolchain provides the build tools and ROS dependencies without bundled source checkouts, firmware or a compiled workspace.
|
||||
ROS integration CI uses this toolchain, builds PX4 from the pull request, and regenerates messages from that checkout.
|
||||
|
||||
#### Go-To Example
|
||||
|
||||
|
||||
@@ -7,15 +7,24 @@ These test that mode registration, failsafes, and mode replacement, work as expe
|
||||
## CI Testing
|
||||
|
||||
When opening a pull request to PX4, CI runs the library integration tests.
|
||||
It builds the pull request's PX4 firmware and a matching ROS workspace, then runs the tests using [SIH](../sim_sih/index.md).
|
||||
SIH runs the physics simulation inside PX4 and does not require Gazebo Classic or Gazebo Harmonic.
|
||||
|
||||
## Running Tests Locally
|
||||
|
||||
The tests can also be run locally from PX4:
|
||||
Follow [Testing A PX4 Checkout With ROS](../dev_setup/sitl_container_builds.md#testing-a-px4-checkout-with-ros) to build `px4_sitl_sih` and a matching ROS workspace.
|
||||
Run the following commands from the PX4 repository root, inside the ROS development environment:
|
||||
|
||||
```sh
|
||||
```bash
|
||||
source /opt/px4_ros2_ci/install/setup.bash
|
||||
./test/ros_test_runner.py
|
||||
```
|
||||
|
||||
If you used another workspace location, source its `install/setup.bash` instead.
|
||||
The runner defaults to `test/ros_tests/config-sih.json` and `build/px4_sitl_sih/`, matching CI.
|
||||
The SIH configuration selects the `quadx` model for all three integration suites.
|
||||
SIH does not support the runner's `--gui` option.
|
||||
|
||||
And to run only a single case:
|
||||
|
||||
```sh
|
||||
@@ -27,3 +36,17 @@ You can list the available test cases with:
|
||||
```sh
|
||||
./test/ros_test_runner.py --list-cases
|
||||
```
|
||||
|
||||
## Legacy Gazebo Classic Testing
|
||||
|
||||
For an existing Gazebo Classic setup, select both its configuration and firmware build directory explicitly:
|
||||
|
||||
```sh
|
||||
./test/ros_test_runner.py \
|
||||
--config-file test/ros_tests/config.json \
|
||||
--build-dir build/px4_sitl_default/ \
|
||||
--model iris
|
||||
```
|
||||
|
||||
This requires separately built Gazebo Classic plugins and matching ROS sources.
|
||||
The Gazebo Harmonic containers do not provide Gazebo Classic.
|
||||
+31
-9
@@ -114,7 +114,7 @@ class TesterInterfaceRos(test_runner.TesterInterface):
|
||||
return "tmp_ros_tests"
|
||||
|
||||
|
||||
def main() -> NoReturn:
|
||||
def create_argument_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--list-cases", action='store_true',
|
||||
help="List available test cases")
|
||||
@@ -139,15 +139,23 @@ def main() -> NoReturn:
|
||||
help="Force colorized output")
|
||||
parser.add_argument("--verbose", default=False, action='store_true',
|
||||
help="enable more verbose output")
|
||||
parser.add_argument("--config-file", help="JSON config file to use",
|
||||
default="test/ros_tests/config.json")
|
||||
parser.add_argument("--config-file",
|
||||
help="JSON config file to use "
|
||||
"(default: test/ros_tests/config-sih.json)",
|
||||
default="test/ros_tests/config-sih.json")
|
||||
parser.add_argument("--build-dir", type=str,
|
||||
default='build/px4_sitl_default/',
|
||||
help="relative path where the built files are stored")
|
||||
default='build/px4_sitl_sih/',
|
||||
help="relative path where the built files are stored "
|
||||
"(default: build/px4_sitl_sih/)")
|
||||
parser.add_argument("--px4-ros2-interface-lib-build-dir", type=str,
|
||||
default=None,
|
||||
help="path which contains the integration_tests binary. "
|
||||
"If not provided, it is determined via 'ros2 pkg'")
|
||||
return parser
|
||||
|
||||
|
||||
def main() -> NoReturn:
|
||||
parser = create_argument_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.force_color:
|
||||
@@ -174,6 +182,9 @@ def main() -> NoReturn:
|
||||
.format(config["mode"]))
|
||||
sys.exit(1)
|
||||
|
||||
if config.get("simulator") == "sih" and args.gui:
|
||||
parser.error("--gui is not supported by the SIH backend")
|
||||
|
||||
if not is_everything_ready(config, args.build_dir):
|
||||
sys.exit(1)
|
||||
|
||||
@@ -197,6 +208,12 @@ def main() -> NoReturn:
|
||||
args.build_dir,
|
||||
tester_interface
|
||||
)
|
||||
empty_filters = [test['test_filter'] for test in tester.tests
|
||||
if test['selected'] and not test['cases']]
|
||||
if empty_filters:
|
||||
parser.error("Configured test filters matched no cases: " + ", ".join(empty_filters))
|
||||
if tester.num_cases() == 0:
|
||||
parser.error("No test cases selected; check --config-file, --model and --case")
|
||||
signal.signal(signal.SIGINT, tester.sigint_handler)
|
||||
|
||||
# Automatically start & stop the XRCE Agent if not running already
|
||||
@@ -234,11 +251,16 @@ def is_everything_ready(config: Dict[str, str], build_dir: str) -> bool:
|
||||
"run `killall px4` and try again")
|
||||
result = False
|
||||
if not os.path.isfile(os.path.join(build_dir, 'bin/px4')):
|
||||
print("PX4 SITL is not built\n"
|
||||
"run `DONT_RUN=1 make px4_sitl gazebo` or "
|
||||
"`DONT_RUN=1 make px4_sitl_default gazebo`")
|
||||
if config.get('simulator') == 'sih':
|
||||
print("PX4 SIH SITL is not built\n"
|
||||
"run `make px4_sitl_sih` and use "
|
||||
"`--build-dir build/px4_sitl_sih`")
|
||||
else:
|
||||
print("PX4 SITL is not built\n"
|
||||
"run `DONT_RUN=1 make px4_sitl gazebo` or "
|
||||
"`DONT_RUN=1 make px4_sitl_default gazebo`")
|
||||
result = False
|
||||
if config['simulator'] == 'gazebo':
|
||||
if config.get('simulator') == 'gazebo':
|
||||
if is_running('gzserver'):
|
||||
print("gzserver process already running\n"
|
||||
"run `killall gzserver` and try again")
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"mode": "sitl",
|
||||
"simulator": "sih",
|
||||
"model_prefix": "sihsim_",
|
||||
"tests":
|
||||
[
|
||||
{
|
||||
"model": "quadx",
|
||||
"vehicle": "quadx",
|
||||
"test_filter": "ModesTest.*",
|
||||
"timeout_min": 10
|
||||
},
|
||||
{
|
||||
"model": "quadx",
|
||||
"vehicle": "quadx",
|
||||
"test_filter": "LocalPositionInterfaceTest.*",
|
||||
"timeout_min": 10,
|
||||
"env": {
|
||||
"PX4_PARAM_EKF2_EV_CTRL": 15
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "quadx",
|
||||
"vehicle": "quadx",
|
||||
"test_filter": "GlobalPositionInterfaceTest.*",
|
||||
"timeout_min": 10,
|
||||
"env": {
|
||||
"PX4_PARAM_EKF2_AGP0_ID": 1,
|
||||
"PX4_PARAM_EKF2_AGP0_CTRL": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
import ros_test_runner
|
||||
|
||||
|
||||
class RosTestRunnerArgumentsTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.parser = ros_test_runner.create_argument_parser()
|
||||
self.repo = Path(__file__).resolve().parents[1]
|
||||
|
||||
def test_defaults_select_sih_firmware_and_suites(self):
|
||||
args = self.parser.parse_args([])
|
||||
self.assertEqual(args.config_file, "test/ros_tests/config-sih.json")
|
||||
self.assertEqual(args.build_dir, "build/px4_sitl_sih/")
|
||||
self.assertEqual(args.model, "all")
|
||||
config = json.loads((self.repo / args.config_file).read_text())
|
||||
self.assertEqual(config["simulator"], "sih")
|
||||
self.assertEqual(config["model_prefix"], "sihsim_")
|
||||
self.assertEqual(
|
||||
{test["model"] for test in config["tests"]}, {"quadx"}
|
||||
)
|
||||
self.assertEqual(len(config["tests"]), 3)
|
||||
|
||||
def test_classic_remains_an_explicit_option(self):
|
||||
args = self.parser.parse_args([
|
||||
"--config-file", "test/ros_tests/config.json",
|
||||
"--build-dir", "build/px4_sitl_default/",
|
||||
"--model", "iris", "--gui",
|
||||
])
|
||||
config = json.loads((self.repo / args.config_file).read_text())
|
||||
self.assertEqual(config["simulator"], "gazebo")
|
||||
self.assertEqual(config["model_prefix"], "gazebo-classic_")
|
||||
self.assertEqual(args.build_dir, "build/px4_sitl_default/")
|
||||
self.assertEqual(args.model, "iris")
|
||||
self.assertTrue(args.gui)
|
||||
|
||||
def test_case_filter_and_custom_build_directory(self):
|
||||
args = self.parser.parse_args([
|
||||
"--case", "ModesTest.*", "--build-dir", "/tmp/custom-sih",
|
||||
])
|
||||
self.assertEqual(args.case, "ModesTest.*")
|
||||
self.assertEqual(args.build_dir, "/tmp/custom-sih")
|
||||
self.assertEqual(args.config_file, "test/ros_tests/config-sih.json")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user