Skip to content

Add pure-Python HDMI RX (input) test to checkbox-provider-ce-oem (New)#2691

Open
seankingyang wants to merge 5 commits into
mainfrom
hdmirx_test
Open

Add pure-Python HDMI RX (input) test to checkbox-provider-ce-oem (New)#2691
seankingyang wants to merge 5 commits into
mainfrom
hdmirx_test

Conversation

@seankingyang

@seankingyang seankingyang commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

HDMI RX (input) is currently tested only through the proprietary
genio-test-tool.hdmi-rx-tool vendor binary, driven by pexpect/expect against
its interactive menu (baoshan + genio providers). OEMQA-6742 migrates this to a
pure-Python, stdlib-only test that talks to the kernel directly, behind a
pluggable per-platform backend, landing in checkbox-provider-ce-oem
(com.canonical.contrib). No vendor binary, no snap dependency.

Implementation (flat bin/hdmirx_*.py, Python 3.5-safe):

  • hdmirx_utils.py — platform-independent core: data models, the
    HdmiRxBackend contract, the Linux _IOC ioctl-number helpers, a reusable
    IoctlCharBackend base (open/ioctl/errno/abi_selfcheck/uevent plumbing
    lives here once), a stdlib netlink KOBJECT_UEVENT listener, and the
    verify_* helpers.
  • hdmirx_genio.pyGenioIoctlBackend for MediaTek Genio (/dev/hdmirx,
    magic 'H', module mtk_hdmirx). Declares only the ctypes structs, the
    command table and the field mappers — written from the ABI spec (ioctl
    numbers, struct fields, decode tables), not from the vendor source. Struct
    sizes are pinned by an abi-selfcheck (VID 40 / DEV 12 / AUD 28) that runs
    before any ioctl so an ABI drift fails loudly instead of returning garbage.
  • hdmirx_generic.pyV4L2Backend for mainline platforms, reading
    resolution/refresh through the stable VIDIOC_QUERY_DV_TIMINGS UAPI. Audio,
    enable/disable and source-change events raise NotImplementedError with the
    exact UAPI to wire up, rather than ship ctypes that no V4L2 target has yet
    validated.
  • hdmirx_tool.py — the only script the jobs call: auto-detects a backend
    (or --backend), runs one self-verifying sub-command per job, exits 0 on
    pass / 1 on fail, --json for machine-readable output.

Adding another custom-ioctl platform is a new flat hdmirx_<vendor>.py of
structs + COMMANDS + EVENT_MAP + _map_* — no plumbing rewritten.

Units (units/hdmi-rx/): the two suites live in their own job files,
v4l2.pxu and specific.pxu, alongside category, manifest and
test-plan:

  • v4l2 (generic): gated on manifest.has_hdmi_rx_v4l2; forced onto
    --backend v4l2; the three jobs the V4L2 backend supports today
    (module-detect, cable, video-info).
  • specific (per-platform): gated on manifest.has_hdmi_rx_specific. A
    ce-oem-hdmi-rx-backend resource job emits a single backend record from
    the HDMIRX_BACKEND environment variable (one backend per DUT, e.g.
    genio); jinja2 templates then generate the 7 jobs for that backend, with
    the backend name in the job id, summary and --backend argument. The jobs
    carry no environ:; the test plan selects them by template-id, and an
    unset HDMIRX_BACKEND yields no record and hence no specific jobs.

Both drop the old vendor-executable gate. Expected values (1920x1080@60,
24-bit/2-ch/48.0 kHz) and user: root are kept. The jobs carry
flags: also-after-suspend, which self-activates the after-suspend siblings,
so no separate after-suspend test plans are needed.

Data-format changes: none to the submission schema. New provider units and
two new manifest entries (has_hdmi_rx_v4l2, has_hdmi_rx_specific) only.

Resolved issues

Migrates https://warthogs.atlassian.net/browse/OEMQA-6742 (the accepted design
of record is in that card's description). On-hardware validation on a Genio
DUT is tracked before the epic closes (see Tests).

Documentation

No repository/Sphinx documentation is impacted. Each job carries its own
_summary / _purpose / _description; both manifest entries share one
_prompt so they group together on the manifest screen. The full design +
ABI reference lives in the OEMQA-6742 card.

Tests

Replace the proprietary genio-test-tool.hdmi-rx-tool vendor binary with a
pure-Python, stdlib-only HDMI RX test that talks to the kernel directly
behind a pluggable per-platform backend (OEMQA-6742).

bin/ (Python 3.5-safe: namedtuples, .format(), no annotations):
- hdmirx_utils.py: platform-independent core -- data models, Event enum,
  the HdmiRxBackend contract, the Linux _IOC ioctl-number helpers, a
  reusable IoctlCharBackend base (a new vendor is data + mappers only), a
  stdlib netlink KOBJECT_UEVENT listener, and the verify_* helpers.
- hdmirx_genio.py: Genio backend (/dev/hdmirx, magic 'H', mtk_hdmirx
  module) -- ctypes structs, command table and field mappers, written
  from the ABI spec rather than the vendor source. Struct sizes verified
  (VID 40, DEV 12, AUD 28) and ioctl numbers pinned by an abi-selfcheck.
- hdmirx_generic.py: mainline V4L2 backend using the stable UAPI
  VIDIOC_QUERY_DV_TIMINGS for video/presence; audio, enable and events
  raise NotImplementedError with the exact UAPI to wire up on a target.
- hdmirx_tool.py: the only script the jobs invoke -- auto-detects a
  backend (or --backend), one self-verifying sub-command per job, exit 0
  pass / 1 fail, optional --json.

units/hdmi-rx/: category, manifest (has_hdmi_rx), the 7 jobs with
ce-oem-hdmi-rx/ ids gated only on the manifest (no vendor executable),
and full/manual/automated test plans plus after-suspend variants.

tests/: 73 hardware-free unit tests (mocked ioctl/netlink) covering the
ioctl numbers, struct ABI, field decoders, netlink parser, verify_*
logic and CLI contract. Each asserts both pass and mismatch paths so a
hard-coded implementation would fail.
The ce-oem tox gate runs flake8 with the pep8-naming plugin, which
flags the ctypes structs and ioctl helpers that intentionally mirror
the external ABI verbatim: the kernel _IOC/_IOW/_IOR/_IOWR macros
(N802), the MTK HDMIRX_* C struct names and the V4L2 v4l2_* UAPI
struct names (N801). Renaming would break the 1:1 correspondence with
the vendor header, so suppress per-line instead. Also silence N812 on
the two short test-module aliases.
Copilot AI review requested due to automatic review settings July 15, 2026 10:08
@seankingyang seankingyang added the ce-oem The PR only contains to the ce-oem provider under the contrib area label Jul 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new HDMI RX (input) test suite to the checkbox-provider-ce-oem contrib provider, implemented as pure-Python tooling plus provider units (jobs, category, manifest, and test plans) and accompanied by hardware-free unit tests.

Changes:

  • Introduces new HDMI RX provider units (manifest entry, category, jobs, test plans) under units/hdmi-rx/.
  • Adds a pure-Python HDMI RX CLI (hdmirx_tool.py) and backend implementations (hdmirx_genio.py, hdmirx_generic.py) plus shared utilities (hdmirx_utils.py).
  • Adds comprehensive hardware-free unit tests covering ioctl encoding, backend behavior, V4L2 timing parsing, and CLI behavior.

Reviewed changes

Copilot reviewed 8 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/test-plan.pxu Adds HDMI RX full/manual/auto test plan units (including after-suspend variants).
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/manifest.pxu Adds has_hdmi_rx manifest entry used to gate HDMI RX jobs.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Adds HDMI RX jobs invoking hdmirx_tool.py for module/events/cable/video/audio/enable flows.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/category.pxu Adds a dedicated category for HDMI RX jobs.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/hdmirx_utils.py Implements shared models, ioctl helpers, uevent listener, and verification helpers.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/hdmirx_tool.py Implements the CLI orchestration and JSON/plain reporting used by provider jobs.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/hdmirx_genio.py Implements the Genio ioctl backend with ctypes structures and field mapping.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/hdmirx_generic.py Implements a generic V4L2 backend for reading DV timings (video/presence only).
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/tests/test_hdmirx_utils.py Adds unit tests for ioctl encoding, uevent parsing, and verify helpers.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/tests/test_hdmirx_tool.py Adds unit tests for CLI exit codes, orchestration, and JSON output.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/tests/test_hdmirx_genio.py Adds unit tests pinning Genio ABI struct sizes/ioctl numbers and mapping logic.
contrib/checkbox-ce-oem/checkbox-provider-ce-oem/tests/test_hdmirx_generic.py Adds unit tests for V4L2 struct sizes, frame-rate computation, and discovery logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/manifest.pxu Outdated
Make the manifest gates self-describing and separate the two ways of
testing HDMI RX:

- manifest: has_hdmi_rx (single) becomes has_hdmi_rx_v4l2 (generic
  mainline V4L2 path) and has_hdmi_rx_specific (a platform-specific
  backend).
- jobs: a v4l2 suite (module-detect, cable, video-info) forced onto
  --backend v4l2, and a specific suite (all 7 jobs) that selects the
  backend from $HDMIRX_BACKEND (environ) and errors if it is unset.
- test plans: separate ce-oem-hdmi-rx-v4l2-* and
  ce-oem-hdmi-rx-specific-* families plus after-suspend variants.
- hdmirx_tool.py: detect() now treats an empty --backend (unset
  HDMIRX_BACKEND) as a hard error instead of silently auto-detecting,
  and --backend is no longer restricted to a fixed choice list.
Apply the checkbox-job-plan patterns to the HDMI RX (input) units:

- Render the platform-specific templates with the jinja2 engine
  (template-engine: jinja2, {{ backend }}) so the backend name flows
  into the job id, summary, description and command.
- Keep each template-id static (<feature>-tests) and select the
  generated jobs from the test plan by template-id instead of
  generated-job regular expressions.
- Drop the redundant after-suspend test plans: the jobs already carry
  flags: also-after-suspend, which self-activates the after-suspend
  siblings when the original job is selected.
- Group both manifest entries under one shared _prompt so they appear
  together on the manifest screen; the distinguishing detail moves to
  _name.
- Remove the decorative section-banner comments from the bin/ scripts
  and pxu files, and de-duplicate the backend-name listing in detect().

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 12 changed files in this pull request and generated 1 comment.

Comment thread contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/hdmi-rx/jobs.pxu Outdated
- Move the generic V4L2 jobs to units/hdmi-rx/v4l2.pxu and the
  platform-specific resource + jinja2 templates to
  units/hdmi-rx/specific.pxu; drop the combined jobs.pxu so each suite
  lives in its own file.
- Simplify the ce-oem-hdmi-rx-backend resource command to a single-value
  echo guarded against an unset HDMIRX_BACKEND, replacing the
  space-separated awk loop (one backend per DUT, e.g. HDMIRX_BACKEND=genio).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 13 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ce-oem The PR only contains to the ce-oem provider under the contrib area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants