Skip to content

selftests: add matrix validation for dtb and detect duplicated compatibles #2273

Merged
ricardosalveti merged 3 commits into
qualcomm-linux:masterfrom
ricardosalveti:selftest
May 26, 2026
Merged

selftests: add matrix validation for dtb and detect duplicated compatibles #2273
ricardosalveti merged 3 commits into
qualcomm-linux:masterfrom
ricardosalveti:selftest

Conversation

@ricardosalveti
Copy link
Copy Markdown
Contributor

Add QcomFitImageMatrixTests class with two test methods to validate DTB coverage without full image builds and two tests to QcomFitImageMatrixTests that catch mistakes like those fixed in PR #2236.

FIT_DTB_COMPATIBLE[sa8775p-ride-camx] and
FIT_DTB_COMPATIBLE[sa8775p-ride-camx+lemans-staging] produced the same
compatible strings (qcom,sa8775p-qam-camx and qcom,sa8775p-qam-camx-staging)
as the existing composite-key entries:

  FIT_DTB_COMPATIBLE[sa8775p-ride+sa8775p-ride-camx]
  FIT_DTB_COMPATIBLE[sa8775p-ride+sa8775p-ride-camx+lemans-staging]

Duplicate compatible strings cause UEFI firmware to stop at the first ITS
match, potentially selecting the wrong DTB configuration at boot. Remove
the two redundant standalone entries, which are also incorrect as
sa8775p-ride-camx is just the overlay.

Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>
…roviders

Add QcomFitImageMatrixTests class with two test methods to validate DTB
coverage without full image builds:

- test_machine_dtb_entries_exist_for_kernel_providers: validates all
  machine/kernel DTB combinations have corresponding sources via lightweight
  bitbake -c unpack and kernel source tree parsing. Detects available qcom
  kernel providers (linux-qcom, linux-qcom-next) and cross-validates against
  kernel KERNEL_DEVICETREE and LINUX_QCOM_KERNEL_DEVICETREE metadata.

- test_fit_dtb_compatible_keys_exist_in_kernel_sources: validates all
  FIT_DTB_COMPATIBLE keys in conf/machine/include/fit-dtb-compatible.inc map
  to real DTB/DTBO files in kernel sources. Supports both single-part keys
  (either .dtb or .dtbo) and composite keys with base DTB + overlay DTBOs.

Implementation includes:
- Require LAYERDIR_qcom from bitbake metadata (hard-fail if undefined)
- Assume linux-yocto is always present via oe-core dependency
- Restrict DTS scanning to architecture DT roots:
  arch/arm64/boot/dts and arch/arm/boot/dts
- Recursively scan only those DT roots (not the full kernel source tree)
- Cache provider output files and availability across test runs
- Handle machine incompatibilities with linux-yocto gracefully (skip checks
  for incompatible machines, validate via qcom kernels only)
- Support DT file naming variants (commas vs underscores) via _name_variants()

Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>
Add two tests to QcomFitImageMatrixTests that catch mistakes like those
fixed in PR qualcomm-linux#2236, where identical compatible strings were assigned to
multiple FIT_DTB_COMPATIBLE keys:

- test_fit_dtb_compatible_no_duplicate_keys: fails if the same bracketed
  key appears more than once in fit-dtb-compatible.inc (bitbake silently
  overwrites the first assignment, losing compatible strings).

- test_fit_dtb_compatible_no_duplicate_values: fails if the same
  compatible string is listed under more than one key (UEFI firmware
  stops at the first ITS match, so duplicates can select the wrong DTB).

A helper _fit_compatible_map() is added to parse the file into a
{key: [compat_str, ...]} dict, handling both single-line and
backslash-continued multi-line value syntax.

Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>
@github-actions
Copy link
Copy Markdown

Test run workflow

Test jobs for commit 418cbe9

qcom-distro
Pass: 264 | Fail: 2 | Total: 286
nodistro
Pass: 9 | Fail: 0 | Total: 9
qcom-distro_linux-qcom-6.18
Pass: 198 | Fail: 4 | Total: 222

@lumag
Copy link
Copy Markdown
Contributor

lumag commented May 24, 2026

I think instead we need to invert the logic. The FIT_DTB_COMPATIBLE (or a new variable) should be indexed by the FIT configuration values rather than the lists of DTBs being used.

@ricardosalveti
Copy link
Copy Markdown
Contributor Author

I think instead we need to invert the logic. The FIT_DTB_COMPATIBLE (or a new variable) should be indexed by the FIT configuration values rather than the lists of DTBs being used.

But you still need to have validate that the DTBs are indeed valid, as you still need to include the dtb / dtbos in the end.

This PR is not done to change the behavior, this was just to catch possible issues with the current file, we can for sure change it, but it would be out of the scope from this PR I would say.

Copy link
Copy Markdown
Contributor

@koenkooi koenkooi left a comment

Choose a reason for hiding this comment

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

LGTM, the more checks for things like this, the better

@ricardosalveti ricardosalveti enabled auto-merge May 26, 2026 13:33
@ricardosalveti ricardosalveti disabled auto-merge May 26, 2026 13:33
@ricardosalveti ricardosalveti merged commit 8917dc1 into qualcomm-linux:master May 26, 2026
252 of 253 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants