@samitouri / QOSamiQemu / commits / ac8d4cf5f5

tests/audio: add an invalid settings test

As we are going to change the related code next. Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Jan 21, 2026 at 18:17 UTC ac8d4cf5f5eb9396c15e081ff0948707022cd52b
1 file changed +21
tests/audio/test-audio.c
+21
@@ -534,6 +534,26 @@ static void test_audio_multiple_voices(void)
534 audio_be_close_out(be, out1);
535 }
536
537 +static const struct audsettings invalid_test_settings = {
538 + .nchannels = 0,
539 + .freq = SAMPLE_RATE,
540 + .fmt = AUDIO_FORMAT_S16,
541 + .big_endian = false,
542 +};
543 +
544 +static void test_audio_invalid_settings(void)
545 +{
546 + AudioBackend *be = get_test_audio_backend();
547 + void *voice;
548 +
549 + voice = audio_be_open_out(be, NULL, "invalid", NULL,
550 + dummy_audio_callback, &invalid_test_settings);
551 + g_assert_null(voice);
552 + voice = audio_be_open_in(be, NULL, "invalid", NULL,
553 + dummy_audio_callback, &invalid_test_settings);
554 + g_assert_null(voice);
555 +}
556 +
557 int main(int argc, char **argv)
558 {
559 GOptionContext *context;
@@ -589,6 +609,7 @@ int main(int argc, char **argv)
609
610 g_test_add_func("/audio/null-handling", test_audio_null_handling);
611 g_test_add_func("/audio/multiple-voices", test_audio_multiple_voices);
612 + g_test_add_func("/audio/invalid-settings", test_audio_invalid_settings);
613
614 ret = g_test_run();
615