Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest/alsa: pcm - Drop recent coverage improvement changes

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>

authored by

Mark Brown and committed by
Takashi Iwai
c48cafc2 88603b6d

+42 -81
+16 -19
tools/testing/selftests/alsa/conf.d/Lenovo_ThinkPad_P1_Gen2.conf
··· 39 39 # 40 40 pcm.0.0 { 41 41 PLAYBACK { 42 - # 43 - # Uncomment to override values for specific tests 44 - # 45 - #test_name1 { 46 - # access RW_INTERLEAVED 47 - # format S16_LE 48 - # rate 48000 49 - # channels 2 50 - # period_size 512 51 - # buffer_size 4096 52 - #} 53 - #test_name2 { 54 - # access RW_INTERLEAVED 55 - # format S16_LE 56 - # rate 48000 57 - # channels 2 58 - # period_size 24000 59 - # buffer_size 192000 60 - #} 42 + test.time1 { 43 + access RW_INTERLEAVED # can be omitted - default 44 + format S16_LE # can be omitted - default 45 + rate 48000 # can be omitted - default 46 + channels 2 # can be omitted - default 47 + period_size 512 48 + buffer_size 4096 49 + } 50 + test.time2 { 51 + access RW_INTERLEAVED 52 + format S16_LE 53 + rate 48000 54 + channels 2 55 + period_size 24000 56 + buffer_size 192000 57 + } 61 58 } 62 59 CAPTURE { 63 60 # use default tests, check for the presence
+26 -62
tools/testing/selftests/alsa/pcm-test.c
··· 37 37 int num_missing = 0; 38 38 struct pcm_data *pcm_missing = NULL; 39 39 40 - struct time_test_def { 41 - const char *cfg_prefix; 42 - const char *format; 43 - long rate; 44 - long channels; 45 - long period_size; 46 - long buffer_size; 47 - }; 48 - 49 40 void timestamp_now(timestamp_t *tstamp) 50 41 { 51 42 if (clock_gettime(CLOCK_MONOTONIC_RAW, tstamp)) ··· 220 229 } 221 230 222 231 static void test_pcm_time1(struct pcm_data *data, 223 - const struct time_test_def *test) 232 + const char *cfg_prefix, const char *sformat, 233 + long srate, long schannels, 234 + long speriod_size, long sbuffer_size) 224 235 { 225 236 char name[64], key[128], msg[256]; 226 237 const char *cs; ··· 234 241 snd_pcm_sframes_t frames; 235 242 long long ms; 236 243 long rate, channels, period_size, buffer_size; 237 - unsigned int rchannels; 238 244 unsigned int rrate; 239 245 snd_pcm_uframes_t rperiod_size, rbuffer_size, start_threshold; 240 246 timestamp_t tstamp; 241 247 bool pass = false, automatic = true; 242 248 snd_pcm_hw_params_t *hw_params; 243 249 snd_pcm_sw_params_t *sw_params; 244 - bool skip = false; 245 250 246 251 snd_pcm_hw_params_alloca(&hw_params); 247 252 snd_pcm_sw_params_alloca(&sw_params); 248 253 249 - cs = conf_get_string(data->pcm_config, test->cfg_prefix, "format", test->format); 254 + cs = conf_get_string(data->pcm_config, cfg_prefix, "format", sformat); 250 255 format = snd_pcm_format_value(cs); 251 256 if (format == SND_PCM_FORMAT_UNKNOWN) 252 257 ksft_exit_fail_msg("Wrong format '%s'\n", cs); 253 - rate = conf_get_long(data->pcm_config, test->cfg_prefix, "rate", test->rate); 254 - channels = conf_get_long(data->pcm_config, test->cfg_prefix, "channels", test->channels); 255 - period_size = conf_get_long(data->pcm_config, test->cfg_prefix, "period_size", test->period_size); 256 - buffer_size = conf_get_long(data->pcm_config, test->cfg_prefix, "buffer_size", test->buffer_size); 258 + rate = conf_get_long(data->pcm_config, cfg_prefix, "rate", srate); 259 + channels = conf_get_long(data->pcm_config, cfg_prefix, "channels", schannels); 260 + period_size = conf_get_long(data->pcm_config, cfg_prefix, "period_size", speriod_size); 261 + buffer_size = conf_get_long(data->pcm_config, cfg_prefix, "buffer_size", sbuffer_size); 257 262 258 - automatic = strcmp(test->format, snd_pcm_format_name(format)) == 0 && 259 - test->rate == rate && 260 - test->channels == channels && 261 - test->period_size == period_size && 262 - test->buffer_size == buffer_size; 263 + automatic = strcmp(sformat, snd_pcm_format_name(format)) == 0 && 264 + srate == rate && 265 + schannels == channels && 266 + speriod_size == period_size && 267 + sbuffer_size == buffer_size; 263 268 264 269 samples = malloc((rate * channels * snd_pcm_format_physical_width(format)) / 8); 265 270 if (!samples) ··· 293 302 if (automatic && format == SND_PCM_FORMAT_S16_LE) { 294 303 format = SND_PCM_FORMAT_S32_LE; 295 304 ksft_print_msg("%s.%d.%d.%d.%s.%s format S16_LE -> S32_LE\n", 296 - test->cfg_prefix, 305 + cfg_prefix, 297 306 data->card, data->device, data->subdevice, 298 307 snd_pcm_stream_name(data->stream), 299 308 snd_pcm_access_name(access)); ··· 302 311 snd_pcm_format_name(format), snd_strerror(err)); 303 312 goto __close; 304 313 } 305 - rchannels = channels; 306 - err = snd_pcm_hw_params_set_channels_near(handle, hw_params, &rchannels); 314 + err = snd_pcm_hw_params_set_channels(handle, hw_params, channels); 307 315 if (err < 0) { 308 316 snprintf(msg, sizeof(msg), "snd_pcm_hw_params_set_channels %ld: %s", channels, snd_strerror(err)); 309 - goto __close; 310 - } 311 - if (rchannels != channels) { 312 - snprintf(msg, sizeof(msg), "channels unsupported %ld != %ld", channels, rchannels); 313 - skip = true; 314 317 goto __close; 315 318 } 316 319 rrate = rate; ··· 314 329 goto __close; 315 330 } 316 331 if (rrate != rate) { 317 - snprintf(msg, sizeof(msg), "rate unsupported %ld != %ld", rate, rrate); 318 - skip = true; 332 + snprintf(msg, sizeof(msg), "rate mismatch %ld != %ld", rate, rrate); 319 333 goto __close; 320 334 } 321 335 rperiod_size = period_size; ··· 362 378 } 363 379 364 380 ksft_print_msg("%s.%d.%d.%d.%s hw_params.%s.%s.%ld.%ld.%ld.%ld sw_params.%ld\n", 365 - test->cfg_prefix, 381 + cfg_prefix, 366 382 data->card, data->device, data->subdevice, 367 383 snd_pcm_stream_name(data->stream), 368 384 snd_pcm_access_name(access), ··· 410 426 msg[0] = '\0'; 411 427 pass = true; 412 428 __close: 413 - if (!skip) { 414 - ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n", 415 - test->cfg_prefix, 416 - data->card, data->device, data->subdevice, 417 - snd_pcm_stream_name(data->stream), 418 - msg[0] ? " " : "", msg); 419 - } else { 420 - ksft_test_result_skip("%s.%d.%d.%d.%s%s%s\n", 421 - test->cfg_prefix, 422 - data->card, data->device, 423 - data->subdevice, 424 - snd_pcm_stream_name(data->stream), 425 - msg[0] ? " " : "", msg); 426 - } 429 + ksft_test_result(pass, "%s.%d.%d.%d.%s%s%s\n", 430 + cfg_prefix, 431 + data->card, data->device, data->subdevice, 432 + snd_pcm_stream_name(data->stream), 433 + msg[0] ? " " : "", msg); 427 434 free(samples); 428 435 if (handle) 429 436 snd_pcm_close(handle); 430 437 } 431 438 432 - static const struct time_test_def time_tests[] = { 433 - /* name format rate chan period buffer */ 434 - { "8k.1.big", "S16_LE", 8000, 2, 8000, 32000 }, 435 - { "8k.2.big", "S16_LE", 8000, 2, 8000, 32000 }, 436 - { "44k1.2.big", "S16_LE", 44100, 2, 22050, 192000 }, 437 - { "48k.2.small", "S16_LE", 48000, 2, 512, 4096 }, 438 - { "48k.2.big", "S16_LE", 48000, 2, 24000, 192000 }, 439 - { "48k.6.big", "S16_LE", 48000, 6, 48000, 576000 }, 440 - { "96k.2.big", "S16_LE", 96000, 2, 48000, 192000 }, 441 - }; 439 + #define TESTS_PER_PCM 2 442 440 443 441 int main(void) 444 442 { 445 443 struct pcm_data *pcm; 446 - int i; 447 444 448 445 ksft_print_header(); 449 446 ··· 432 467 433 468 find_pcms(); 434 469 435 - ksft_set_plan(num_missing + num_pcms * ARRAY_SIZE(time_tests)); 470 + ksft_set_plan(num_missing + num_pcms * TESTS_PER_PCM); 436 471 437 472 for (pcm = pcm_missing; pcm != NULL; pcm = pcm->next) { 438 473 ksft_test_result(false, "test.missing.%d.%d.%d.%s\n", ··· 441 476 } 442 477 443 478 for (pcm = pcm_list; pcm != NULL; pcm = pcm->next) { 444 - for (i = 0; i < ARRAY_SIZE(time_tests); i++) { 445 - test_pcm_time1(pcm, &time_tests[i]); 446 - } 479 + test_pcm_time1(pcm, "test.time1", "S16_LE", 48000, 2, 512, 4096); 480 + test_pcm_time1(pcm, "test.time2", "S16_LE", 48000, 2, 24000, 192000); 447 481 } 448 482 449 483 conf_free();