Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
metadata:
name: DeviceTree_HW_Capability_Validation
format: "Lava-Test Test Definition 1.0"
description: "Validate runtime device-tree identity, enabled hardware controllers, driver binding, and kernel health"
os:
- linux
scope:
- functional
params:
area: all

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Kernel/Baseport/DeviceTree_HW_Capability_Validation
- ./run.sh --area "${area:-all}" || true
- $REPO_PATH/Runner/utils/send-to-lava.sh DeviceTree_HW_Capability_Validation.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Device Tree Hardware Capability Validation

## Overview

`DeviceTree_HW_Capability_Validation` validates the active runtime device tree,
not a DTB stored on the root filesystem. It is designed for Qualcomm Linux
Developer Kits and Evaluation Kits with differing board revisions, FIT DTB
selection, and overlays.

The suite discovers enabled hardware controllers from the runtime `compatible`
properties. It does not hardcode board names, network-interface names, or
attached peripherals.

## Validation scope

| Area selector | Validation |
| --- | --- |
| `identity` | Runtime DT root, `compatible`, optional `model`, root address and size cells, and a profile identifier derived from the first compatible string |
| `boot` | Optional `/chosen` `stdout-path` and `bootargs`, including stdout target resolution through `/aliases` |
| `cpu-memory` | Enabled DT CPU nodes cover kernel-exposed CPUs; memory nodes expose `reg`; reserved-memory children expose `reg` or `size`; declared NUMA node identifiers are inventoried |
| `interrupts` | Readable `/proc/interrupts`, interrupt-controller providers, and GIC, PDC, and GPIO structural or runtime evidence as appropriate |
| `fabric` | Clock, reset, regulator, mailbox, interconnect, RPMh, LLCC, and SMMU provider structure with platform-driver evidence where applicable |
| `storage` | Enabled UFS, SDHCI, and SPI controller bindings; SPI-NOR DT inventory; optional NVMe and MTD runtime evidence |
| `usb` | Enabled USB controller binding plus optional host and gadget-controller runtime evidence, including role-state reporting when host mode is inactive |
| `pcie` | Enabled PCIe controller binding plus optional endpoint enumeration evidence |
| `network` | Enabled Ethernet controller binding, non-virtual network-runtime evidence, and separate Wi-Fi/Bluetooth DT inventory without requiring an external module or link |
| `multimedia` | Display and GPU binding, audio and camera DT inventory, and optional DRM and ALSA runtime evidence |
| `remoteproc` | Enabled Qualcomm remoteproc inventory, memory-region and firmware-name evidence, firmware provisioning status, and runtime instance correlation |
| `security` | OP-TEE, SCM, TPM, and KVM EL2 DT inventory with optional TEE, TPM, and KVM runtime evidence, distinguishing a likely Qualcomm TEE flow from declared OP-TEE |
| `health` | Captured relevant DT and controller probe failures before and after validation |

Existing focused suites remain responsible for active functional testing. For
example, PCIe endpoint enumeration, Ethernet traffic, audio capture,
interconnect voting, and EDAC counter behavior are not duplicated here.

## Result policy

- **PASS**: Required DT structure is present and a discovered controller is bound.
- **SKIP**: The runtime tree does not expose an optional capability, remoteproc
firmware is not provisioned, an external fixture or USB role is inactive, a
framework provider has no direct runtime binding, or a required base utility
is absent.
- **FAIL**: Required DT identity, CPU, or memory data is invalid; a hardware
controller that requires an MMIO register range lacks `reg`; or the captured
kernel log reports relevant failures. Framework children and firmware nodes
without direct platform-device representation are reported as **SKIP**.

An attached USB device, PCIe endpoint, Ethernet cable, display, camera, or
wireless module is not required. Those are fixture-level validations.

The profile identifier is runtime-derived from the first compatible string.
This keeps the baseline valid for all supported `meta-qcom` machines and their
overlay variants without tying the suite to a Yocto `MACHINE` name. Platform
profiles can later add stricter requirements after target evidence is collected.

## Usage

Run directly on the target from the suite directory:

```sh
./run.sh
```

By default all areas run. To shorten an investigation, select one area or a
comma-separated set. The accepted area names correspond to the table above:

```sh
./run.sh --area interrupts
./run.sh --area storage,usb,pcie
./run.sh --area remoteproc,security
./run.sh --list-areas
```

The suite builds compatible, provider-property, and platform-device indexes
once at startup, then reuses them for each selected area. This avoids repeated
full device-tree and platform-bus scans. It deliberately does not run checks in
parallel because they update one result file and one set of result counters.
The final output includes a compact per-area pass, fail, and skip table; full
per-node details remain in the artifacts.

The result file is `DeviceTree_HW_Capability_Validation.res`. DT node lists and
captured kernel-log artifacts, including `dmesg_snapshot.log` and
`dmesg_errors.log`, are retained in:

```text
results/DeviceTree_HW_Capability_Validation/
```

This directory also contains `dt_compatible_index.log`,
`dt_property_index.log`, `platform_device_index.log`, and
`dt_area_summary.tsv`.

## LAVA

Use `DeviceTree_HW_Capability_Validation.yaml`. The definition invokes the
suite and uploads its result file through the repository LAVA helper.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause

# ---------- Repo env + helpers ----------
SCRIPT_DIR="$(
cd "$(dirname "$0")" || exit 1
pwd
)"
INIT_ENV=""
SEARCH="$SCRIPT_DIR"

while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then
INIT_ENV="$SEARCH/init_env"
break
fi
SEARCH=$(dirname "$SEARCH")
done

if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
exit 1
fi

# Only source once (idempotent)
# NOTE: We intentionally **do not export** any new vars. They stay local to this shell.
if [ -z "${__INIT_ENV_LOADED:-}" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
__INIT_ENV_LOADED=1
fi

# shellcheck disable=SC1090
. "$INIT_ENV"
# shellcheck disable=SC1091
. "$TOOLS/functestlib.sh"
TESTNAME="DeviceTree_HW_Capability_Validation"
RES_FILE="$SCRIPT_DIR/$TESTNAME.res"

RESULT_DIR="$SCRIPT_DIR/results/$TESTNAME"

dt_hw_capability_parse_args "$@"
parse_status=$?
if [ "$parse_status" -ne 0 ]; then
if [ "$parse_status" -eq 2 ]; then
exit 0
fi
echo "[ERROR] Usage: ./run.sh [--area all|identity,boot,cpu-memory,interrupts,fabric,storage,usb,pcie,network,multimedia,remoteproc,security,health] [--list-areas]" >&2
exit 2
fi

test_result_init "$TESTNAME" "$RES_FILE" || exit 1

if ! mkdir -p "$RESULT_DIR"; then
test_result_finish "FAIL" "$TESTNAME FAIL: cannot create result directory $RESULT_DIR"
fi

# DT helper discovery uses mktemp. Keep all temporary files in the testcase
# directory instead of inheriting a target-specific TMPDIR.
TMPDIR="$SCRIPT_DIR"

if ! CHECK_DEPS_NO_EXIT=1 check_dependencies \
awk basename cp date dirname dmesg find grep mkdir mktemp readlink rm sed sort tr wc; then
test_result_finish "SKIP" "$TESTNAME SKIP: required base utilities are unavailable"
fi

if ! DT_ROOT=$(dt_runtime_root); then
test_result_finish "SKIP" "$TESTNAME SKIP: runtime device tree is not exposed"
fi

log_info "--------------------------------------------------------------------------"
log_info "Starting $TESTNAME"
log_info "Validation areas: $DTRHC_AREAS"

if ! dt_validate_runtime_hardware_capabilities "$DT_ROOT" "$RESULT_DIR"; then
test_result_finish "FAIL" "$TESTNAME FAIL: DT capability validation could not complete"
fi

test_result_finish
Loading
Loading