From: <svn...@op...> - 2009-07-13 12:51:35
|
Author: bellmich Date: Mon Jul 13 14:51:30 2009 New Revision: 1189 URL: http://libsyncml.opensync.org/changeset/1189 Log: fixed wrong error handling in HTTP tests Modified: trunk/tests/check_http.c trunk/tests/check_libsoup.c Modified: trunk/tests/check_http.c ============================================================================== --- trunk/tests/check_http.c Mon Jul 13 14:47:56 2009 (r1188) +++ trunk/tests/check_http.c Mon Jul 13 14:51:30 2009 (r1189) @@ -73,10 +73,10 @@ sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlTransportSetConfigOption(tsp, "URL", "http://libsyncml.opensyncml.org", &error), "%s", error->message); + sml_fail_unless(smlTransportSetConfigOption(tsp, "URL", "http://libsyncml.opensyncml.org", &error), "%s", GET_ERROR_MESSAGE(error)); - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(smlTransportFinalize(tsp, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -125,11 +125,11 @@ sml_fail_unless(error == NULL, NULL); /* The transport is not configured but libsoup can initialize a default client */ - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); - sml_fail_unless(smlTransportFinalize(tsp, &error), "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportFinalize(tsp, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); smlTransportFree(tsp); } @@ -211,9 +211,9 @@ if (GPOINTER_TO_INT(userdata) == 1) { data = smlTransportDataNew((char *)"answer", 7, SML_MIMETYPE_WBXML, FALSE, &locerror); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(locerror == NULL, "%s", locerror->message); + sml_fail_unless(locerror == NULL, "%s", GET_ERROR_MESSAGE(locerror)); - sml_fail_unless(smlTransportSend(tsp, link_, data, &locerror), "%s", locerror->message); + sml_fail_unless(smlTransportSend(tsp, link_, data, &locerror), "%s", GET_ERROR_MESSAGE(locerror)); smlTransportDataDeref(data); } else if (GPOINTER_TO_INT(userdata) == 2) { @@ -222,7 +222,7 @@ smlTransportSendError(tsp, link_, newerror); SML_ERROR_FREE(newerror); } else if (GPOINTER_TO_INT(userdata) == 3) { - sml_fail_unless(smlTransportDisconnect(tsp, link_, &locerror), "%s", locerror->message); + sml_fail_unless(smlTransportDisconnect(tsp, link_, &locerror), "%s", GET_ERROR_MESSAGE(locerror)); } else { sml_fail_unless(FALSE, "Some unexpected userdata %i was detected.", GPOINTER_TO_INT(userdata)); } @@ -262,8 +262,8 @@ smlTransportSetEventCallback(tsp, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(smlTransportFinalize(tsp, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -287,8 +287,8 @@ SML_ERROR_FREE(error); /* The default config of libsoup can be used to setup a valid transport. */ - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(smlTransportFinalize(tsp, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -312,8 +312,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(smlTransportConnect(client, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -325,7 +325,7 @@ /* disconnect the client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(error == NULL, NULL); while (client_disconnects == 0) { usleep(50); }; @@ -358,8 +358,8 @@ smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -373,7 +373,7 @@ /* disconnect client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); while(client_disconnects < 1) { usleep(50); } /* disconnect server */ @@ -407,8 +407,8 @@ smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(3)); smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -457,8 +457,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -478,7 +478,7 @@ /* disconnect client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); while(client_disconnects < 1) { usleep(50); } /* disconnect server */ @@ -511,8 +511,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = NULL; @@ -539,7 +539,7 @@ /* disconnect client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); while(client_disconnects < 1) { usleep(50); } /* disconnect server */ @@ -579,7 +579,7 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -618,8 +618,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(2)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -647,7 +647,7 @@ sml_fail_unless(server_disconnects == 1, NULL); sml_fail_unless(smlTransportFinalize(client, &error), NULL); - sml_fail_unless(smlTransportFinalize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportFinalize(server, &error), "%s", GET_ERROR_MESSAGE(error)); smlTransportFree(client); smlTransportFree(server); @@ -675,10 +675,10 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -716,9 +716,9 @@ sml_fail_unless(client_receives == 3, NULL); sml_fail_unless(server_receives == 3, NULL); - sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", error->message); - sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", error->message); - sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); while (client_disconnects < 3) { usleep(100); }; @@ -731,7 +731,7 @@ * that the list will be cleaned up before * this for-loop ends */ - sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", GET_ERROR_MESSAGE(error)); while (server_disconnects < 3 - i + 1) { usleep(100); } @@ -775,10 +775,10 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -818,7 +818,7 @@ sml_fail_unless(client_errors == 2, NULL); sml_fail_unless(server_receives == 3, NULL); - sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); while (client_disconnects < 1) { usleep(100); } @@ -831,7 +831,7 @@ * that the list will be cleaned up before * this for-loop ends */ - sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", GET_ERROR_MESSAGE(error)); while (server_disconnects < 3 - i + 1) { usleep(100); } @@ -876,10 +876,10 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", GET_ERROR_MESSAGE(error)); SmlTransportData *data = NULL; @@ -924,9 +924,9 @@ sml_fail_unless(client_receives == 3 * num, NULL); sml_fail_unless(server_receives == 3 * num, NULL); - sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", error->message); - sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", error->message); - sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); for (i = g_list_length(links); i > 0; i--) { /* start to disconnect from the end * to avoid conflicts with very fast SMP machines @@ -934,7 +934,7 @@ * that the list will be cleaned up before * this for-loop ends */ - sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", GET_ERROR_MESSAGE(error)); while (server_disconnects < (3 * num - i + 1)) { usleep(100); } Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Mon Jul 13 14:47:56 2009 (r1188) +++ trunk/tests/check_libsoup.c Mon Jul 13 14:51:30 2009 (r1189) @@ -148,12 +148,12 @@ server_ctx = g_main_context_new(); sml_fail_unless(server_ctx != NULL, NULL); server_thread = smlThreadNew(server_ctx, &error); - sml_fail_unless(server_thread != NULL, "%s", error->message); + sml_fail_unless(server_thread != NULL, "%s", GET_ERROR_MESSAGE(error)); /* simulate the transport layer behaviour */ queue = smlQueueNew(&error); - sml_fail_unless(queue != NULL, "%s", error->message); + sml_fail_unless(queue != NULL, "%s", GET_ERROR_MESSAGE(error)); smlQueueSetHandler(queue, (SmlQueueHandler)transport_dummy_callback, NULL); smlQueueAttach(queue, server_ctx); @@ -296,7 +296,7 @@ SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); sml_fail_unless(smlTransportSetConfigOption(client, "URL", url, &error), NULL); smlTransportSetEventCallback(client, _recv_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", GET_ERROR_MESSAGE(error)); /* send test message */ @@ -323,7 +323,7 @@ /* cleanup client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); sleep_total = 0; while (client_disconnects < 1 && client_errors < 1 && sleep_total < sleep_max) { @@ -405,10 +405,10 @@ client_ctx = g_main_context_new(); sml_fail_unless(client_ctx != NULL, NULL); SmlThread *client_thread = smlThreadNew(client_ctx, &error); - sml_fail_unless(client_thread != NULL, "%s", error->message); + sml_fail_unless(client_thread != NULL, "%s", GET_ERROR_MESSAGE(error)); smlThreadStart(client_thread); - sml_fail_unless(smlThreadCallFunction(client_thread, init_soup_session, msg, &error), "%s", error->message); + sml_fail_unless(smlThreadCallFunction(client_thread, init_soup_session, msg, &error), "%s", GET_ERROR_MESSAGE(error)); #endif /* test and cleanup server */ @@ -432,7 +432,7 @@ #else /* cleanup session */ - sml_fail_unless(smlThreadCallFunction(client_thread, cleanup_soup_session, NULL, &error), "%s", error->message); + sml_fail_unless(smlThreadCallFunction(client_thread, cleanup_soup_session, NULL, &error), "%s", GET_ERROR_MESSAGE(error)); /* The client thread must be stopped first * because libsoup is not thread safe. @@ -471,10 +471,10 @@ /* init server transport */ SmlTransport *serverTsp = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); - sml_fail_unless(serverTsp != NULL, "%s", error->message); + sml_fail_unless(serverTsp != NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(smlTransportSetConfigOption(serverTsp, "PORT", "13003", &error), NULL); smlTransportSetEventCallback(serverTsp, _recv_event, GINT_TO_POINTER(2)); - sml_fail_unless(smlTransportInitialize(serverTsp, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(serverTsp, &error), "%s", GET_ERROR_MESSAGE(error)); /* client stuff */ |