diff -r 000000000000 -r b00705a84ffe branches/gmyth-0.1b/tests/gmyth_test_connection.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/branches/gmyth-0.1b/tests/gmyth_test_connection.c Thu Feb 08 23:07:59 2007 +0000 @@ -0,0 +1,74 @@ +#include + +#include "gmyth_uri.h" +#include "gmyth_backendinfo.h" +#include "gmyth_socket.h" +#include "gmyth_query.h" + +static gboolean +test_backend_connection1 (GMythBackendInfo *backend_info) +{ + GMythSocket *socket = gmyth_socket_new (); + if (gmyth_socket_connect_with_timeout (socket, + gmyth_backend_info_get_hostname (backend_info), + gmyth_backend_info_get_port (backend_info), 4) == TRUE) { + g_debug ("Socket connection success"); + return TRUE; + } else { + g_debug ("Connection failed"); + return FALSE; + } +} + +static gboolean +test_backend_connection2 (GMythBackendInfo *backend_info) +{ + GMythSocket *socket = gmyth_socket_new (); + if (gmyth_socket_connect_to_backend (socket, + gmyth_backend_info_get_hostname (backend_info), + gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) { + + + g_debug ("Backend socket connection success"); + return TRUE; + } else { + g_debug ("Connection failed"); + return FALSE; + } +} + +static gboolean +test_mysql_connection1 (GMythBackendInfo *backend_info) +{ + GMythQuery *query = gmyth_query_new (); + + if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) { + g_debug ("Mysql connection success"); + return TRUE; + } else { + g_debug ("Mysql connection failed"); + return FALSE; + } + +} + + +int +main (int args, const char **argv) +{ + const char* uri = argv[1]; + + GMythBackendInfo *backend_info; + g_type_init (); + //g_thread_init (NULL); + + backend_info = gmyth_backend_info_new_with_uri (argv[1]); + + test_backend_connection1 (backend_info); + test_backend_connection2 (backend_info); + test_mysql_connection1 (backend_info); +} + + + +