branches/gmyth-0.1b/tests/gmyth_test_connection.c
author rosfran
Thu Feb 08 14:30:36 2007 +0000 (2007-02-08)
branchtrunk
changeset 335 aedcbbf818b7
permissions -rw-r--r--
[svn r337] Changed the g_object_unref's in the do_get_file_info.
     1 #include <glib-object.h>
     2 
     3 #include "gmyth_uri.h"
     4 #include "gmyth_backendinfo.h"
     5 #include "gmyth_socket.h"
     6 #include "gmyth_query.h"
     7 
     8 static gboolean
     9 test_backend_connection1 (GMythBackendInfo *backend_info)
    10 {
    11     GMythSocket *socket = gmyth_socket_new ();
    12     if (gmyth_socket_connect_with_timeout (socket, 
    13 	    gmyth_backend_info_get_hostname (backend_info),
    14 	    gmyth_backend_info_get_port (backend_info), 4) == TRUE) {
    15 	g_debug ("Socket connection success");
    16 	return TRUE;
    17     } else {
    18 	g_debug ("Connection failed");
    19 	return FALSE;
    20     }
    21 }
    22 
    23 static gboolean
    24 test_backend_connection2 (GMythBackendInfo *backend_info)
    25 {
    26     GMythSocket *socket = gmyth_socket_new ();
    27     if (gmyth_socket_connect_to_backend (socket,
    28 	    gmyth_backend_info_get_hostname (backend_info),
    29 	    gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) {
    30 
    31 		    
    32 	g_debug ("Backend socket connection success");
    33 	return TRUE;
    34     } else {
    35 	g_debug ("Connection failed");
    36 	return FALSE;
    37     }
    38 }
    39 
    40 static gboolean
    41 test_mysql_connection1 (GMythBackendInfo *backend_info)
    42 {
    43     GMythQuery *query = gmyth_query_new ();
    44 
    45     if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) {
    46 	g_debug ("Mysql connection success");
    47 	return TRUE;
    48     } else {
    49 	g_debug ("Mysql connection failed");
    50 	return FALSE;
    51     }
    52        
    53 }
    54 
    55 
    56 int
    57 main (int args, const char **argv)
    58 {
    59     const char* uri = argv[1];
    60 
    61     GMythBackendInfo *backend_info;
    62     g_type_init ();
    63     //g_thread_init (NULL);
    64 
    65     backend_info = gmyth_backend_info_new_with_uri (argv[1]);
    66 
    67     test_backend_connection1 (backend_info);
    68     test_backend_connection2 (backend_info);
    69     test_mysql_connection1 (backend_info);
    70 }
    71 
    72 
    73 
    74