From patchwork Wed Nov 30 00:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 630056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2878AC4167B for ; Wed, 30 Nov 2022 00:07:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231363AbiK3AHM (ORCPT ); Tue, 29 Nov 2022 19:07:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbiK3AG5 (ORCPT ); Tue, 29 Nov 2022 19:06:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720AE7045B for ; Tue, 29 Nov 2022 16:06:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D5AF06188A for ; Wed, 30 Nov 2022 00:06:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9BC7C43470; Wed, 30 Nov 2022 00:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669766815; bh=441OKhiJgVCddtFNAx9Epxfx+yKvkKD9MnnbzjxJBFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sww73/2lJHu91+zcY3fgythvMBaW0QXhLKwVXQyD3QLrzAC0xhJSOfH6wkxxU/+s/ ktT8B2zlPWPMpnSEhC+GGqHSysk3yq0eBNC4IDXE21Q+j+ohEf5dOYZMsH59JXmsnl 8Y9bOa+J3Q+vYrmdJpi7sdcVJGQjF+3Cus6lAEQFCRSaRzsj8RLwTIG7gIbv/jj8gx LBKAfjlfrawnSf8vF5Ehu3VA0P2AljlDEl1AwZlv8nfmXtIDDPBQlDChDQHVymBf3m wDirIjzhpdPyikTGvTWcgbPWHT0M0OMGZq5QAVT15+Jz9do0XSijzuIt6D2ke4nFe1 flHLOcpgO9s2Q== From: Mark Brown To: Takashi Iwai , Jaroslav Kysela , Shuah Khan Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 1/6] kselftest/alsa: Refactor pcm-test to list the tests to run in a struct Date: Wed, 30 Nov 2022 00:06:03 +0000 Message-Id: <20221130000608.519574-2-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221130000608.519574-1-broonie@kernel.org> References: <20221130000608.519574-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5316; i=broonie@kernel.org; h=from:subject; bh=441OKhiJgVCddtFNAx9Epxfx+yKvkKD9MnnbzjxJBFo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjhp5rGwhQdFbiniftIokUorQjjrV1ranWwhmL5ru6 nZQqrk+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY4aeawAKCRAk1otyXVSH0LifB/ oCrFFsdd9oQg3cpDBQszgz4t/u2B7OZU1yvoKwDkRAc24mjA9HMfRMZWmhbpN5P+yYsiUgny/b1GfI n1rWjB6ACmfetUFagcQDQRujtdfa7id09aRq+6mt5DpoJrysXLkd3fQhGo+aY6T1aCfd9IC1b9AOVC WxOCViGfbUmDtXXwhad3fovW6VWtBOTwWzdB9lUa/oP5iJZXCsXDDfXm7rGBNpustrTxl5+JcLGgak eehbj/d1fiOHnfM7nGwmHioLH9S45bQiMev8pWqa2YFcEV3mkKnE/HympA1lIn+o3Azsedf+3Euja3 MeD1xX6Rm0DhkLUImB2xubdt5WPjfu X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- tools/testing/selftests/alsa/pcm-test.c | 53 +++++++++++++++---------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c index 2814d8f74f82..b8923e494e50 100644 --- a/tools/testing/selftests/alsa/pcm-test.c +++ b/tools/testing/selftests/alsa/pcm-test.c @@ -57,6 +57,15 @@ struct pcm_data *pcm_list = NULL; int num_missing = 0; struct pcm_data *pcm_missing = NULL; +struct time_test_def { + const char *cfg_prefix; + const char *format; + long rate; + long channels; + long period_size; + long buffer_size; +}; + void timestamp_now(timestamp_t *tstamp) { if (clock_gettime(CLOCK_MONOTONIC_RAW, tstamp)) @@ -290,9 +299,7 @@ static void find_pcms(void) } static void test_pcm_time1(struct pcm_data *data, - const char *cfg_prefix, const char *sformat, - long srate, long schannels, - long speriod_size, long sbuffer_size) + const struct time_test_def *test) { char name[64], key[128], msg[256]; const char *cs; @@ -314,20 +321,20 @@ static void test_pcm_time1(struct pcm_data *data, snd_pcm_hw_params_alloca(&hw_params); snd_pcm_sw_params_alloca(&sw_params); - cs = conf_get_string(data->pcm_config, cfg_prefix, "format", sformat); + cs = conf_get_string(data->pcm_config, test->cfg_prefix, "format", test->format); format = snd_pcm_format_value(cs); if (format == SND_PCM_FORMAT_UNKNOWN) ksft_exit_fail_msg("Wrong format '%s'\n", cs); - rate = conf_get_long(data->pcm_config, cfg_prefix, "rate", srate); - channels = conf_get_long(data->pcm_config, cfg_prefix, "channels", schannels); - period_size = conf_get_long(data->pcm_config, cfg_prefix, "period_size", speriod_size); - buffer_size = conf_get_long(data->pcm_config, cfg_prefix, "buffer_size", sbuffer_size); + rate = conf_get_long(data->pcm_config, test->cfg_prefix, "rate", test->rate); + channels = conf_get_long(data->pcm_config, test->cfg_prefix, "channels", test->channels); + period_size = conf_get_long(data->pcm_config, test->cfg_prefix, "period_size", test->period_size); + buffer_size = conf_get_long(data->pcm_config, test->cfg_prefix, "buffer_size", test->buffer_size); - automatic = strcmp(sformat, snd_pcm_format_name(format)) == 0 && - srate == rate && - schannels == channels && - speriod_size == period_size && - sbuffer_size == buffer_size; + automatic = strcmp(test->format, snd_pcm_format_name(format)) == 0 && + test->rate == rate && + test->channels == channels && + test->period_size == period_size && + test->buffer_size == buffer_size; samples = malloc((rate * channels * snd_pcm_format_physical_width(format)) / 8); if (!samples) @@ -363,7 +370,7 @@ static void test_pcm_time1(struct pcm_data *data, if (automatic && format == SND_PCM_FORMAT_S16_LE) { format = SND_PCM_FORMAT_S32_LE; ksft_print_msg("%s.%d.%d.%d.%s.%s format S16_LE -> S32_LE\n", - cfg_prefix, + test->cfg_prefix, data->card, data->device, data->subdevice, snd_pcm_stream_name(data->stream), snd_pcm_access_name(access)); @@ -432,7 +439,7 @@ static void test_pcm_time1(struct pcm_data *data, } ksft_print_msg("%s.%d.%d.%d.%s hw_params.%s.%s.%ld.%ld.%ld.%ld sw_params.%ld\n", - cfg_prefix, + test->cfg_prefix, data->card, data->device, data->subdevice, snd_pcm_stream_name(data->stream), snd_pcm_access_name(access), @@ -481,7 +488,7 @@ static void test_pcm_time1(struct pcm_data *data, pass = true; __close: ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n", - cfg_prefix, + test->cfg_prefix, data->card, data->device, data->subdevice, snd_pcm_stream_name(data->stream), msg[0] ? " " : "", msg); @@ -490,11 +497,16 @@ static void test_pcm_time1(struct pcm_data *data, snd_pcm_close(handle); } -#define TESTS_PER_PCM 2 +static const struct time_test_def time_tests[] = { + /* name format rate chan period buffer */ + { "test.time1", "S16_LE", 48000, 2, 512, 4096 }, + { "test.time2", "S16_LE", 48000, 2, 24000, 192000 }, +}; int main(void) { struct pcm_data *pcm; + int i; ksft_print_header(); @@ -502,7 +514,7 @@ int main(void) find_pcms(); - ksft_set_plan(num_missing + num_pcms * TESTS_PER_PCM); + ksft_set_plan(num_missing + num_pcms * ARRAY_SIZE(time_tests)); for (pcm = pcm_missing; pcm != NULL; pcm = pcm->next) { ksft_test_result(false, "test.missing.%d.%d.%d.%s\n", @@ -511,8 +523,9 @@ int main(void) } for (pcm = pcm_list; pcm != NULL; pcm = pcm->next) { - test_pcm_time1(pcm, "test.time1", "S16_LE", 48000, 2, 512, 4096); - test_pcm_time1(pcm, "test.time2", "S16_LE", 48000, 2, 24000, 192000); + for (i = 0; i < ARRAY_SIZE(time_tests); i++) { + test_pcm_time1(pcm, &time_tests[i]); + } } conf_free(); From patchwork Wed Nov 30 00:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 629767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AC6AC433FE for ; Wed, 30 Nov 2022 00:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbiK3AHN (ORCPT ); Tue, 29 Nov 2022 19:07:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiK3AG7 (ORCPT ); Tue, 29 Nov 2022 19:06:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDD670466 for ; Tue, 29 Nov 2022 16:06:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ABF0661982 for ; Wed, 30 Nov 2022 00:06:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B21CAC433B5; Wed, 30 Nov 2022 00:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669766817; bh=wqpaOP9IsZBH4xn9d7qF8ePQ5O6RD8RKVwSH35DW6JU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pzg9LrsvWEBJN7bAuXvrptbKPXn+k3MOzdQsc03W0U2yB7xE1wLAZSqd5zWe9v11g utn/GeuyqrvWNjUms+nVCNonG2oPraHksmVqfZ8NN84/e+tSlKsMGUQnuv6DBY97vA gQslbLlamDGy8GArqCHjFZsqnZitPD4045N7sOGYgFx3W4SEFm7xSo/bFD3HJDoh8h q6+dbmsWzetI5tnt0af3YxNDarXv2Otove+RUvKFbw/y/+OVhq/9HLZlfM2wOsgGrF 0SAdkPdTcz4r3We+7yIKtwFONN5R/rsnfeeCCh2qYY4Ih0gCvnJBXHClfn4K37qyaY s1nVYZkNp0AqA== From: Mark Brown To: Takashi Iwai , Jaroslav Kysela , Shuah Khan Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 2/6] kselftest/alsa: Report failures to set the requested sample rate as skips Date: Wed, 30 Nov 2022 00:06:04 +0000 Message-Id: <20221130000608.519574-3-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221130000608.519574-1-broonie@kernel.org> References: <20221130000608.519574-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2201; i=broonie@kernel.org; h=from:subject; bh=wqpaOP9IsZBH4xn9d7qF8ePQ5O6RD8RKVwSH35DW6JU=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjhp5sBJwm+lWb68cs/Kqx+6TVtUwnlH1Z4xrws870 u3bklPeJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY4aebAAKCRAk1otyXVSH0Lw2B/ 0SOPiFYC3iUaqOGezP5DUzGqUqe4Z68//nb3p1BMeDnELLkK7eIj12TGHaewlYHfKGkXUKcuDMHkAd UWRER1A+GZfGVwQidHIDV1ZhWjL0KC/YrpcKxsH+/ODtUy1KOzw4IazeZNHhNl0APY1PJvYmk/Epmv 3JjUmZR7RsXJCEmo8GmmTBGxGutXsocHwAIou3UWzvgW8EuW3kDkDqAxaZvlrbYwJvE+awd9OlrBYA HQReQvrOnS5leguzyjYi2TUbcj3PSaFPCAQb2syWOcXmDqNq3Zq4LCxERxYZbDlD3duYx35BXh3qk0 OHO3Zcf3Dqin5dKUUWXYQYo6PRWcFW X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- tools/testing/selftests/alsa/pcm-test.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c index b8923e494e50..6a9e4af828ee 100644 --- a/tools/testing/selftests/alsa/pcm-test.c +++ b/tools/testing/selftests/alsa/pcm-test.c @@ -317,6 +317,7 @@ static void test_pcm_time1(struct pcm_data *data, bool pass = false, automatic = true; snd_pcm_hw_params_t *hw_params; snd_pcm_sw_params_t *sw_params; + bool skip = false; snd_pcm_hw_params_alloca(&hw_params); snd_pcm_sw_params_alloca(&sw_params); @@ -391,7 +392,8 @@ static void test_pcm_time1(struct pcm_data *data, goto __close; } if (rrate != rate) { - snprintf(msg, sizeof(msg), "rate mismatch %ld != %ld", rate, rrate); + snprintf(msg, sizeof(msg), "rate unsupported %ld != %ld", rate, rrate); + skip = true; goto __close; } rperiod_size = period_size; @@ -487,11 +489,20 @@ static void test_pcm_time1(struct pcm_data *data, msg[0] = '\0'; pass = true; __close: - ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n", - test->cfg_prefix, - data->card, data->device, data->subdevice, - snd_pcm_stream_name(data->stream), - msg[0] ? " " : "", msg); + if (!skip) { + ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n", + test->cfg_prefix, + data->card, data->device, data->subdevice, + snd_pcm_stream_name(data->stream), + msg[0] ? " " : "", msg); + } else { + ksft_test_result_skip("%s.%d.%d.%d.%s%s%s\n", + test->cfg_prefix, + data->card, data->device, + data->subdevice, + snd_pcm_stream_name(data->stream), + msg[0] ? " " : "", msg); + } free(samples); if (handle) snd_pcm_close(handle); From patchwork Wed Nov 30 00:06:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 629766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BA22C47088 for ; Wed, 30 Nov 2022 00:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbiK3AHO (ORCPT ); Tue, 29 Nov 2022 19:07:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbiK3AHA (ORCPT ); Tue, 29 Nov 2022 19:07:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E898D7044E for ; Tue, 29 Nov 2022 16:06:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 81EF1617EB for ; Wed, 30 Nov 2022 00:06:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 891E8C43470; Wed, 30 Nov 2022 00:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669766818; bh=QUtBBASg/fKretMAe1LPjLOjq07MO6kbUGOnoUTWAv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmGpS2fX5Ikyv51CFBimH2R7P0/hdDUyl+rzWBTEzw6B8l4eTdDB04bGKEHQhtnHM jf3Y1xOSqf8YdPYkRjJ9N2h3nozmZUwSGZHyvmMRZpKAx6gE7bwcCg1n3h7pKrgDC2 yKjNHTj70nNsbvJJKak0Z1LJN6TiNcrgJUntMMFk4CFADgAjpI0iSng2z2LYl7OT2t 5OzVKhlgkd5tskibxmx5FXOPm0QSS9dnV6o0wjJGacNlHNEUlI26gqU1IUC4Kt9UTV JA2TUtcTyA57EDnCz5FKQKtiGDmHgVcnbYW0GGvjL0QVlIu+9Yi91hHsQgZY+VEa4C DQhkpq1QRGOeQ== From: Mark Brown To: Takashi Iwai , Jaroslav Kysela , Shuah Khan Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 3/6] kselftest/alsa: Report failures to set the requested channels as skips Date: Wed, 30 Nov 2022 00:06:05 +0000 Message-Id: <20221130000608.519574-4-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221130000608.519574-1-broonie@kernel.org> References: <20221130000608.519574-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1760; i=broonie@kernel.org; h=from:subject; bh=QUtBBASg/fKretMAe1LPjLOjq07MO6kbUGOnoUTWAv8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjhp5ttNhH9uQpLtwxgl96s5h1BSi/oaLbUpM4fPV+ akujv3eJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY4aebQAKCRAk1otyXVSH0AJoB/ 4p3oUv164HbGjiICneo1d/wFxHYM0WQ0qEO1zPcQ+vVQvEKY8a0roAUSWM0bVt/G/fgozvKoyHF/0c JiWDu/AGqh4dy0xZOEPxXlSO6DibPMiu4rjBg5ZhGNmflkmWnPqF+BpQrLHSTq4exme9F5s6DL6ynN GvM/WAzK9+u5+DoAPbkenLgt8N6QES+S2t7fsTchzMHAXwAB+CjVxcywBxSXR78xn/RpbtQkJw1W7t o283rPIzMGDfHKZpWCq7RMM9dKalrRiJgOrMBfvfX+kJ4mdjkHQvG3owTOuMG+qRrkb0B2Pz/nJTdb DMOlBEI46/hWzg0Dls5aKrzU34HaSE X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- tools/testing/selftests/alsa/pcm-test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c index 6a9e4af828ee..bc0cb3c481f2 100644 --- a/tools/testing/selftests/alsa/pcm-test.c +++ b/tools/testing/selftests/alsa/pcm-test.c @@ -311,6 +311,7 @@ static void test_pcm_time1(struct pcm_data *data, snd_pcm_sframes_t frames; long long ms; long rate, channels, period_size, buffer_size; + unsigned int rchannels; unsigned int rrate; snd_pcm_uframes_t rperiod_size, rbuffer_size, start_threshold; timestamp_t tstamp; @@ -380,11 +381,17 @@ static void test_pcm_time1(struct pcm_data *data, snd_pcm_format_name(format), snd_strerror(err)); goto __close; } - err = snd_pcm_hw_params_set_channels(handle, hw_params, channels); + rchannels = channels; + err = snd_pcm_hw_params_set_channels_near(handle, hw_params, &rchannels); if (err < 0) { snprintf(msg, sizeof(msg), "snd_pcm_hw_params_set_channels %ld: %s", channels, snd_strerror(err)); goto __close; } + if (rchannels != channels) { + snprintf(msg, sizeof(msg), "channels unsupported %ld != %ld", channels, rchannels); + skip = true; + goto __close; + } rrate = rate; err = snd_pcm_hw_params_set_rate_near(handle, hw_params, &rrate, 0); if (err < 0) { From patchwork Wed Nov 30 00:06:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 630055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE1F5C4708B for ; Wed, 30 Nov 2022 00:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229707AbiK3AHO (ORCPT ); Tue, 29 Nov 2022 19:07:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbiK3AHC (ORCPT ); Tue, 29 Nov 2022 19:07:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCE1A7044E for ; Tue, 29 Nov 2022 16:07:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 58B7E6188A for ; Wed, 30 Nov 2022 00:07:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6097BC433B5; Wed, 30 Nov 2022 00:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669766820; bh=Kn+BswH7rAycY9VeynvDcjRtACgC1wb2IYiNOSjS+Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/iVjO3eQ6O5SgF4L+pW9wQc9nwBwqAboxcJv9JEJRFeJ/drWcxPH5BBlqDfHhqA3 kGABAq+BeP9U+y+XPW8m1PQszD+9pGLFw3E5MLA6JaFZM1jZupLKV73IbVEgXhYGlM BVPqPjREhoNqRbxPga1qUP247txfym8MPKg94sFUtigBGDRpoY7qDp51eR5Uroyjrm KwH3JtqnreECU67fSnB7BY6tnQ0R4wMJ4kg9bf0pL6RJ5AlxNR4bqA3LEqQrJ8xikp miueaeBcBuTclKcS4XBE5C0KrbVkMRa/opcJmVUE+Uo6q/Oedb7+IGrJy6s9UQkYMw 2Hnf6XyRvGCnQ== From: Mark Brown To: Takashi Iwai , Jaroslav Kysela , Shuah Khan Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 4/6] kselftest/alsa: Don't any configuration in the sample config Date: Wed, 30 Nov 2022 00:06:06 +0000 Message-Id: <20221130000608.519574-5-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221130000608.519574-1-broonie@kernel.org> References: <20221130000608.519574-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1748; i=broonie@kernel.org; h=from:subject; bh=Kn+BswH7rAycY9VeynvDcjRtACgC1wb2IYiNOSjS+Q8=; b=owGbwMvMwMWocq27KDak/QLjabUkhuS2eXnZc4R1tCP8b77YUvVbKE7uxMflSW0cHPYavxjNPyp4 eEl0MhqzMDByMciKKbKsfZaxKj1cYuv8R/NfwQxiZQKZwsDFKQATUShg/2eYF78weJ3a86ZGpnfu5i /kv7SciZHoYFb9teXqbmZJzc96i4qK6hNql027XRo8//srOTlb75gTF0SzU+3Xm9ma+mczPNqrJLXF rdblc+xU3X/rW+/mf5leOKPQJ/q19mORXQ5BARZ/ysr0OKUFWs+HGDxLirX4zbcgMtju8Ruxt2+/GN vPcWl9KMkdduSYkImZ0/vAFbwbxZsDorsX8BxpfhLAX7OuM+5AYZNW0Jrf2Svr+lcXBLo2vrz4WuIE V6+QzM974ldOsHJpT3u69IBIbwWzaBiL5KKn08V38vAJa8dtqpPfq2stFb3i5VyPA15BU7ZvfbDJ7/ nzD/Lsj+4U8R7/XNARmCVSd3ItAA== X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- .../alsa/conf.d/Lenovo_ThinkPad_P1_Gen2.conf | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/alsa/conf.d/Lenovo_ThinkPad_P1_Gen2.conf b/tools/testing/selftests/alsa/conf.d/Lenovo_ThinkPad_P1_Gen2.conf index 0a83f35d43eb..9eca985e0c08 100644 --- a/tools/testing/selftests/alsa/conf.d/Lenovo_ThinkPad_P1_Gen2.conf +++ b/tools/testing/selftests/alsa/conf.d/Lenovo_ThinkPad_P1_Gen2.conf @@ -39,22 +39,25 @@ card.hda { # pcm.0.0 { PLAYBACK { - test.time1 { - access RW_INTERLEAVED # can be omitted - default - format S16_LE # can be omitted - default - rate 48000 # can be omitted - default - channels 2 # can be omitted - default - period_size 512 - buffer_size 4096 - } - test.time2 { - access RW_INTERLEAVED - format S16_LE - rate 48000 - channels 2 - period_size 24000 - buffer_size 192000 - } + # + # Uncomment to override values for specific tests + # + #test_name1 { + # access RW_INTERLEAVED + # format S16_LE + # rate 48000 + # channels 2 + # period_size 512 + # buffer_size 4096 + #} + #test_name2 { + # access RW_INTERLEAVED + # format S16_LE + # rate 48000 + # channels 2 + # period_size 24000 + # buffer_size 192000 + #} } CAPTURE { # use default tests, check for the presence From patchwork Wed Nov 30 00:06:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 630054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 739C8C4708A for ; Wed, 30 Nov 2022 00:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiK3AHO (ORCPT ); Tue, 29 Nov 2022 19:07:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbiK3AHE (ORCPT ); Tue, 29 Nov 2022 19:07:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 979B27044E for ; Tue, 29 Nov 2022 16:07:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3475D61981 for ; Wed, 30 Nov 2022 00:07:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39566C43470; Wed, 30 Nov 2022 00:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669766822; bh=kOi2ubrZvDe707/dHvl2mMsoj6BDmru6DBWUPvLaUxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V76bYzMawZs2YAZJGTTI54SCy/ykzT/KViJgN1xRHteLpFJ4NMiP16Eu+ai6NkR9J KqjYNfFxvQicyYObFWmw5mjE2Bn2sMAiR/U6I+TpayzrU1xXHxgStxeY/YYzvWjcIw LA2P7bYO7U9xGtQVqwfGOEXHlMXaUoR9FI174M7iTCmJllRtbzG4CVYCjdjyn17usp XtzoUuo2GMffADPV756TGO5MiNZ5RkvKjtBR3d5ZiOSVCKy8joNLAB2DWY1WYfi+kL VTni1/k/QUM2NNDK4A6MX34ZDz6A8HYVJPppOyRWPuX+vdw1JVZD5HUVe8M+6Vd2aa PHnk+g1XBq72w== From: Mark Brown To: Takashi Iwai , Jaroslav Kysela , Shuah Khan Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 5/6] kselftest/alsa: Provide more meaningful names for tests Date: Wed, 30 Nov 2022 00:06:07 +0000 Message-Id: <20221130000608.519574-6-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221130000608.519574-1-broonie@kernel.org> References: <20221130000608.519574-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1263; i=broonie@kernel.org; h=from:subject; bh=kOi2ubrZvDe707/dHvl2mMsoj6BDmru6DBWUPvLaUxo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjhp5vuot+YdREPb2LKHc+Hc4LtSKasB2J15HPSkKa bmmoyNiJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY4aebwAKCRAk1otyXVSH0CQdB/ 9cJAjFX1Xnft5g+5CfO4Y8lx+WCr3PDsQszQed6iptz7DARLlXwMxdtMkdd604CYcSD6AvJNAK3cw/ ZkkB/JMf5+ux/09aCxl/d6Cikp9UygL6YGghksGVo45g3IKRJ7S/KIYXpF1bYrEVgXJRsLnmLttiDD 9wKr3MxG14S+OUBmHArQDXpFX4GhRdrhcLo1mzq9C3uftSxkbei3787vsCNf/JprSYk0HBd5yJM7+4 st6OIHQjPQ6gRYIcR0pxe8EHnn6Sut3MNmakDNDvkKVduqSpX0u7GCcCQz2P/h1WkYXH9Lwx/rQ3KZ pSJVo6mFnGccacTrr/nPenPPeiap2E X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- tools/testing/selftests/alsa/pcm-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c index bc0cb3c481f2..614ccc52cece 100644 --- a/tools/testing/selftests/alsa/pcm-test.c +++ b/tools/testing/selftests/alsa/pcm-test.c @@ -516,9 +516,9 @@ static void test_pcm_time1(struct pcm_data *data, } static const struct time_test_def time_tests[] = { - /* name format rate chan period buffer */ - { "test.time1", "S16_LE", 48000, 2, 512, 4096 }, - { "test.time2", "S16_LE", 48000, 2, 24000, 192000 }, + /* name format rate chan period buffer */ + { "S16.48k.2.small", "S16_LE", 48000, 2, 512, 4096 }, + { "S16.48k.2.big", "S16_LE", 48000, 2, 24000, 192000 }, }; int main(void) From patchwork Wed Nov 30 00:06:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 630053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B54F0C4167B for ; Wed, 30 Nov 2022 00:07:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbiK3AHP (ORCPT ); Tue, 29 Nov 2022 19:07:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbiK3AHG (ORCPT ); Tue, 29 Nov 2022 19:07:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7283E7044E for ; Tue, 29 Nov 2022 16:07:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F40C61981 for ; Wed, 30 Nov 2022 00:07:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1194FC4347C; Wed, 30 Nov 2022 00:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669766824; bh=SZHDVz1meOtVOiMtc7gqDxDlymHtQ6CtxKd4qfqfgaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPhFm/Rzn35CIuHoM6Kgsoh5DKPiQHfbzJx5SwxcOGOneYc9CYHFA7bk0L3nxELuA T6YLnzy0TSak9OyZFGt/JuT2uwToUhZ58/6dRIEQV4RFbk87XPdnq2fsMpDHzv7wqj lxK4zuuLgnuj8DHu9F+PDEEBEes+riNjojaZahmnJ+7FDQeD8Tvl0nkFS5liwmj9q5 +1pO42XnWJmjnvO+Daa1Ja+kyQdyfqK10cKpT9n9j6gimEQkzAUQMfktuHYu2eSzhr /L8+yxHYjNUHOVd25N9aK96NZVP2JpmI9HHvTCqXvP58TyXrIPNrFGnGV55AR84wz8 kGkbXf2pqHx4g== From: Mark Brown To: Takashi Iwai , Jaroslav Kysela , Shuah Khan Cc: alsa-devel@alsa-project.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 6/6] kselftest/alsa: Add more coverage of sample rates and channel counts Date: Wed, 30 Nov 2022 00:06:08 +0000 Message-Id: <20221130000608.519574-7-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221130000608.519574-1-broonie@kernel.org> References: <20221130000608.519574-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1735; i=broonie@kernel.org; h=from:subject; bh=SZHDVz1meOtVOiMtc7gqDxDlymHtQ6CtxKd4qfqfgaI=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjhp5w0bk3EujAlnTerYvqQ9S/R8ox+IZVeJcICXIK wwlnRFWJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY4aecAAKCRAk1otyXVSH0CllB/ sGS7q4vmYVJutEyNKuqLI/KUoHy9Q6FnDhS5uiUkaQsAaHDzOWu5oJ4cV0eoMbV2AIysL6J1+y2Rj8 Pmn93CcKhqva/XJCgoIDYiQ0aiR9tkzRMo8tuiGhtUYD+UQ9dkzLDXB2kiYZRzUxpATphPmburf24u e7uvG+ciBZQGml/WT+Taz+LFOjvVC/vG71NeZCEbJAzjeAhhc+5mYD+5RbKxMAJwSPNb04tnNBHn98 zziqRYeBHd0U/x/kMUbOD3GAsOQb19bhEcV8ZKYLT+gyDmdct3NPcDnUUOPo4WzI2hjiyBx54Pzpy6 35DLesB6oimXgjzPA4gbkIIFS/bJe7 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- tools/testing/selftests/alsa/pcm-test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/alsa/pcm-test.c b/tools/testing/selftests/alsa/pcm-test.c index 614ccc52cece..d76a6f15ce25 100644 --- a/tools/testing/selftests/alsa/pcm-test.c +++ b/tools/testing/selftests/alsa/pcm-test.c @@ -517,8 +517,13 @@ static void test_pcm_time1(struct pcm_data *data, static const struct time_test_def time_tests[] = { /* name format rate chan period buffer */ - { "S16.48k.2.small", "S16_LE", 48000, 2, 512, 4096 }, - { "S16.48k.2.big", "S16_LE", 48000, 2, 24000, 192000 }, + { "8k.1.big", "S16_LE", 8000, 2, 2000, 16000 }, + { "8k.2.big", "S16_LE", 8000, 2, 4000, 32000 }, + { "44k1.2.big", "S16_LE", 44100, 2, 22050, 192000 }, + { "48k.2.small", "S16_LE", 48000, 2, 512, 4096 }, + { "48k.2.big", "S16_LE", 48000, 2, 24000, 192000 }, + { "48k.6.big", "S16_LE", 48000, 6, 48000, 576000 }, + { "96k.2.big", "S16_LE", 96000, 2, 48000, 384000 }, }; int main(void)