Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup_workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ echo
# Clone L4T kernel source repo
cd $DEVDIR

# Check if local tar ball exists in ~/nvidia_sources_cache
NVIDIA_CACHE_DIR="$HOME/nvidia_sources_cache"
# Check if local tar ball exists in /home/nvidia_sources_cache
NVIDIA_CACHE_DIR="/home/nvidia_sources_cache"
Comment on lines +76 to +77

Copilot AI Feb 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coding NVIDIA_CACHE_DIR to "/home/nvidia_sources_cache" reduces portability (e.g., non-standard home locations, CI users without access to /home, or running as non-root). Consider keeping the previous $HOME-based default and/or allowing an override via an environment variable so the script works across environments.

Suggested change
# Check if local tar ball exists in /home/nvidia_sources_cache
NVIDIA_CACHE_DIR="/home/nvidia_sources_cache"
# Check if local tar ball exists in NVIDIA cache directory (default: \$HOME/nvidia_sources_cache)
: "${NVIDIA_CACHE_DIR:="${HOME:-/tmp}/nvidia_sources_cache"}"

Copilot uses AI. Check for mistakes.
TARBALL_NAME="backup_sources_$1.tar.gz"
TARBALL_PATH="$NVIDIA_CACHE_DIR/$TARBALL_NAME"

Expand Down
86 changes: 0 additions & 86 deletions test/run_ci.py

This file was deleted.

97 changes: 0 additions & 97 deletions test/test_fps.py

This file was deleted.

36 changes: 0 additions & 36 deletions test/test_fw_version.py

This file was deleted.

145 changes: 138 additions & 7 deletions test/v4l2_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .d4xx.discovery import discover_cameras
from .d4xx import constants as C
from .v4l2.device import V4L2Device
from .v4l2 import ioctls
from .report import D4xxReportPlugin


Expand Down Expand Up @@ -63,13 +64,16 @@ def camera(all_cameras, request):
def fw_version(camera):
"""Cached firmware version as (raw_int, version_string) tuple."""
with V4L2Device(camera.depth_path) as dev:
ctrl = dev.get_ctrl(C.DS5_CAMERA_CID_FW_VERSION)
raw = ctrl.value
major = (raw >> 24) & 0xFF
minor = (raw >> 16) & 0xFF
patch = (raw >> 8) & 0xFF
build = raw & 0xFF
return raw, f"{major}.{minor}.{patch}.{build}"
try:
ctrl = dev.get_ctrl(C.DS5_CAMERA_CID_FW_VERSION)
raw = ctrl.value
major = (raw >> 24) & 0xFF
minor = (raw >> 16) & 0xFF
patch = (raw >> 8) & 0xFF
build = raw & 0xFF
return raw, f"{major}.{minor}.{patch}.{build}"
except OSError:
pytest.skip("FW version control not available (tegra-video driver)")


# ---- Function-scoped device fixtures ----
Expand Down Expand Up @@ -108,3 +112,130 @@ def depth_md_device(camera):
dev.open()
yield dev
dev.close()


def _discrete_sizes(dev, pixfmt):
"""Return set of (w, h) for discrete frame sizes."""
return {
(s.discrete.width, s.discrete.height)
for s in dev.enum_framesizes(pixfmt)
if s.type == ioctls.V4L2_FRMSIZE_TYPE_DISCRETE
}


# ---- Cached common resolution discovery (used by pytest_generate_tests) ----

_common_res_cache = None


def _discover_common_resolutions():
"""Discover resolutions shared by depth (Z16) and RGB.

Returns ([(w,h), ...], rgb_pixfmt) or ([], None) if unavailable.
Cached after first call.
"""
global _common_res_cache
if _common_res_cache is not None:
return _common_res_cache

cameras = discover_cameras()
if not cameras:
_common_res_cache = ([], None)
return _common_res_cache

cam = cameras[0]
try:
Comment on lines +146 to +147

Copilot AI Feb 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_discover_common_resolutions() always uses the first discovered camera (cameras[0]) to enumerate frame sizes, which can diverge from the selected camera (via --device-index). This can parametrize resolution based on a different device than the one under test and cause false failures/skips. Use the selected camera (or pass it into the discovery helper) instead of hard-coding cameras[0].

Suggested change
cam = cameras[0]
try:
# Select the camera according to the configured --device-index option.
try:
device_index = pytest.config.getoption("--device-index")
except Exception:
device_index = 0
if not isinstance(device_index, int) or device_index < 0 or device_index >= len(cameras):
_common_res_cache = ([], None)
return _common_res_cache
cam = cameras[device_index]
try:

Copilot uses AI. Check for mistakes.
with V4L2Device(cam.depth_path) as ddev:
depth_sizes = _discrete_sizes(ddev, ioctls.V4L2_PIX_FMT_Z16)

with V4L2Device(cam.rgb_path) as rdev:
rgb_formats = rdev.enum_formats()
if not rgb_formats:
_common_res_cache = ([], None)
return _common_res_cache
rgb_pixfmt = rgb_formats[0].pixelformat
rgb_sizes = _discrete_sizes(rdev, rgb_pixfmt)

common = sorted(depth_sizes & rgb_sizes, key=lambda wh: wh[0] * wh[1])
_common_res_cache = (common, rgb_pixfmt)
except (OSError, Exception):
_common_res_cache = ([], None)

return _common_res_cache


@pytest.fixture(scope="session")
def common_depth_rgb_resolutions(camera):
"""Resolutions supported by both depth (Z16) and RGB on this camera."""
resolutions, rgb_pixfmt = _discover_common_resolutions()
if not resolutions:
pytest.skip("No common resolutions between depth and RGB")
return resolutions, rgb_pixfmt


# ---- Cached common depth+RGB+IR resolution discovery ----

_common_all_res_cache = None


def _discover_common_all_resolutions():
"""Discover resolutions shared by depth (Z16), RGB, and IR (GREY).

Returns ([(w,h), ...], rgb_pixfmt) or ([], None) if unavailable.
Cached after first call.
"""
global _common_all_res_cache
if _common_all_res_cache is not None:
return _common_all_res_cache

cameras = discover_cameras()
if not cameras:
_common_all_res_cache = ([], None)
return _common_all_res_cache

cam = cameras[0]
Comment on lines +192 to +196

Copilot AI Feb 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_discover_common_all_resolutions() also enumerates sizes on cameras[0] rather than the camera selected for the session. If multiple cameras are attached, this can generate tri_resolution parameters that the chosen camera doesn’t support. Consider basing enumeration on the camera fixture (or honoring --device-index) instead of defaulting to the first device.

Copilot uses AI. Check for mistakes.
try:
with V4L2Device(cam.depth_path) as ddev:
depth_sizes = _discrete_sizes(ddev, ioctls.V4L2_PIX_FMT_Z16)

with V4L2Device(cam.rgb_path) as rdev:
rgb_formats = rdev.enum_formats()
if not rgb_formats:
_common_all_res_cache = ([], None)
return _common_all_res_cache
rgb_pixfmt = rgb_formats[0].pixelformat
rgb_sizes = _discrete_sizes(rdev, rgb_pixfmt)

with V4L2Device(cam.ir_path) as idev:
ir_sizes = _discrete_sizes(idev, ioctls.V4L2_PIX_FMT_GREY)

common = sorted(
depth_sizes & rgb_sizes & ir_sizes,
key=lambda wh: wh[0] * wh[1],
)
_common_all_res_cache = (common, rgb_pixfmt)
except (OSError, Exception):
_common_all_res_cache = ([], None)

return _common_all_res_cache


@pytest.fixture(scope="session")
def common_depth_rgb_ir_resolutions(camera):
"""Resolutions supported by depth (Z16), RGB, and IR (GREY)."""
resolutions, rgb_pixfmt = _discover_common_all_resolutions()
if not resolutions:
pytest.skip("No common resolutions between depth, RGB, and IR")
return resolutions, rgb_pixfmt


def pytest_generate_tests(metafunc):
"""Dynamically parametrize resolution fixtures from hardware enumeration."""
if "resolution" in metafunc.fixturenames:
resolutions, _ = _discover_common_resolutions()
ids = [f"{w}x{h}" for w, h in resolutions]
metafunc.parametrize("resolution", resolutions, ids=ids)
if "tri_resolution" in metafunc.fixturenames:
resolutions, _ = _discover_common_all_resolutions()
ids = [f"{w}x{h}" for w, h in resolutions]
metafunc.parametrize("tri_resolution", resolutions, ids=ids)
Loading