On 11/9/26 10:35, Petr Oros wrote:
Add a shell library for DPLL selftests with wrappers around the iproute2
dpll tool and around the dpllsim configfs interface, and the first two
test scripts built on it. The library resolves devices by the clock ID
chosen at creation time, since netlink ids depend on what else exists
on the system, and the dpllsim helpers restrict the lookup to their
module, so that a device of another driver with the same clock ID is
never picked up. Every query runs the tool first and jq on what it
printed, so that a failed query is told apart from a missing attribute.
The library mounts configfs when nothing else did, and the exit trap of
each script undoes that, removes the devices the script created and
runs on INT and TERM as well, so that a timeout imposed by the harness
still cleans up.
Two runs of scripts that create dpllsim devices would share the one
dpllsim directory and could draw the same clock IDs, so every such
script takes a lock before it mounts or creates anything and skips when
another run holds it. The lock file lives under /run rather than in
/tmp, since the scripts run as root and open the file for writing, and
a symlink planted in the world-writable /tmp would redirect that open.
dpll_basic.sh checks that a device reports the mandatory attributes
over netlink. It runs against the device named by DPLL_DEV_ID, the
first device of the driver named by DPLL_DRIVER, or the first device
that is not a dpllsim one, and creates a dpllsim device when there is
none or when DPLL_DRIVER asks for dpllsim, so the same script serves
the simulator and real drivers and picks one of several drivers on a
host. dpll_stress.sh is simulator only and exercises the lifecycle
paths of the core by creating and deleting devices in a loop and by
cycling one device through repeated register and unregister
transitions. The dpllsim MAINTAINERS entry covers the new directory.
Signed-off-by: Petr Oros<redacted>
---
v3:
- move the selftests to tools/testing/selftests/drivers/dpll, next to
where the drivers live, with the library in that directory as a
TEST_FILES entry; the TARGETS and MAINTAINERS entries follow
- add DPLL_DRIVER, which picks the first device of the named driver
or, as dpllsim, a created simulated device on a system that has
hardware DPLL devices
- the Reviewed-by and Acked-by of v2 are not carried over, the
device selection changed
Reviewed-by: Ivan Vecera <ivecera@redhat.com>