-
Notifications
You must be signed in to change notification settings - Fork 30
Refactor and enhance V4L2 test suite #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -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 ---- | ||||||||||||||||||||||||||||||
|
|
@@ -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
|
||||||||||||||||||||||||||||||
| 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
AI
Feb 18, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.