Files
RedBear-OS/local/recipes/drivers/redbear-hid-core
vasilito 248434a84d redbear-hid-core: add parser integration tests (9 tests covering real HID shapes)
The HID 1.11 report-descriptor parser (redbear-hid-core) had 0 unit
tests. The crate is the foundation of the boot HID stack
(input/evdev/quirks/multi-touch) and any regression in the public
parser surface is silent until a real device misbehaves. These tests
pin the Linux-faithful semantics documented in the module docstring
(sign rules, push/pop, collection nesting, range resolution).

tests/parser.rs covers nine scenarios:

- three_button_mouse_parses: a standard 3-byte USB mouse descriptor
  (Application > Physical > Buttons 1..3 + 5-bit padding). Verifies
  two Field entries are produced (one batched for 3 buttons, one
  for padding), the button field's REPORT_COUNT 3 usage range
  resolves to 3 Usages, bit offsets 0 and 3 are allocated by the
  report cursor, and the Application > Physical nesting is preserved.
- keyboard_boot_parses: standard HID boot keyboard. Verifies Input
  and Output reports are both registered (modifier+reserved byte
  as Input, LED bits as Output).
- nested_collections_link: Application > Logical. Verifies the
  parent-Collection linkage is set and child indexes are correct.
- empty_returns_error: empty input yields EmptyDescriptor, not a panic.
- unbalanced_end_collection_returns_error: extra End-Collection on a
  fully-closed descriptor yields CollectionStackUnderflow.
- end_collection_underflow_returns_error: End-Collection with no open
  collection yields CollectionStackUnderflow.
- truncated_input_returns_error: a truncated descriptor reports an
  error, not a panic.
- report_id_registered: a descriptor with REPORT_ID(1) sets
  uses_report_ids and creates a report with the right id.
- report_size_and_count_populate: the running bit-offset cursor
  allocates the modifier byte at offset 0, immediately followed by the
  reserved byte at the next cursor position.

The tests live in  so they compile against the public API
only. Internal helper extensions (, ,
) live in the test file, kept minimal.

Test count: 9 passed, 0 failed. Previously 0.

Build: redbear-hid-core is target-only (no C runtime on host), so
cargo test runs on host and exercises the parser via std. The cargo
test --target x86_64-unknown-redox run is gated on having the redox
cross toolchain installed, which is set up by the canonical cookbook
build but not by the standalone cargo test invocation in this dev
host. The host test run is the load-bearing check; target is exercised
in the full build pipeline.
2026-07-25 15:59:34 +09:00
..