summaryrefslogtreecommitdiff
path: root/sound/core/sound_kunit.c
AgeCommit message (Collapse)AuthorFilesLines
2024-05-09ALSA: kunit: Add missing module descriptionsTakashi Iwai1-0/+1
Now that make W=1 starts complaining the lack of MODULE_DESCRIPTION(), let's add the missing information. Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Closes: https://lore.kernel.org/r/ZjpQm-hxLQtpgkUx@smile.fi.intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dragan Simic <dsimic@manjaro.org> Link: https://lore.kernel.org/r/20240508091128.25274-5-tiwai@suse.de
2024-04-28ALSA: kunit: use const qualifier for immutable dataTakashi Sakamoto1-4/+4
Some data for testing is immutable. In the case, the const qualifier is available for any loader to place it to read-only segment. Fixes: 3e39acf56ede ("ALSA: core: Add sound core KUnit test") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Ivan Orlov <ivan.orlov0322@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Message-ID: <20240425233653.218434-1-o-takashi@sakamocchi.jp>
2024-04-26ALSA: kunit: make read-only array buf_samples static constColin Ian King1-1/+1
Don't populate the read-only array buf_samples on the stack at run time, instead make it static const. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Acked-by: Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de> Message-ID: <20240425160754.114716-1-colin.i.king@gmail.com>
2024-02-28ALSA: kunit: Fix sparse warningsTakashi Iwai1-14/+15
There were a few sparse warnings about the cast of strong-typed snd_pcm_format_t. Fix them with cast with __force. For spreading the ugly mess, put them in the definitions WRONG_FORMAT_1 and WRONG_FORMAT_2 and use them in the callers. Fixes: 3e39acf56ede ("ALSA: core: Add sound core KUnit test") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/r/202402270303.PmvmQrJV-lkp@intel.com Link: https://lore.kernel.org/r/20240227104912.18921-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-02-19ALSA: core: fix buffer overflow in test_format_fill_silence()Arnd Bergmann1-2/+3
KASAN caught a buffer overflow with the hardcoded 2048 byte buffer size, when 2080 bytes are written to it: BUG: KASAN: slab-out-of-bounds in snd_pcm_format_set_silence+0x3bc/0x3e4 Write of size 8 at addr ffff0000c8149800 by task kunit_try_catch/1297 CPU: 0 PID: 1297 Comm: kunit_try_catch Tainted: G N 6.8.0-rc4-next-20240216 #1 Hardware name: linux,dummy-virt (DT) Call trace: kasan_report+0x78/0xc0 __asan_report_store_n_noabort+0x1c/0x28 snd_pcm_format_set_silence+0x3bc/0x3e4 _test_fill_silence+0xdc/0x298 test_format_fill_silence+0x110/0x228 kunit_try_run_case+0x144/0x3bc kunit_generic_run_threadfn_adapter+0x50/0x94 kthread+0x330/0x3e8 ret_from_fork+0x10/0x20 Allocated by task 1297: __kmalloc+0x17c/0x2f0 kunit_kmalloc_array+0x2c/0x78 test_format_fill_silence+0xcc/0x228 kunit_try_run_case+0x144/0x3bc kunit_generic_run_threadfn_adapter+0x50/0x94 kthread+0x330/0x3e8 ret_from_fork+0x10/0x20 Replace the incorrect size with the correct length of 260 64-bit samples. Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Suggested-by: Ivan Orlov <ivan.orlov0322@gmail.com> Fixes: 3e39acf56ede ("ALSA: core: Add sound core KUnit test") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Tested-by: Linux Kernel Functional Testing <lkft@linaro.org> Acked-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20240217104311.3749655-1-arnd@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-01-30ALSA: core: Add sound core KUnit testIvan Orlov1-0/+310
At the moment, we have a decent amount of integration tests (selftests) covering different aspects of the sound subsystem. However, a lot of of sound-related in-kernel functions remains uncovered. This patch introduces the KUnit test for the core part of the sound subsystem. It includes 10 test cases: - Coverage of the format-related inline functions from 'pcm.h' header file: snd_pcm_format_physical_width, snd_pcm_format_width, snd_pcm_format_signed, test_format_endianness - Coverage of the available bytes counting functions from 'pcm.h' header: snd_pcm_capture_avail, snd_pcm_playback_avail - Coverage of functions from pcm_misc: snd_pcm_format_set_silence, snd_pcm_format_name - Coverage of card-related functions from init.c: snd_card_set_id, snd_component_add This patch depends on the previous patches in this patch series as they contain fix for the bug, which was found during the test development. Without them, the test doesn't pass. Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20240125223522.1122765-3-ivan.orlov0322@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>