aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/alsa (follow)
AgeCommit message (Collapse)AuthorFilesLines
2024-03-05selftests: avoid using SKIP(exit()) in harness fixure setupJakub Kicinski1-2/+2
selftest harness uses various exit codes to signal test results. Avoid calling exit() directly, otherwise tests may get broken by harness refactoring (like the commit under Fixes). SKIP() will instruct the harness that the test shouldn't run, it used to not be the case, but that has been fixed. So just return, no need to exit. Note that for hmm-tests this actually changes the result from pass to skip. Which seems fair, the test is skipped, after all. Reported-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/all/05f7bf89-04a5-4b65-bf59-c19456aeb1f0@sirena.org.uk Fixes: a724707976b0 ("selftests: kselftest_harness: use KSFT_* exit codes") Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Mark Brown <broonie@kernel.org> Tested-by: Mark Brown <broonie@kernel.org> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Link: https://lore.kernel.org/r/20240304233621.646054-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-01-09kselftest/alsa - conf: Stringify the printed errno in sysfs_get()Mirsad Todorovac1-1/+1
GCC 13.2.0 reported the warning of the print format specifier: conf.c: In function ‘sysfs_get’: conf.c:181:72: warning: format ‘%s’ expects argument of type ‘char *’, \ but argument 3 has type ‘int’ [-Wformat=] 181 | ksft_exit_fail_msg("sysfs: unable to read value '%s': %s\n", | ~^ | | | char * | %d The fix passes strerror(errno) as it was intended, like in the sibling error exit message. Fixes: aba51cd0949ae ("selftests: alsa - add PCM test") Cc: Mark Brown <broonie@kernel.org> Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: Shuah Khan <shuah@kernel.org> Cc: linux-sound@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20240107173704.937824-5-mirsad.todorovac@alu.unizg.hr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-01-09kselftest/alsa - mixer-test: Fix the print format specifier warningMirsad Todorovac1-1/+1
GCC 13.2.0 compiler issued the following warning: mixer-test.c:350:80: warning: format ‘%ld’ expects argument of type ‘long int’, \ but argument 5 has type ‘unsigned int’ [-Wformat=] 350 | ksft_print_msg("%s.%d value %ld more than item count %ld\n", | ~~^ | | | long int | %d 351 | ctl->name, index, int_val, 352 | snd_ctl_elem_info_get_items(ctl->info)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | unsigned int Fixing the format specifier in call to ksft_print_msg() according to the compiler suggestion silences the warning. Fixes: 10f2f194663af ("kselftest: alsa: Validate values read from enumerations") Cc: Mark Brown <broonie@kernel.org> Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: Shuah Khan <shuah@kernel.org> Cc: linux-sound@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20240107173704.937824-4-mirsad.todorovac@alu.unizg.hr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-01-09kselftest/alsa - mixer-test: Fix the print format specifier warningMirsad Todorovac1-1/+1
The GCC 13.2.0 compiler issued the following warning: mixer-test.c: In function ‘ctl_value_index_valid’: mixer-test.c:322:79: warning: format ‘%lld’ expects argument of type ‘long long int’, \ but argument 5 has type ‘long int’ [-Wformat=] 322 | ksft_print_msg("%s.%d value %lld more than maximum %lld\n", | ~~~^ | | | long long int | %ld 323 | ctl->name, index, int64_val, 324 | snd_ctl_elem_info_get_max(ctl->info)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int Fixing the format specifier as advised by the compiler suggestion removes the warning. Fixes: 3f48b137d88e7 ("kselftest: alsa: Factor out check that values meet constraints") Cc: Mark Brown <broonie@kernel.org> Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: Shuah Khan <shuah@kernel.org> Cc: linux-sound@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20240107173704.937824-3-mirsad.todorovac@alu.unizg.hr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-01-09kselftest/alsa - mixer-test: fix the number of parameters to ksft_exit_fail_msg()Mirsad Todorovac1-1/+1
Minor fix in the number of arguments to error reporting function in the test program as reported by GCC 13.2.0 warning. mixer-test.c: In function ‘find_controls’: mixer-test.c:169:44: warning: too many arguments for format [-Wformat-extra-args] 169 | ksft_exit_fail_msg("snd_ctl_poll_descriptors() failed for %d\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The number of arguments in call to ksft_exit_fail_msg() doesn't correspond to the format specifiers, so this is adjusted resembling the sibling calls to the error function. Fixes: b1446bda56456 ("kselftest: alsa: Check for event generation when we write to controls") Cc: Mark Brown <broonie@kernel.org> Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: Shuah Khan <shuah@kernel.org> Cc: linux-sound@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20240107173704.937824-2-mirsad.todorovac@alu.unizg.hr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-18kselftest: alsa: fixed a print formatting warningGhanshyam Agrawal1-1/+1
A statement used %d print formatter where %s should have been used. The same has been fixed in this commit. Signed-off-by: Ghanshyam Agrawal <ghanshyam1898@gmail.com> Link: 5aaf9efffc57 ("kselftest: alsa: Add simplistic test for ALSA mixer controls kselftest") Link: https://lore.kernel.org/r/20231217080019.1063476-1-ghanshyam1898@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-09-20kselftest/alsa: pcm-test: Report cards declared in config but missingNícolas F. R. A. Prado3-47/+73
When parsing the configs, keep track of card configurations that match the current system but haven't matched any card, and report those as test failures as they represent that a card which was expected to be present on the system is missing. This allows the configuration files to not only be used to detect missing PCM devices (which is currently possible) but also that the soundcard hasn't been registered at all. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230919152702.100617-1-nfraprado@collabora.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-09-11selftests: ALSA: remove unused variablesDing Xiang4-12/+5
These variables are never referenced in the code, just remove them. Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com> Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230908081040.197243-1-dingxiang@cmss.chinamobile.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-07-25Merge tag 'asoc-v6.6-early' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-nextTakashi Iwai2-3/+2
ASoC: Updates for v6.6 Here's an initial batch of updates for ASoC for this release cycle. We've got a bunch of new drivers in here, a bit of core work from Morimoto-san and quite a lot of janitorial work. There's several updates that pull in changes from other subsystems in order to build on them: - An adaptor to allow use of IIO DACs and ADCs in ASoC which pulls in some IIO changes. - Create a library function for intlog10() and use it in the NAU8825 driver. - Include the ASoC tests, including the topology tests, in the default KUnit full test coverage. This also involves enabling UML builds of ALSA since that's the default KUnit test environment which pulls in the addition of some stubs to the driver. - More factoring out from Morimoto-san. - Convert a lot of drivers to use the more modern maple tree register cache. - Support for AMD machines with MAX98388 and NAU8821, Cirrus Logic CS35L36, Intel AVS machines with ES8336 and RT5663 and NXP i.MX93.
2023-07-19selftests: ALSA: Add test-pcmtest-driver to .gitignoreTakashi Iwai1-0/+1
It was forgotten to add the new binary to .gitignore. Let's fix it. Fixes: 10b98a4db11a ("selftests: ALSA: Add test for the 'pcmtest' driver") Link: https://lore.kernel.org/r/20230719114336.18409-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-07-13selftests: ALSA: Fix fclose on an already fclosed file pointerColin Ian King1-3/+1
In the case where a sysfs file cannot be opened the error return path fcloses file pointer fpl, however, fpl has already been closed in the previous stanza. Fix the double fclose by removing it. Fixes: 10b98a4db11a ("selftests: ALSA: Add test for the 'pcmtest' driver") Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230712140122.457206-1-colin.i.king@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-07-10kselftest/alsa: pcm-test: Decrease stream duration from 4 to 2 secondsNícolas F. R. A. Prado1-1/+1
Currently test_pcm_time() streams audio on each PCM with each configuration for 4 seconds. This time can add up, and with the current 45 second kselftest timeout, some machines like mt8192-asurada-spherion can't even run to completion. Lower the duration to 2 seconds to cut the test duration in half, without reducing the test coverage. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20230620220839.2215057-3-nfraprado@collabora.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-07-10kselftest/alsa: pcm-test: Move stream duration and margin to variablesNícolas F. R. A. Prado1-3/+5
The duration to stream for and time margin to consider the stream failed are currently hardcoded values. Move them to variables so they can be reused and more easily changed. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230620220839.2215057-2-nfraprado@collabora.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-26Merge branch 'for-next' into for-linusTakashi Iwai2-1/+334
Pull the 6.5-devel branch for upstreaming. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-07selftests: ALSA: Add test for the 'pcmtest' driverIvan Orlov2-1/+334
This test covers the new Virtual PCM Test Driver, including the capturing, playback and ioctl redefinition functionalities for both interleaved and non-interleaved access modes. This test is also helpful as an usage example of the 'pcmtest' driver. We have a lot of different virtual media drivers, which can be used for testing of the userspace applications and media subsystem middle layer. However, all of them are aimed at testing the video functionality and simulating the video devices. For audio devices we have only snd-dummy module, which is good in simulating the correct behavior of an ALSA device. I decided to write a tool, which would help to test the userspace ALSA programs (and the PCM middle layer as well) under unusual circumstances to figure out how they would behave. So I came up with this Virtual PCM Test Driver. This new Virtual PCM Test Driver has several features which can be useful during the userspace ALSA applications testing/fuzzing, or testing/fuzzing of the PCM middle layer. Not all of them can be implemented using the existing virtual drivers (like dummy or loopback). Here is what can this driver do: - Simulate both capture and playback processes - Generate random or pattern-based capture data - Check the playback stream for containing the looped pattern - Inject delays into the playback and capturing processes - Inject errors during the PCM callbacks Also, this driver can check the playback stream for containing the predefined pattern, which is used in the corresponding selftest to check the PCM middle layer data transferring functionality. Additionally, this driver redefines the default RESET ioctl, and the selftest covers this PCM API functionality as well. The driver supports both interleaved and non-interleaved access modes, and have separate pattern buffers for each channel. The driver supports up to 4 channels and up to 8 substreams. Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Acked-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20230606193254.20791-3-ivan.orlov0322@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-05selftests: alsa: pcm-test: Fix compiler warnings about the formatMirsad Goran Todorovac1-5/+5
GCC 11.3.0 issues warnings in this module about wrong sizes of format specifiers: pcm-test.c: In function ‘test_pcm_time’: pcm-test.c:384:68: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 \ has type ‘unsigned int’ [-Wformat=] 384 | snprintf(msg, sizeof(msg), "rate mismatch %ld != %ld", rate, rrate); pcm-test.c:455:53: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has \ type ‘long int’ [-Wformat=] 455 | "expected %d, wrote %li", rate, frames); pcm-test.c:462:53: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has \ type ‘long int’ [-Wformat=] 462 | "expected %d, wrote %li", rate, frames); pcm-test.c:467:53: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has \ type ‘long int’ [-Wformat=] 467 | "expected %d, wrote %li", rate, frames); Simple fix according to compiler's suggestion removed the warnings. Signed-off-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr> Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230524191528.13203-1-mirsad.todorovac@alu.unizg.hr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-03-24kselftest/alsa - pcm-test: Don't include diagnostic message in test nameMark Brown1-6/+7
When reporting errors or skips we currently include the diagnostic message indicating why we're failing or skipping. This isn't ideal since KTAP defines the entire print as the test name, so if there's an error then test systems won't detect the test as being the same one as a passing test. Move the diagnostic to a separate ksft_print_msg() to avoid this issue, the test name part will always be the same for passes, fails and skips and the diagnostic information is still displayed. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230323-alsa-pcm-test-names-v1-1-8be67a8885ff@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-03-24kselftest/alsa - mixer-test: Log values associated with event issuesMark Brown1-0/+44
While it is common for driver bugs with events to apply to all events there are some issues which only trigger for specific values. Understanding these is easier if we know what we were trying to do when configuring the control so add logging for the specific values involved in the spurious event. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230322-alsa-mixer-event-values-v1-1-78189fcf6655@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-03-08kselftest/alsa: Log card names during startupMark Brown2-0/+20
It can be helpful to know which card numbers apply to which cards in a multi-card system so log the card names when we start the test programs. People looking at the logs may not have direct access to the systems being tested. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230223-alsa-log-ctl-name-v1-2-ac0f10cc4db2@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-03-08kselftest/alsa - mixer: Always log control namesMark Brown1-0/+3
Currently we only log the names of controls on error but it can be useful to know what control we're testing (for example, when looking at why the tests are taking a while to run). People looking at test logs may not have direct access to the target system. This will increase the amount we write to the console, hopefully that's buffered. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230223-alsa-log-ctl-name-v1-1-ac0f10cc4db2@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-03-08kselftest/alsa - mixer-test: Don't fail tests if we can't restore defaultMark Brown1-7/+2
If a control has an invalid default value then we might fail to set it when restoring the default value after our write tests, for example due to correctly implemented range checks in put() operations. Currently this causes us to report the tests we were running as failed even when the operation we were trying to test is successful, making it look like there are problems where none really exist. Stop doing this, only reporting any issues during the actual test. We already have validation for the initial readback being in spec and for writing the default value back so failed tests will be reported for these controls, and we log an error on the operation that failed when we write so there will be a diagnostic warning the user that there is a problem. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230224-alsa-mixer-test-restore-invalid-v1-1-454f0f1f2c4b@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-02-04kselftest/alsa: Run PCM tests for multiple cards in parallelMark Brown2-8/+74
With each test taking 4 seconds the runtime of pcm-test can add up. Since generally each card in the system is physically independent and will be unaffected by what's going on with other cards we can mitigate this by testing each card in parallel. Make a list of cards as we enumerate the system and then start a thread for each, then join the threads to ensure they have all finished. The threads each run the same tests we currently run for each PCM on the card before exiting. The list of PCMs is kept global since it helps with global operations like working out our planned number of tests and identifying missing PCMs and it seemed neater to check for PCMs on the right card in the card thread than make every PCM loop iterate over cards as well. We don't run per-PCM tests in parallel since in embedded systems it can be the case that resources are shared between the PCMs and operations on one PCM on a card may constrain what can be done on another PCM on the same card leading to potentially unstable results. We use a mutex to ensure that the reporting of results is serialised and we don't have issues with anything like the current test number, we could do this in the kselftest framework but it seems like this might cause problems for other tests that are doing lower level testing and building in constrained environments such as nolibc so this seems more sensible. Note that the ordering of the tests can't be guaranteed as things stand, this does not seem like a major problem since the numbering of tests often changes as test programs are changed so results parsers are expected to rely on the test name rather than the test numbers. We also now prefix the machine generated test name when printing the description of the test since this is logged before streaming starts. On my two card desktop system this reduces the overall runtime by a third. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230203-alsa-pcm-test-card-thread-v1-1-59941640ebba@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-02kselftest/alsa: pcm - Add more coverage by defaultMark Brown1-1/+46
Add more coverage to our standard test cases: - 8kHz mono and stereo to verify that the most common mono format is clocked correctly. - 44.1kHz stereo to verify that this different clock base is generated accurately. - 48kHz 6 channel to verify that 6 channel is clocked correctly. - 96kHz stereo since that is a common audiophile rate. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221208-alsa-pcm-test-hacks-v4-7-5a152e65b1e1@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-02kselftest/alsa: pcm - Provide descriptions for the default testsMark Brown1-0/+2
Help people understand what the standard tests are trying to cover by providing descriptions which both serve as comments in the file and log messages in the program's output. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221208-alsa-pcm-test-hacks-v4-6-5a152e65b1e1@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-02kselftest/alsa: pcm - Support optional description for testsMark Brown1-0/+5
In order to help with the comprehensibility of tests it is useful for us to document what the test is attempting to cover. We could just do this through comments in the configuration files but in order to aid people looking at the output of the program in logs let's provide support for an optional 'description' directive which we log prior to running each of the tests. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221208-alsa-pcm-test-hacks-v4-5-5a152e65b1e1@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-02kselftest/alsa: pcm - skip tests when we fail to set paramsMark Brown1-6/+33
Since we don't know what the capabilities of an unknown card is any of our standard tests may fail due to not being supported by the system. Set a flag once we've configured the stream, just before we start data, to say that the system accepted our stream configuration. Since there shouldn't be a use case for tests that are specified for the individual system failing for those tests we also add a new test which fails if we are unable to configure the settings specified in the system specific configuration file. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221208-alsa-pcm-test-hacks-v4-4-5a152e65b1e1@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-02kselftest/alsa: pcm - Always run the default set of testsMark Brown1-25/+58
Rather than allowing the system specific tests to replace the default set of tests instead run them in addition to the standard set of tests. In order to avoid name collisions in the reported tests we add an additional test class element to the reported tests. Doing this means we always get a consistent baseline of coverage no matter what card we run on but retain the ability to specify specific coverage for a given system. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221208-alsa-pcm-test-hacks-v4-3-5a152e65b1e1@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-02kselftest/alsa: pcm - move more configuration to configuration filesJaroslav Kysela6-36/+121
Obtain all test parameters from the configuration files. The defaults are defined in the pcm-test.conf file. The test count and parameters may be variable per specific hardware. Also, handle alt_formats field now (with the fixes in the format loop). It replaces the original "automatic" logic which is not so universal. The code may be further extended to skip various tests based on the configuration hints, if the exact PCM hardware parameters are not available for the given hardware. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221208-alsa-pcm-test-hacks-v4-2-5a152e65b1e1@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-01-02kselftest/alsa: pcm - Drop recent coverage improvement changesMark Brown2-81/+42
In preparation to adopting a better, more comprehensive approach to adding the coverage that was just added using some changes from Jaroslav which were sent at the same time the recently added improvements were being applied drop what was applied. This reverts: 7d721baea138 "kselftest/alsa: Add more coverage of sample rates and channel counts" ee12040dd53a "kselftest/alsa: Provide more meaningful names for tests" ae95efd9754c "kselftest/alsa: Don't any configuration in the sample config" 8370d9b00c92 Revert "kselftest/alsa: Report failures to set the requested channels as skips" f944f8b539ea "kselftest/alsa: Report failures to set the requested sample rate as skips" 22eeb8f531c1 "kselftest/alsa: Refactor pcm-test to list the tests to run in a struct" Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221208-alsa-pcm-test-hacks-v4-1-5a152e65b1e1@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-12-01kselftest/alsa: Add more coverage of sample rates and channel countsMark Brown1-3/+8
Now that we can skip unsupported configurations add some more test cases using that, cover 8kHz, 44.1kHz and 96kHz plus 8kHz mono and 48kHz 6 channel. 44.1kHz is a different clock base to the existing 48kHz tests and may therefore show problems with the clock configuration if only 8kHz based rates are really available (or help diagnose if bad clocking is due to only 44.1kHz based rates being supported). 8kHz mono and 48Hz 6 channel are real world formats and should show if clocking does not account for channel count properly. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221201170745.1111236-7-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-12-01kselftest/alsa: Provide more meaningful names for testsMark Brown1-3/+3
Rather than just numbering the tests try to provide semi descriptive names for what the tests are trying to cover. This also has the advantage of meaning we can add more tests without having to keep the list of tests ordered by existing number which should make it easier to understand what we're testing and why. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221201170745.1111236-6-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-12-01kselftest/alsa: Don't any configuration in the sample configMark Brown1-16/+19
The values in the one example configuration file we currently have are the default values for the two tests we have so there's no need to actually set them. Comment them out as examples, with a rename for the tests so that we can update the tests in the code more easily. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221201170745.1111236-5-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-12-01kselftest/alsa: Report failures to set the requested channels as skipsMark Brown1-1/+8
If constraint selection gives us a number of channels other than the one that we asked for that isn't a failure, that is the device implementing constraints and advertising that it can't support whatever we asked for. Report such cases as a test skip rather than failure so we don't have false positives. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221201170745.1111236-4-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-12-01kselftest/alsa: Report failures to set the requested sample rate as skipsMark Brown1-6/+17
If constraint selection gives us a sample rate other than the one that we asked for that isn't a failure, that is the device implementing sample rate constraints and advertising that it can't support whatever we asked for. Report such cases as a test skip rather than failure so we don't have false positives. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221201170745.1111236-3-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-12-01kselftest/alsa: Refactor pcm-test to list the tests to run in a structMark Brown1-20/+33
In order to help make the list of tests a bit easier to maintain refactor things so we pass the tests around as a struct with the parameters in, enabling us to add new tests by adding to a table with comments saying what each of the number are. We could also use named initializers if we get more parameters. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221201170745.1111236-2-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-11-29selftests: alsa - move shared library configuration code to conf.cJaroslav Kysela5-122/+85
The minimal alsa-lib configuration code is similar in both mixer and pcm tests. Move this code to the shared conf.c source file. Also, fix the build rules inspired by rseq tests. Build libatest.so which is linked to the both test utilities dynamically. Also, set the TEST_FILES variable for lib.mk. Cc: linux-kselftest@vger.kernel.org Cc: Shuah Khan <shuah@kernel.org> Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz> Tested-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221129085306.2345763-1-perex@perex.cz Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-11-25kselftest/alsa: Add a .gitignore for the newly added PCM testMark Brown1-0/+1
The newly added PCM test produces a binary which is not ignored by git when built in tree, fix that. Fixes: aba51cd0949a ("selftests: alsa - add PCM test") Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20221125153654.1037868-1-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-11-16selftests: alsa - add PCM testJaroslav Kysela5-1/+1003
This initial code does a simple sample transfer tests. By default, all PCM devices are detected and tested with short and long buffering parameters for 4 seconds. If the sample transfer timing is not in a +-100ms boundary, the test fails. Only the interleaved buffering scheme is supported in this version. The configuration may be modified with the configuration files. A specific hardware configuration is detected and activated using the sysfs regex matching. This allows to use the DMI string (/sys/class/dmi/id/* tree) or any other system parameters exposed in sysfs for the matching for the CI automation. The configuration file may also specify the PCM device list to detect the missing PCM devices. v1..v2: - added missing alsa-local.h header file Cc: Mark Brown <broonie@kernel.org> Cc: Pierre-Louis Bossart <pierre-louis.bossart@intel.com> Cc: Liam Girdwood <liam.r.girdwood@intel.com> Cc: Jesse Barnes <jsbarnes@google.com> Cc: Jimmy Cheng-Yi Chiang <cychiang@google.com> Cc: Curtis Malainey <cujomalainey@google.com> Cc: Brian Norris <briannorris@chromium.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz> Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20221108115914.3751090-1-perex@perex.cz Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-05-31selftests: alsa: Handle pkg-config failure more gracefullyMark Brown1-0/+3
Follow the pattern used by other selftests like memfd and fall back on the standard toolchain options to build with a system installed alsa-lib if we don't get anything from pkg-config. This reduces our build dependencies a bit in the common case while still allowing use of pkg-config in case there is a need for it. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20220531151337.2933810-1-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-04-25selftests: alsa: Start validating control namesMark Brown1-1/+40
Not much of a test but we keep on getting problems with boolean controls not being called Switches so let's add a few basic checks to help people spot problems. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20220421115020.14118-1-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-02-08kselftest: alsa: fix spelling mistake "desciptor" -> "descriptor"Colin Ian King1-3/+3
There are some spelling mistakes in some ksft messages. Fix them. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Link: https://lore.kernel.org/r/20220207092235.240284-1-colin.i.king@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-02-04kselftest: alsa: Declare most functions staticMark Brown1-28/+30
This program has only one file so most functions can be static. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20220202150902.19563-2-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-02-04kselftest: alsa: Check for event generation when we write to controlsMark Brown1-3/+151
Add some coverage of event generation to mixer-test. Rather than doing a separate set of writes designed to trigger events we add a step to the existing write_and_verify() which checks to see if the value we read back from non-volatile controls matches the value before writing and that an event is or isn't generated as appropriate. The "tests" for events then simply check that no spurious or missing events were detected. This avoids needing further logic to generate appropriate values for each control type and maximises coverage. When checking for events we use a timeout of 0. This relies on the kernel generating any event prior to returning to userspace when setting a control. That is currently the case and it is difficult to see it changing, if it does the test will need to be updated. Using a delay of 0 means that we don't slow things down unduly when checking for no event or when events fail to be generated. We don't check behaviour for volatile controls since we can't tell what the behaviour is supposed to be for any given control. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20220202150902.19563-1-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-01-26kselftest: alsa: Add test case for writing invalid valuesMark Brown1-1/+221
Attempt to write various invalid values for control types we know about and check that something sensible happens. The ABI isn't quite as clearly defined as one might like, rather than generating an error when an invalid value is written many devices will silently rewrite the value into one that is valid for the control. The exact value chosen is not predictable so in the case the write succeeds we just check that the value we read back is one that is valid for the control. Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20220125162824.3816659-1-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-12-25kselftest: alsa: Validate values read from enumerationsMark Brown1-0/+17
Enumerations should return a value between 0 and items-1, check that this is the case. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20211217130213.3893415-3-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-12-25kselftest: alsa: Factor out check that values meet constraintsMark Brown1-59/+82
To simplify the code a bit and allow future reuse factor the checks that values we read are valid out of test_ctl_get_value() into a separate function which can be reused later. As part of this extend the test to check all the values for the control, not just the first one. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20211217130213.3893415-2-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-12-12kselftest: alsa: Use private alsa-lib configuration in mixer testJaroslav Kysela1-1/+55
As mentined by Takashi Sakamoto, the system-wide alsa-lib configuration may override the standard device declarations. This patch use the private alsa-lib configuration to set the predictable environment. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20211208095209.1772296-1-perex@perex.cz [Restructure version test to keep the preprocessor happy -- broonie] Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20211210185410.740009-4-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-12-12kselftest: alsa: optimization for SNDRV_CTL_ELEM_ACCESS_VOLATILETakashi Sakamoto1-3/+9
The volatile attribute of control element means that the hardware can voluntarily change the state of control element independent of any operation by software. ALSA control core necessarily sends notification to userspace subscribers for any change from userspace application, while it doesn't for the hardware's voluntary change. This commit adds optimization for the attribute. Even if read value is different from written value, the test reports success as long as the target control element has the attribute. On the other hand, the difference is itself reported for developers' convenience. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/Ya7TAHdMe9i41bsC@workstation [Fix comment style as suggested by Shuah -- broonie] Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20211210185410.740009-3-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-12-12kselftest: alsa: Add simplistic test for ALSA mixer controls kselftestMark Brown3-0/+615
Add a basic test for the mixer control interface. For every control on every sound card in the system it checks that it can read and write the default value where the control supports that and for writeable controls attempts to write all valid values, restoring the default values after each test to minimise disruption for users. There are quite a few areas for improvement - currently no coverage of the generation of notifications, several of the control types don't have any coverage for the values and we don't have any testing of error handling when we attempt to write out of range values - but this provides some basic coverage. This is added as a kselftest since unlike other ALSA test programs it does not require either physical setup of the device or interactive monitoring by users and kselftest is one of the test suites that is frequently run by people doing general automated testing so should increase coverage. It is written in terms of alsa-lib since tinyalsa is not generally packaged for distributions which makes things harder for general users interested in kselftest as a whole but it will be a barrier to people with Android. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Link: https://lore.kernel.org/r/20211210185410.740009-2-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>