linux-stable/tools/testing/selftests/dt/ktap_helpers.sh
Nícolas F. R. A. Prado 14571ab1ad kselftest: Add new test for detecting unprobed Devicetree devices
Introduce a new kselftest to detect devices that were declared in the
Devicetree, and are expected to be probed by a driver, but weren't.

The test uses two lists: a list of compatibles that can match a
Devicetree device to a driver, and a list of compatibles that should be
ignored. The first is automatically generated by the
dt-extract-compatibles script, and is run as part of building this test.
The list of compatibles to ignore is a hand-crafted list to capture the
few exceptions of compatibles that are expected to match a driver but
not be bound to it.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20230828211424.2964562-4-nfraprado@collabora.com
Signed-off-by: Rob Herring <robh@kernel.org>
2023-09-20 14:25:10 -05:00

70 lines
1.1 KiB
Bash

# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2023 Collabora Ltd
#
# Helpers for outputting in KTAP format
#
KTAP_TESTNO=1
KTAP_CNT_PASS=0
KTAP_CNT_FAIL=0
KTAP_CNT_SKIP=0
ktap_print_header() {
echo "TAP version 13"
}
ktap_set_plan() {
num_tests="$1"
echo "1..$num_tests"
}
ktap_skip_all() {
echo -n "1..0 # SKIP "
echo $@
}
__ktap_test() {
result="$1"
description="$2"
directive="$3" # optional
local directive_str=
[[ ! -z "$directive" ]] && directive_str="# $directive"
echo $result $KTAP_TESTNO $description $directive_str
KTAP_TESTNO=$((KTAP_TESTNO+1))
}
ktap_test_pass() {
description="$1"
result="ok"
__ktap_test "$result" "$description"
KTAP_CNT_PASS=$((KTAP_CNT_PASS+1))
}
ktap_test_skip() {
description="$1"
result="ok"
directive="SKIP"
__ktap_test "$result" "$description" "$directive"
KTAP_CNT_SKIP=$((KTAP_CNT_SKIP+1))
}
ktap_test_fail() {
description="$1"
result="not ok"
__ktap_test "$result" "$description"
KTAP_CNT_FAIL=$((KTAP_CNT_FAIL+1))
}
ktap_print_totals() {
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
}