selftests: ALSA: Cover userspace-driven timers with test
authorIvan Orlov <ivan.orlov0322@gmail.com>
Tue, 13 Aug 2024 12:07:01 +0000 (13:07 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sun, 18 Aug 2024 07:55:55 +0000 (09:55 +0200)
commit1026392d10af7b35361c7ec4e14569d88c0c33e4
tree7319695e216fc0109bd704b75752120237ade2f1
parent37745918e0e7575bc40f38da93a99b9fa6406224
selftests: ALSA: Cover userspace-driven timers with test

Add a test for the new functionality of userspace-driven timers and the
tool which allows us to count timer ticks in a certain time period. The
test:

1. Creates a userspace-driven timer with ioctl to /dev/snd/timer
2. Starts the `global-timer` application to count the ticks of the timer
from step 1.
3. Asynchronously triggers the timer multiple times with some interval
4. Compares the amount of caught ticks with the amount of trigger calls.

Since we can't include <alsa/asoundlib.h> and <sound/asound.h> in one
file due to overlapping declarations, I have to split the test into two
applications: one of them counts the amount of timer ticks in the
defined time period, and another one is the actual test which creates
the timer, triggers it periodically and starts the first app to count
the amount of ticks in a separate thread.

Besides from testing the functionality itself, the test represents a
sample application showing userspace-driven ALSA timers API.

Also, the timer test includes a test case which tries to create a timer
with invalid resolution (=0), and NULL as a timer info structure.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240813120701.171743-5-ivan.orlov0322@gmail.com
tools/testing/selftests/alsa/Makefile
tools/testing/selftests/alsa/global-timer.c [new file with mode: 0644]
tools/testing/selftests/alsa/utimer-test.c [new file with mode: 0644]