From bfdf900f97b1185509e2b266f29ffe51f56b3d5b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 21 Aug 2026 00:33:44 +0200 Subject: [PATCH] tests: print error message on spd_open failure --- src/tests/clibrary.c | 5 +++-- src/tests/clibrary2.c | 11 ++++++----- src/tests/connection-recovery.c | 10 +++++++--- src/tests/long_message.c | 5 +++-- src/tests/spd_cancel_long_message.c | 5 +++-- src/tests/spd_set_notifications_all.c | 5 +++-- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/tests/clibrary.c b/src/tests/clibrary.c index 0db6cacf6..92417b564 100644 --- a/src/tests/clibrary.c +++ b/src/tests/clibrary.c @@ -37,13 +37,14 @@ int main() SPDConnection *conn; int i, ret; + char *error; printf("Start of the test of the test.\n"); printf("Trying to initialize Speech Daemon...\n"); - conn = spd_open("say", NULL, NULL, SPD_MODE_SINGLE); + conn = spd_open2("say", NULL, NULL, SPD_MODE_SINGLE, NULL, 1, &error); if (conn == 0) { - printf("Speech Daemon failed.\n"); + printf("Speech Daemon failed:\n%s\n", error); exit(1); } printf("OK\n"); diff --git a/src/tests/clibrary2.c b/src/tests/clibrary2.c index 3fec491c4..7a42a1ceb 100644 --- a/src/tests/clibrary2.c +++ b/src/tests/clibrary2.c @@ -52,6 +52,7 @@ int main() char **voices; char *module; char *language; + char *error; int value; SPDVoiceType voice_type = SPD_CHILD_MALE; SPDVoice **synth_voices; @@ -72,15 +73,15 @@ int main() printf("Start of the test.\n"); printf("Trying to initialize Speech Daemon...\n"); - conn = spd_open("say", NULL, NULL, + conn = spd_open2("say", NULL, NULL, #ifdef THOROUGH - SPD_MODE_THREADED + SPD_MODE_THREADED, #else - SPD_MODE_SINGLE + SPD_MODE_SINGLE, #endif - ); + NULL, 1, &error); if (conn == 0) { - printf("Speech Daemon failed\n"); + printf("Speech Daemon failed:\n%s\n", error); exit(1); } printf("OK\n"); diff --git a/src/tests/connection-recovery.c b/src/tests/connection-recovery.c index fa51eb430..cc2ae5895 100644 --- a/src/tests/connection-recovery.c +++ b/src/tests/connection-recovery.c @@ -36,14 +36,17 @@ SPDConnection *try_to_reconnect(void) { SPDConnection *conn; while (1) { + char *error; printf("Trying to reconnect\n"); usleep(1000); - conn = spd_open("test", NULL, NULL, SPD_MODE_THREADED); + conn = spd_open2("test", NULL, NULL, SPD_MODE_THREADED, NULL, 1, &error); if (conn != NULL) { spd_say(conn, SPD_MESSAGE, "Reconnect successful"); printf("Reconnect successful\n"); return conn; } + printf("Reconnect failed:\n%s\n", error); + free(error); } } @@ -53,10 +56,11 @@ int main(void) int i = 0; int failures = 0; int ret; + char *error; - conn = spd_open("test", NULL, NULL, SPD_MODE_THREADED); + conn = spd_open2("test", NULL, NULL, SPD_MODE_THREADED, NULL, 1, &error); if (conn == 0) { - printf("Speech Daemon failed\n"); + printf("Speech Daemon failed:\n%s\n", error); exit(1); } diff --git a/src/tests/long_message.c b/src/tests/long_message.c index b4e8c79eb..60b1de36e 100644 --- a/src/tests/long_message.c +++ b/src/tests/long_message.c @@ -34,13 +34,14 @@ int main() { SPDConnection *sockfd; int ret; + char *error; printf("Start of the test.\n"); printf("Trying to initialize Speech Dispatcher...\n"); - sockfd = spd_open("test", NULL, NULL, SPD_MODE_SINGLE); + sockfd = spd_open2("test", NULL, NULL, SPD_MODE_SINGLE, NULL, 1, &error); if (sockfd == 0) { - printf("Speech Dispatcher failed\n"); + printf("Speech Daemon failed:\n%s\n", error); exit(1); } printf("OK\n"); diff --git a/src/tests/spd_cancel_long_message.c b/src/tests/spd_cancel_long_message.c index 30590d1fd..0e35d05a6 100644 --- a/src/tests/spd_cancel_long_message.c +++ b/src/tests/spd_cancel_long_message.c @@ -49,11 +49,12 @@ static void notification_cb(size_t msg_id, size_t client_id, int main(int argc, char *argv[]) { int result, count; + char *error; /* Open Speech Dispatcher connection */ - spd = spd_open(TEST_NAME, __FUNCTION__, NULL, SPD_MODE_THREADED); + spd = spd_open2(TEST_NAME, __FUNCTION__, NULL, SPD_MODE_THREADED, NULL, 1, &error); if (!spd) { - printf("Speech-dispatcher: Failed to open connection. \n"); + printf("Speech-dispatcher: Failed to open connection:\n%s\n", error); exit(1); } diff --git a/src/tests/spd_set_notifications_all.c b/src/tests/spd_set_notifications_all.c index 84824ea11..1ef852993 100644 --- a/src/tests/spd_set_notifications_all.c +++ b/src/tests/spd_set_notifications_all.c @@ -55,11 +55,12 @@ void index_mark_cb(size_t msg_id, size_t client_id, SPDNotificationType type, int main(int argc, char *argv[]) { int result, count; + char *error; /* Open Speech Dispatcher connection in THREADED mode. */ - spd = spd_open(TEST_NAME, __FUNCTION__, NULL, SPD_MODE_THREADED); + spd = spd_open2(TEST_NAME, __FUNCTION__, NULL, SPD_MODE_THREADED, NULL, 1, &error); if (!spd) { - printf("Speech-dispatcher: Failed to open connection. \n"); + printf("Speech-dispatcher: Failed to open connection:\n%s\n", error); exit(1); }