1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gmyth/tests/gmyth_test_connection.c Wed Jan 10 20:50:38 2007 +0000
1.3 @@ -0,0 +1,57 @@
1.4 +#include <glib-object.h>
1.5 +
1.6 +#include "gmyth_uri.h"
1.7 +#include "gmyth_backendinfo.h"
1.8 +#include "gmyth_socket.h"
1.9 +#include "gmyth_query.h"
1.10 +
1.11 +static gboolean
1.12 +test_backend_connection1 (GMythBackendInfo *backend_info)
1.13 +{
1.14 + GMythSocket *socket = gmyth_socket_new ();
1.15 + if (gmyth_socket_connect (socket,
1.16 + gmyth_backend_info_get_hostname (backend_info),
1.17 + gmyth_backend_info_get_port (backend_info)) == TRUE) {
1.18 + g_debug ("Connection success");
1.19 + return TRUE;
1.20 + } else {
1.21 + g_debug ("Connection failed");
1.22 + return FALSE;
1.23 + }
1.24 +}
1.25 +
1.26 +static gboolean
1.27 +test_mysql_connection1 (GMythBackendInfo *backend_info)
1.28 +{
1.29 + GMythQuery *query = gmyth_query_new ();
1.30 +
1.31 + if (gmyth_query_connect (query, backend_info) == TRUE) {
1.32 + g_debug ("Mysql connection success");
1.33 + return TRUE;
1.34 + } else {
1.35 + g_debug ("Mysql connection failed");
1.36 + return FALSE;
1.37 + }
1.38 +
1.39 +}
1.40 +
1.41 +
1.42 +int
1.43 +main (int args, const char **argv)
1.44 +{
1.45 + const char* uri = argv[1];
1.46 +
1.47 + GMythBackendInfo *backend_info;
1.48 + g_type_init ();
1.49 + g_thread_init (NULL);
1.50 +
1.51 + backend_info = gmyth_backend_info_new_with_uri (argv[1]);
1.52 +
1.53 + test_backend_connection1 (backend_info);
1.54 +
1.55 + test_mysql_connection1 (backend_info);
1.56 +}
1.57 +
1.58 +
1.59 +
1.60 +