[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] added more return value checks for c_api tests
From: |
Andrei Kholodnyi |
Subject: |
[PATCH 3/3] added more return value checks for c_api tests |
Date: |
Sun, 26 Sep 2010 23:10:53 +0200 |
return value is checked now for all libspeechd functions used
---
src/tests/clibrary.c | 42 ++++++++++++++++++++++++++++++++++--------
src/tests/clibrary2.c | 28 ++++++++++++++++++++--------
src/tests/long_message.c | 24 +++++++++++++++++++-----
3 files changed, 73 insertions(+), 21 deletions(-)
diff --git a/src/tests/clibrary.c b/src/tests/clibrary.c
index 2e168ca..478deaf 100644
--- a/src/tests/clibrary.c
+++ b/src/tests/clibrary.c
@@ -34,7 +34,7 @@
int main() {
SPDConnection* conn;
- int i;
+ int i, ret;
printf("Start of the test of the test.\n");
@@ -48,16 +48,34 @@ int main() {
printf("Say inviting message\n");
- spd_say(conn, SPD_MESSAGE, "Hello, how are you? I'm Speech Deamon");
-
+ ret = spd_say(conn, SPD_MESSAGE, "Hello, how are you? I'm Speech Deamon");
+ if (ret == -1) {
+ printf("spd_say failed");
+ exit(1);
+ }
+
sleep(4);
printf("\n");
printf("Try to lower pitch and higher rate...\n");
- spd_set_voice_pitch(conn, -20);
- spd_set_voice_rate(conn, +20);
+ ret = spd_set_voice_pitch(conn, -20);
+ if (ret == -1) {
+ printf("spd_set_voice_pitch failed");
+ exit(1);
+ }
+
+ ret = spd_set_voice_rate(conn, +20);
+ if (ret == -1) {
+ printf("spd_set_voice_rate failed");
+ exit(1);
+ }
+
printf("...and say something\n");
- spd_say(conn, SPD_MESSAGE, "Do you like this voice more?");
+ ret = spd_say(conn, SPD_MESSAGE, "Do you like this voice more?");
+ if (ret == -1) {
+ printf("spd_say failed");
+ exit(1);
+ }
sleep(4);
@@ -72,11 +90,19 @@ int main() {
sleep(10);
- spd_set_voice_rate(conn, +90);
+ ret = spd_set_voice_rate(conn, +90);
+ if (ret == -1) {
+ printf("spd_set_voice_rate failed");
+ exit(1);
+ }
for (i = 0; i<= 100; i++){
printf("%d%% completed\n", i);
- spd_sayf(conn, SPD_PROGRESS, "%d%% completed", i);
+ ret = spd_sayf(conn, SPD_PROGRESS, "%d%% completed", i);
+ if (ret == -1) {
+ printf("spd_sayf failed");
+ exit(1);
+ }
}
printf("Trying to close Speech Dispatcher connection...");
diff --git a/src/tests/clibrary2.c b/src/tests/clibrary2.c
index 0caba87..6110102 100644
--- a/src/tests/clibrary2.c
+++ b/src/tests/clibrary2.c
@@ -34,7 +34,7 @@
int main() {
SPDConnection* conn;
- int i,j ;
+ int i, j, ret;
char **modules;
char **voices;
SPDVoice **synth_voices;
@@ -52,7 +52,7 @@ int main() {
modules = spd_list_modules(conn);
if (modules == NULL){
printf("Can't list modules\n");
- exit(0);
+ exit(1);
}
printf("Available output modules:\n");
@@ -64,7 +64,7 @@ int main() {
voices = spd_list_voices(conn);
if (voices == NULL){
printf("Can't list voices\n");
- exit(0);
+ exit(1);
}
printf("Available symbolic voices:\n");
@@ -75,12 +75,16 @@ int main() {
for (j=0; ;j++){
if (modules[j] == NULL) break;
- spd_set_output_module(conn, modules[j]);
+ ret = spd_set_output_module(conn, modules[j]);
+ if (ret == -1) {
+ printf("spd_set_output_module failed");
+ exit(1);
+ }
printf("\nListing voices for %s\n", modules[j]);
synth_voices = spd_list_synthesis_voices(conn);
if (synth_voices == NULL){
printf("Can't list voices\n");
- exit(0);
+ exit(1);
}
printf("Available synthesis voices:\n");
for (i=0;;i++){
@@ -89,8 +93,17 @@ int main() {
printf(" name: %s language: %s variant: %s\n",
synth_voices[i]->name, synth_voices[i]->language,
synth_voices[i]->variant);
- spd_set_synthesis_voice(conn, synth_voices[i]->name);
- spd_say(conn, SPD_TEXT, "test");
+ ret = spd_set_synthesis_voice(conn, synth_voices[i]->name);
+ if (ret == -1) {
+ printf("spd_set_synthesis_voice failed");
+ exit(1);
+ }
+
+ ret = spd_say(conn, SPD_TEXT, "test");
+ if (ret == -1) {
+ printf("spd_say failed");
+ exit(1);
+ }
sleep(1);
}
}
@@ -102,4 +115,3 @@ int main() {
printf("End of the test.\n");
exit(0);
}
-
diff --git a/src/tests/long_message.c b/src/tests/long_message.c
index ab66e1c..cdf9325 100644
--- a/src/tests/long_message.c
+++ b/src/tests/long_message.c
@@ -32,7 +32,8 @@
#include "libspeechd.h"
int main() {
- SPDConnection *sockfd;
+ SPDConnection *sockfd;
+ int ret;
printf("Start of the test.\n");
@@ -41,13 +42,17 @@ int main() {
if (sockfd == 0){
printf("Speech Dispatcher failed");
exit(1);
- }
+ }
printf("OK\n");
- spd_cancel(sockfd);
+ ret = spd_cancel(sockfd);
+ if (ret == -1) {
+ printf("spd_cancel failed");
+ exit(1);
+ }
printf("Sending message number 1, text \n");
- spd_say(sockfd, SPD_MESSAGE, ""
+ ret = spd_say(sockfd, SPD_MESSAGE, ""
" \n"
" ALICE'S ADVENTURES IN WONDERLAND by Lewis Carroll.\n"
"\n"
@@ -268,8 +273,13 @@ int main() {
"\n"
" So she set to work, and very soon finished off the cake. ");
+ if (ret == -1) {
+ printf("spd_say failed");
+ exit(1);
+ }
+
printf("Sending message number 2, code (ugly characters) \n");
- spd_say(sockfd, SPD_MESSAGE, "\n"
+ ret = spd_say(sockfd, SPD_MESSAGE, "\n"
"\n"
"int\n"
"stop_p3(){\n"
@@ -382,6 +392,10 @@ int main() {
" else return 1;\n"
"}\n"
" ");
+ if (ret == -1) {
+ printf("spd_say failed");
+ exit(1);
+ }
printf("Trying to close Speech Dispatcher connection...");
spd_close(sockfd);
--
1.6.0.4
[PATCH 1/3] added autotest support, William Hubbs, 2010/09/26
- [PATCH 1/3] added autotest support, William Hubbs, 2010/09/26
- [PATCH 1/3] added autotest support, Andrei Kholodnyi, 2010/09/27
- [PATCH 1/3] added autotest support, William Hubbs, 2010/09/27
- [PATCH 1/3] added autotest support, Andrei Kholodnyi, 2010/09/27
- [PATCH 1/3] added autotest support, Andrei Kholodnyi, 2010/09/27
- [PATCH 1/3] added autotest support, William Hubbs, 2010/09/27