agentleFS
IntelRealSenseIntelRealSense/librealsense/.claude/skills/testing/SKILL.md

testing

Skill9.1k starsChanged 27 days agoApache-2.0View on GitHub

Run, filter and debug librealsense unit tests - pytest tests and the legacy C++ test runner (run-unit-tests.py), tags, devices, nightly/weekly contexts. Use before running tests.

194 other projects use a version of this.

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 1 mentionApr 2026: 0 mentionsMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the IntelRealSense/librealsense repository that our weekly crawl found. There is no adoption data for this file yet.

Most recently taken up by

Who's talking about IntelRealSense/librealsense

The biggest 5 of 81 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 81

Talked about on GitHub, Stack Overflow and Hacker News (81 times).

On GitHub · 48

43 more on GitHub

On Stack Overflow · 30

25 more on Stack Overflow

Used with

Projects with it also use bundle-dependency-prs, update-library-template and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    bundle-dependency-prs

    Fix broken dependency update PRs and aggregate the ones that work into one PR.

    Also in 7 projects that use this

  • MicrosoftSkill

    update-library-template

    Merges the latest Library.Template into this repo (at position of HEAD) and resolves conflicts.

    Also in 7 projects that use this

  • zetaloopSkill

    assign-copilot

    Assigns a GitHub issue to the Copilot coding agent, optionally specifying a custom agent. Use this when asked to assign an issue to Copilot or delegate an issue to CCA.

    Also in 3 projects that use this

  • NVIDIA-NeMoSkill

    build-and-dependency

    Dev environment setup for Megatron Bridge — container-based development, uv package management, lockfile regeneration, adding dependencies, Slurm container usage, and common build pitfalls.

    Also in 3 projects that use this

  • timmo001Skill

    changeset-scope

    Keep all scoped code work contained to the user-defined changeset. Use for implementation, fixes, diagnosis, refactoring, cleanup, and review when explicit instructions, named files, diffs, branches, pull requests, or injected work scopes define the boundary.

    Also in 3 projects that use this

  • JetBrainsSkill

    module-dependencies

    Add or modify IntelliJ module dependencies in `.iml` files.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 1 is distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 174 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Python 3: must be available

    line 15
  2. Very specific:

    No legacy test-*.py scripts remain, and run-unit-tests.py never collects pytest-*.py.

    line 26
  3. Very specific:

    Use -r / --regex to run tests whose names match a regular expression:

    line 91
  4. Very specific:

    Use --skip-regex to exclude tests whose names match:

    line 106
  5. Very specific:

    Use -t / --tag to run tests with a specific tag.

    line 114
  6. Very specific:

    Run tests only on a specific device (implies --live):

    line 127
  7. Very specific:

    If tests fail due to missing pyrealsense2, ensure -DBUILD_PYTHON_BINDINGS=ON was set during the CMake configure step

    line 241
  8. Very specific:

    Make sure you are running from the unit-tests/ directory

    line 243

“Common” is measured: kept by at least 6 in 10 of the 174 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Running Tests in librealsense

Prerequisites

  1. Build with tests and Python bindings enabled:
    cmake .. -DBUILD_UNIT_TESTS=ON -DBUILD_PYTHON_BINDINGS=ON
    cmake --build . --config Release
  2. Python 3 must be available
  3. The pyrealsense2 Python module must be built (ensured by -DBUILD_PYTHON_BINDINGS=ON)
  4. For live tests: an Intel RealSense device must be connected

Test Framework

Two frameworks, split by test language:

  • C++ tests (test-*.cpp) are orchestrated by the legacy runner unit-tests/run-unit-tests.py. Keeping that runner for C++ testing is its only remaining purpose.
  • Python tests (pytest-*.py) are pytest only. See the pytest-infra skill (.claude/skills/pytest-infra/SKILL.md). No legacy test-*.py scripts remain, and run-unit-tests.py never collects pytest-*.py.

Either way, run from the unit-tests/ directory.

Test Categories

DirectoryTypeDescription
unit-tests/live/Live (C++ & Python)Require a connected RealSense device
unit-tests/sw-dev/SoftwareSoftware-device tests, no hardware needed
unit-tests/dds/DDSDDS-related tests (require BUILD_WITH_DDS=ON)
unit-tests/algo/AlgorithmAlgorithm-level unit tests
unit-tests/post-processing/Post-processingPost-processing filter tests
unit-tests/syncer/SyncerFrame synchronization tests
unit-tests/3D/3DProjection and 3D-related tests
unit-tests/log/LoggingLogging infrastructure tests
unit-tests/types/TypesType system tests

Running the pytest Tests

cd unit-tests
python3 -m pytest -v                        # all collectable tests
python3 -m pytest -v live/frames            # one directory
python3 -m pytest -v pytest-fw-update.py    # one file
python3 -m pytest -v -k "hdr and not preset"   # filter by test name

Flags are registered in conftest.py: --live, --not-live, --device, --exclude-device, --context, --tag, --repeat, --reruns, --debug, --rslog, --test-dir, --device-map. Note that -s disables the per-test log files. See the pytest-infra skill (.claude/skills/pytest-infra/SKILL.md) for fixtures and markers.

Running the C++ Tests (legacy runner)

Navigate to the unit-tests/ directory and run:

cd unit-tests
python3 run-unit-tests.py -s

The -s flag directs test output to stdout. You can also specify the build output directory (required when both Debug and Release builds exist, to avoid ambiguity):

# When only one build configuration exists:
python3 run-unit-tests.py -s

# When both Debug and Release exist, specify the build output directory:
python3 run-unit-tests.py -s <build-output-dir>
# e.g., python3 run-unit-tests.py -s C:\work\git\librealsense\build\Release

For full usage and all available flags:

python3 run-unit-tests.py --help

Running Specific C++ Tests

The flags below belong to run-unit-tests.py, so they select among the C++ tests. For pytest use -k, -m and the flags listed above.

By Name (Regex)

Use -r / --regex to run tests whose names match a regular expression:

python3 run-unit-tests.py -s -r "test-log-vs-LOG"
python3 run-unit-tests.py -s --regex "rsutils-string.*"

Test name derivation: the orchestrator builds a test's name from its path relative to unit-tests/, replacing directory separators with - and stripping the leading test- from the filename. For example:

  • rsutils/string/test-hexarray.cpp becomes test-rsutils-string-hexarray
  • log/test-vs-LOG-shared.cpp becomes test-log-vs-LOG-shared

So when using -r, omit the test- filename prefix and join subdirectories with -.

Skip Tests by Name (Regex)

Use --skip-regex to exclude tests whose names match:

python3 run-unit-tests.py -s --skip-regex "test-rsutils-string-hexarray"

By Tag

Use -t / --tag to run tests with a specific tag. Tags come from:

  • File type: exe (C++ binaries). The py tag matches nothing now that no legacy test-*.py remain.
  • Directory location: e.g., tests in unit-tests/live/ get the live tag
  • An explicit //#test:tag <name> directive in the source file
python3 run-unit-tests.py -s -t live          # run only live tests
python3 run-unit-tests.py -s -t exe           # run only compiled C++ tests
python3 run-unit-tests.py -s -t live -t exe   # run tests that have BOTH tags

By Device

Run tests only on a specific device (implies --live):

python3 run-unit-tests.py -s --device "D435"
python3 run-unit-tests.py -s --device "D455"
python3 run-unit-tests.py -s --exclude-device "D405"

Live vs Non-Live

python3 run-unit-tests.py -s --live           # only tests requiring hardware
python3 run-unit-tests.py -s --not-live       # only tests that don't need hardware

Listing Available Tests and Tags

# List all available tests
python3 run-unit-tests.py --list-tests

# List all available tags
python3 run-unit-tests.py --list-tags

# List tests with their tags
python3 run-unit-tests.py --list-tests --list-tags

Output Control

python3 run-unit-tests.py -s               # direct output to stdout (not log files)
python3 run-unit-tests.py -v               # verbose — dump log on errors
python3 run-unit-tests.py -q               # quiet — rely on exit status only
python3 run-unit-tests.py --rslog          # enable LibRS debug logging in tests
python3 run-unit-tests.py --debug          # enable framework debug output; also prints "test took X seconds" per test

Running Nightly-Only and Weekly Tests

Both runners take --context, which accepts a space-separated list.

pytest tests gated with @pytest.mark.context("nightly") are skipped unless the context is passed:

python3 -m pytest -v live/hw-reset/pytest-stress.py --context nightly

A test that also scales its iteration count or timeout for weekly runs reads the context through the test_context_var fixture, so pass both words to get nightly collection plus weekly behaviour:

python3 -m pytest -v live/hw-reset/pytest-stress.py --context "nightly weekly"

C++ tests use a //#test:donotrun:<context> directive in the source file, evaluated by run-unit-tests.py against the same --context list.

Repeating and Retrying

python3 run-unit-tests.py --repeat 3       # repeat each test 3 times
python3 run-unit-tests.py --retry 2        # retry failed tests up to 2 times

python3 -m pytest --repeat 3               # pytest: repeat each file's tests 3 times
python3 -m pytest --reruns 2               # pytest: retry a failed test up to 2 times

Recording and Playback (Mock Hardware)

Tests can be recorded and replayed without a physical device:

# Record test execution to a file
./live-test into <filename>

# Replay tests from recorded data (no hardware needed)
./live-test from <filename>

This is useful for:

  • Debugging without a device
  • Distinguishing hardware issues from software bugs
  • Running tests in CI without physical cameras

CMake-Level Test Configuration

The UNIT_TESTS_ARGS CMake variable passes arguments to unit-test-config.py during configuration:

cmake .. -DBUILD_UNIT_TESTS=ON -DUNIT_TESTS_ARGS="-t live -r rsutils-string.*"

Using a Custom Test Directory

python3 run-unit-tests.py --test-dir /path/to/custom/tests

Custom Firmware for Testing

The SDK no longer ships a bundled firmware blob, so pytest-fw-update requires a custom firmware path for the device under test. Without one it skips. Download a signed .bin from https://dev.realsenseai.com/docs/firmware-updates, then:

python3 -m pytest pytest-fw-update.py --custom-fw-d400 /path/to/firmware.bin
python3 -m pytest pytest-fw-update.py --custom-fw-d555 /path/to/firmware.bin
python3 -m pytest pytest-fw-update.py --custom-fw-d585 /path/to/firmware.bin

--custom-fw-d585 targets the non-safety D585 only (e.g. "D585 Prototype"). The safety SKU is kept out of the test by pytest.mark.device_exclude("D585S"), so it is never collected and never flashed.

Troubleshooting

  • If tests fail due to missing pyrealsense2, ensure -DBUILD_PYTHON_BINDINGS=ON was set during the CMake configure step
  • BUILD_EASYLOGGINGPP must be ON (default) for unit tests to work
  • Make sure you are running from the unit-tests/ directory
  • For live tests, make sure the RealSense device is connected and accessible (on Linux, udev rules may need to be installed)
  • On Linux, you may need to run with appropriate permissions or install udev rules from config/

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.