gmyth/tests/gmyth_test_connection.c
author melunko
Wed Jan 10 21:47:24 2007 +0000 (2007-01-10)
branchtrunk
changeset 257 86e15690a104
parent 254 09623a8c3172
child 258 835d5cc01a0a
permissions -rw-r--r--
[svn r258] Added gmyth_query and gmyth_scheduler connection methods with timeout. Besides, configura.ac now checks libmysqlclient in the right way
     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 (socket, 
    13 	    gmyth_backend_info_get_hostname (backend_info),
    14 	    gmyth_backend_info_get_port (backend_info)) == TRUE) {
    15 	g_debug ("Connection success");
    16 	return TRUE;
    17     } else {
    18 	g_debug ("Connection failed");
    19 	return FALSE;
    20     }
    21 }
    22 
    23 static gboolean
    24 test_mysql_connection1 (GMythBackendInfo *backend_info)
    25 {
    26     GMythQuery *query = gmyth_query_new ();
    27 
    28     if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) {
    29 	g_debug ("Mysql connection success");
    30 	return TRUE;
    31     } else {
    32 	g_debug ("Mysql connection failed");
    33 	return FALSE;
    34     }
    35        
    36 }
    37 
    38 
    39 int
    40 main (int args, const char **argv)
    41 {
    42     const char* uri = argv[1];
    43 
    44     GMythBackendInfo *backend_info;
    45     g_type_init ();
    46     g_thread_init (NULL);
    47 
    48     backend_info = gmyth_backend_info_new_with_uri (argv[1]);
    49 
    50     test_mysql_connection1 (backend_info);
    51     test_backend_connection1 (backend_info);
    52 }
    53 
    54 
    55 
    56