# HG changeset patch # User rosfran # Date 1177512641 -3600 # Node ID f36075170a4e9f4afe52fa15f556562a06d91550 # Parent 95263ab433f1d5848421faa992b5e80d18ba64f5 [svn r600] Added clean-up code to the GMyth test cases. diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/gmyth_test_connection.c --- a/gmyth/tests/gmyth_test_connection.c Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/gmyth_test_connection.c Wed Apr 25 15:50:41 2007 +0100 @@ -17,7 +17,8 @@ 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"); + g_object_unref( socket ); + g_debug ("Socket connection success"); return TRUE; } else { g_debug ("Connection failed"); @@ -32,7 +33,9 @@ if (gmyth_socket_connect_to_backend (socket, gmyth_backend_info_get_hostname (backend_info), gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) { - + + + g_object_unref( socket ); g_debug ("Backend socket connection success"); return TRUE; @@ -48,6 +51,7 @@ GMythQuery *query = gmyth_query_new (); if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) { + g_object_unref( query ); g_debug ("Mysql connection success"); return TRUE; } else { @@ -61,8 +65,6 @@ int main (int args, const char **argv) { - const char* uri = argv[1]; - GMythBackendInfo *backend_info; g_type_init (); g_thread_init (NULL); @@ -76,6 +78,9 @@ fprintf(stdout, SYNC_STRING); fflush(NULL); getchar(); + + if ( backend_info != NULL ) + g_object_unref( backend_info ); return (0); diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/gmyth_test_epg.c --- a/gmyth/tests/gmyth_test_epg.c Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/gmyth_test_epg.c Wed Apr 25 15:50:41 2007 +0100 @@ -13,7 +13,8 @@ res = gmyth_epg_connect (epg, backend_info); gmyth_epg_disconnect (epg); - g_object_unref (epg); + if ( epg != NULL ) + g_object_unref (epg); return res; } @@ -31,7 +32,7 @@ } length = gmyth_epg_get_channel_list (epg, &clist); - g_print ("==== %d channels found in the EPG ====\n", length); + g_debug ("==== %d channels found in the EPG ====\n", length); for (i=0; ichannel_name->str, channel_info->channel_icon->str); + g_debug ("Channel %s has icon %s\n", channel_info->channel_name->str, channel_info->channel_icon->str); if (gmyth_epg_channel_get_icon (epg, channel_info, &icon_data, &icon_length)) { FILE *outfile = fopen (icon_name, "w+"); if (fwrite (icon_data, icon_length, 1, outfile) == icon_length) - g_print ("\tIcon saved as %s", icon_name); + g_debug ("\tIcon saved as %s", icon_name); else - g_print ("\tError while downloading the file or writing it"); + g_debug ("\tError while downloading the file or writing it"); g_free (icon_data); } g_free (icon_name); } else { - g_print ("Channel %s does not have icon\n", channel_info->channel_name->str); + g_debug ("Channel %s does not have icon\n", channel_info->channel_name->str); } gmyth_channel_info_print(channel_info); } @@ -93,14 +95,13 @@ int main (int args, const char **argv) { - const char* uri = argv[1]; GMythBackendInfo *backend_info; g_type_init (); g_thread_init (NULL); if (args < 2) { - g_printf ("Type %s myth://hostname:port/?mythconverg\n", argv[0]); + g_debug ("Type %s myth://hostname:port/?mythconverg\n", argv[0]); return -1; } @@ -114,6 +115,9 @@ test_epg_get_channels (backend_info); test_epg_get_channel_icon (backend_info); + if ( backend_info != NULL ) + g_object_unref( backend_info ); + return(0); } diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/gmyth_test_http.c --- a/gmyth/tests/gmyth_test_http.c Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/gmyth_test_http.c Wed Apr 25 15:50:41 2007 +0100 @@ -19,44 +19,51 @@ GTimeVal* start = gmyth_util_string_to_time_val("2007-03-19T17:00:00"); //GTimeVal* end = gmyth_util_string_to_time_val("2007-03-10T00:00:00"); + fprintf(stdout, SYNC_STRING); + fflush(NULL); + getchar(); //GMythEpg epg; - //epg = gmyth_http_retrieve_epg(backend_info, start, end, 1000, 10000, "1"); + /* + epg = gmyth_http_retrieve_epg(backend_info, start, end, 1000, 10000, "1"); - //if ( NULL == epg.channelList || g_slist_length( epg.channelList ) <= 0 ) - // printf( "Channel list is empty!!!" ); + if ( NULL == epg.channelList || g_slist_length( epg.channelList ) <= 0 ) + printf( "Channel list is empty!!!" ); - //GMythRecorded recorded; - //recorded = gmyth_http_retrieve_recorded(backend_info); + GMythRecorded recorded; + recorded = gmyth_http_retrieve_recorded(backend_info); - //GMythRecorded_Program* program = recorded.programList->data; + GMythRecorded_Program* program = recorded.programList->data; + */ + GMythRecProfile* profile; - //GSList* profiles = gmyth_http_retrieve_rec_profiles(backend_info, "Transcoders"); + GSList* profiles = gmyth_http_retrieve_rec_profiles(backend_info, "Transcoders"); - //GMythRecProfile* prof = profiles->data; + profile = profiles->data; - //gchar* sett = gmyth_http_retrieve_setting(backend_info, "JobQueueTranscodeCommand", "wakko"); + gchar* sett = gmyth_http_retrieve_setting(backend_info, "JobQueueTranscodeCommand", "wakko"); - //GMythRecProfile* profile = gmyth_recprofile_new(); + profile = gmyth_recprofile_new(); - //gmyth_recprofile_set_name(profile, "Teste"); - //gmyth_recprofile_set_group(profile, "Transcoders"); - //gmyth_recprofile_set_vcodec(profile, "MPEG-4"); - //gmyth_recprofile_set_acodec(profile, "MP3"); - + gmyth_recprofile_set_name(profile, "Teste"); + gmyth_recprofile_set_group(profile, "Transcoders"); + gmyth_recprofile_set_vcodec(profile, "MPEG-4"); + gmyth_recprofile_set_acodec(profile, "MP3"); - //int teste = gmyth_http_create_rec_profile(backend_info, profile); + int teste = gmyth_http_create_rec_profile(backend_info, profile); - //printf("Hello: %d\n", teste); + printf("Hello: %d\n", teste); - //int teste2 = gmyth_http_del_rec_profile(backend_info, 56); + int teste2 = gmyth_http_del_rec_profile(backend_info, 56); gint ret = gmyth_http_retrieve_job_status(backend_info, 1000, start); printf("Status: %d\n\n", ret); - fprintf(stdout, SYNC_STRING); - fflush(NULL); - getchar(); + //if ( profile != NULL ) + // g_object_unref( profile ); + + if ( backend_info != NULL ) + g_object_unref( backend_info ); return(0); } diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/gmyth_test_livetv.c --- a/gmyth/tests/gmyth_test_livetv.c Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/gmyth_test_livetv.c Wed Apr 25 15:50:41 2007 +0100 @@ -10,8 +10,10 @@ #include "gmyth_file_local.h" #include "gmyth_common.h" +#define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9" + static gboolean -test_livetv_setup () +test_livetv_setup ( gchar *uri ) { GMythLiveTV *livetv = NULL; GMythFile *file = NULL; @@ -19,14 +21,15 @@ gboolean ret = TRUE; gboolean live_tv = FALSE; - gchar *uri = "myth://192.168.3.165:6543/livetv?channel=9"; - + if ( NULL == uri ) + uri = g_strdup( URI_DEFAULT ); + GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri ); GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri); live_tv = gmyth_uri_is_livetv( gmyth_uri ); if ( live_tv ) { - livetv = gmyth_livetv_new (backend_info); + livetv = gmyth_livetv_new (backend_info); gchar* ch = gmyth_uri_get_channel_name( gmyth_uri ); if ( ch != NULL ) @@ -123,21 +126,26 @@ gint main (gint args, const gchar **argv) { + gboolean ret; + g_type_init (); g_thread_init (NULL); - gboolean ret = test_livetv_setup (); + fprintf(stdout, SYNC_STRING); + fflush(NULL); + getchar(); + + if ( args > 1 ) + ret = test_livetv_setup ( argv[1] ); + else + ret = test_livetv_setup ( NULL ); if ( !ret ) g_debug ("Error when running LiveTV setup test script!"); else g_debug ("LiveTV setup test script finished with success."); - fprintf(stdout, SYNC_STRING); - fflush(NULL); - getchar(); - return(0); } diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/gmyth_test_recorder.c --- a/gmyth/tests/gmyth_test_recorder.c Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/gmyth_test_recorder.c Wed Apr 25 15:50:41 2007 +0100 @@ -23,13 +23,20 @@ recorder = remote_request_next_free_recorder (socket, -1); gmyth_socket_close_connection (socket); + + if ( socket != NULL ) + g_object_unref( socket ); + if (recorder == NULL) { g_debug ("Recorder not available\n"); return FALSE; } g_debug ("Recorder found (num): %d", recorder->recorder_num); - + + if ( recorder != NULL ) + g_object_unref( recorder ); + return TRUE; } @@ -45,7 +52,10 @@ g_debug ("Mysql connection failed"); return FALSE; } - + + if ( query != NULL ) + g_object_unref( query ); + } static gboolean @@ -67,6 +77,8 @@ recorder = remote_request_next_free_recorder (socket, -1); gmyth_socket_close_connection (socket); + g_object_unref( socket ); + if (recorder == NULL) { g_debug ("[%s] Recorder not available", __FUNCTION__); return FALSE; @@ -97,9 +109,11 @@ g_list_free (clist); + if ( recorder != NULL ) + g_object_unref( recorder ); + } - int main (int args, const char **argv) { @@ -119,6 +133,9 @@ fprintf(stdout, SYNC_STRING); fflush(NULL); getchar(); + + if ( backend_info != NULL ) + g_object_unref( backend_info ); return(0); diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/gmyth_test_recordings.c --- a/gmyth/tests/gmyth_test_recordings.c Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/gmyth_test_recordings.c Wed Apr 25 15:50:41 2007 +0100 @@ -40,6 +40,12 @@ } gmyth_scheduler_disconnect (scheduler); + + if ( scheduler != NULL ) + g_object_unref( scheduler ); + + if ( list != NULL ) + g_list_free( list ); } @@ -57,6 +63,9 @@ fflush(NULL); getchar(); + if ( backend_info != NULL ) + g_object_unref( backend_info ); + return(0); } diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/test_connection.py --- a/gmyth/tests/test_connection.py Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/test_connection.py Wed Apr 25 15:50:41 2007 +0100 @@ -6,6 +6,5 @@ import sys p = start('gmyth_test_connection', ['myth://192.168.3.165:6543/livetv?channel=1']) -#p = start('gmyth_test_connection', ['livetv']) sys.exit(finish(p)) diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/test_livetv.py --- a/gmyth/tests/test_livetv.py Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/test_livetv.py Wed Apr 25 15:50:41 2007 +0100 @@ -5,6 +5,6 @@ from testing_tools import start, finish import sys -p = start('gmyth_test_livetv') +p = start('gmyth_test_livetv', ['myth://192.168.3.165:6543/livetv?channel=1']) sys.exit(finish(p)) diff -r 95263ab433f1 -r f36075170a4e gmyth/tests/testing_tools.py --- a/gmyth/tests/testing_tools.py Wed Apr 25 01:07:56 2007 +0100 +++ b/gmyth/tests/testing_tools.py Wed Apr 25 15:50:41 2007 +0100 @@ -23,6 +23,7 @@ def __init__(self, cmd, ignore): #assert isinstance(cmd, list) self.p = popen2.Popen3(cmd, capturestderr = True) + #self.p = popen2.Popen3(cmd) print "Executing command... [ %s ]\n" % cmd self.stdin = self.p.tochild self.stdout = self.p.fromchild