# HG changeset patch # User rosfran # Date 1177600047 -3600 # Node ID 945d3f5da6fc12f0196f58e79ff85113eee480db # Parent 2097ef19ce9a7b0f5481376282b53f1976340a1f [svn r603] Uses Valgrind and Mudflap, to create cover tests, and make performance reports. diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/configure.ac --- a/gmyth/configure.ac Wed Apr 25 21:31:00 2007 +0100 +++ b/gmyth/configure.ac Thu Apr 26 16:07:27 2007 +0100 @@ -93,6 +93,25 @@ AM_CONDITIONAL(GMYTH_USE_DEBUG, test "x$enable_debug" = "xyes") +AC_ARG_ENABLE(coverage, + AS_HELP_STRING([--enable-coverage], + [enable coverage (default = no)]), + [ + if test $enableval = no; then + USE_COVERAGE=no; + else + USE_COVERAGE=yes; + fi + ],[ + USE_COVERAGE=no; + ] +) + +if [ test $USE_COVERAGE = yes ]; then + CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage -O0" + LDFLAGS="$LDFLAGS -lgcov" +fi + # Check for pkgconfig AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no) # Give error and exit if we don't have pkgconfig diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/src/gmyth_common.c --- a/gmyth/src/gmyth_common.c Wed Apr 25 21:31:00 2007 +0100 +++ b/gmyth/src/gmyth_common.c Thu Apr 26 16:07:27 2007 +0100 @@ -137,7 +137,7 @@ /* Frees the GMythChannelInfo structure */ GMythChannelInfo *channel = (GMythChannelInfo*) data; - gmyth_channel_info_free (channel); + gmyth_channel_info_free(channel); } static void diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Wed Apr 25 21:31:00 2007 +0100 +++ b/gmyth/src/gmyth_livetv.c Thu Apr 26 16:07:27 2007 +0100 @@ -835,7 +835,7 @@ void gmyth_livetv_stop_playing (GMythLiveTV *livetv) { - gmyth_debug ("Stopping the LiveTV...\n"); + gmyth_debug ("Stopping the LiveTV...\n"); if (livetv->is_livetv) { if ( !gmyth_recorder_stop_livetv (livetv->recorder) ) { diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/tests/Makefile.am --- a/gmyth/tests/Makefile.am Wed Apr 25 21:31:00 2007 +0100 +++ b/gmyth/tests/Makefile.am Thu Apr 26 16:07:27 2007 +0100 @@ -23,10 +23,12 @@ gmyth_test_transcode \ gmyth_test_vlc \ gmyth_test_livetv \ - gmyth_test_http + gmyth_test_http \ + gmyth_test_filetransfer TESTS = \ test \ + relink.py \ test_connection.py \ test_epg.py \ test_recorder.py \ @@ -34,9 +36,10 @@ test_transcode.py \ test_vlc.py \ test_livetv.py \ - test_http.py + test_http.py \ + test_filetransfer.py -#TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) @GLIB_LIBS@ @GOBJECT_LIBS@ @LIBCURL_LIBS@ +TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) test_SOURCES = \ main.c @@ -65,3 +68,6 @@ gmyth_test_livetv_SOURCES = \ gmyth_test_livetv.c +gmyth_test_filetransfer_SOURCES = \ + gmyth_test_filetransfer.c + diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/tests/coverage.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/coverage.py Thu Apr 26 16:07:27 2007 +0100 @@ -0,0 +1,28 @@ +#!/usr/bin/python + +import re +import sys +import os +import shutil +from test import is_coverage, get_gcda + +def build_dir(exe): + t = get_gcda(exe) + a = re.search("(/.*)/tests/regression/.*" ,t) + return a.groups()[0] + +def gen_cov_info(build_dir): + if os.path.exists('coverage'): + shutil.rmtree('coverage') + os.mkdir('coverage') + os.chdir('coverage') + os.system('lcov -d ' + build_dir + ' -b ../ -z') + os.system('lcov -d ' + build_dir + ' -b ../ -c -o clinkc.info') + os.system('genhtml clinkc.info') + +exe = 'mini_cp' +exe = '.libs/' + exe +if is_coverage(exe): + bdir = build_dir(exe) + gen_cov_info(bdir) +sys.exit(0) diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/tests/gmyth_test_filetransfer.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/gmyth_test_filetransfer.c Thu Apr 26 16:07:27 2007 +0100 @@ -0,0 +1,97 @@ +#include + +#include "common.h" + +#include "gmyth_uri.h" +#include "gmyth_backendinfo.h" +#include "gmyth_livetv.h" +#include "gmyth_file.h" +#include "gmyth_file_transfer.h" +#include "gmyth_file_local.h" +#include "gmyth_common.h" + +#define URI_FILE_TRANSFER_DEFAULT "myth://192.168.3.165:6543/" + +static gboolean +test_file_transfer_setup( gchar *uri ) { + GMythLiveTV *livetv = NULL; + GMythFile *file = NULL; + gchar *channel_name = NULL; + gboolean ret = TRUE; + gboolean live_tv = FALSE; + + if ( NULL == uri) + uri = g_strdup( URI_FILE_TRANSFER_DEFAULT ); + + GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri); + + GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri(uri); + + /* Check if the file is local to this specific client renderer, and tries to open + * a local connection + */ + if ( gmyth_uri_is_local_file(gmyth_uri)) { + g_debug( "Opening local file connection to download..."); + file = GMYTH_FILE(gmyth_file_local_new(backend_info)); + ret = gmyth_file_local_open( GMYTH_FILE_LOCAL( file ) ); + } else { + g_debug( "Opening remote file connection to download..."); + file = GMYTH_FILE(gmyth_file_transfer_new(backend_info)); + ret = gmyth_file_transfer_open( GMYTH_FILE_TRANSFER(file), uri); + } + + if (NULL == file) { + g_debug("FileTransfer is NULL"); + ret = FALSE; + goto init_failed; + } + + g_debug( "uri = %s", uri); + + if (ret == FALSE) { + g_debug("MythTV FileTransfer request failed when setting up socket connection!"); + goto init_failed; + } + + g_debug( "MythTV FileTransfer filesize = %lld", + gmyth_file_get_filesize( file)); + + init_failed: if ( livetv != NULL) + g_object_unref(livetv); + + if ( file != NULL) + g_object_unref(file); + + if ( gmyth_uri != NULL) + g_object_unref( gmyth_uri); + + if ( backend_info != NULL) + g_object_unref( backend_info); + + return ret; + +} + +gint +main(gint args, const gchar **argv) { + gboolean ret = FALSE; + + g_type_init(); + + g_thread_init(NULL); + + fprintf(stdout, SYNC_STRING); + fflush(NULL); + getchar(); + + if ( args > 1) + ret = test_file_transfer_setup( argv[1]); + + if ( !ret) + g_debug("Error when running LiveTV setup test script!"); + else + g_debug("LiveTV setup test script finished with success."); + + return (0); +} + diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/tests/relink.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/relink.py Thu Apr 26 16:07:27 2007 +0100 @@ -0,0 +1,30 @@ +#!/usr/bin/python + +#doc: dummy test that relinks all test programs. Should be the first to run + +from testing_tools import relink_name +import sys +import os +import popen2 +import signal +import time + +def relink_all(): + for i in os.listdir('.'): + p = os.popen('file ' + i) + d = p.read() + p.close() + if 'shell script' in d: + relink(i) + +def relink(exe): + rname = relink_name(exe) + if not os.path.exists(rname): + p = popen2.Popen3(['./' + exe], capturestderr = True) + time.sleep(1) + os.kill(p.pid, signal.SIGKILL) + p.wait() + assert os.path.exists(rname) + +relink_all() +sys.exit(0) diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/tests/suppressions --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/suppressions Thu Apr 26 16:07:27 2007 +0100 @@ -0,0 +1,8 @@ +{ + getifaddrs1 + Memcheck:Param + socketcall.sendto(msg) + obj:/usr/lib/debug/libc-2.4.so + fun:__netlink_request + fun:getifaddrs +} diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/tests/test_filetransfer.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/test_filetransfer.py Thu Apr 26 16:07:27 2007 +0100 @@ -0,0 +1,10 @@ +#!/usr/bin/python + +#doc: test gmyth_file_transfer_* methods + +from testing_tools import start, finish +import sys + +p = start('gmyth_test_filetransfer', ['myth://192.168.3.165:6543/1000_20070330144500.nuv']) + +sys.exit(finish(p)) diff -r 2097ef19ce9a -r 945d3f5da6fc gmyth/tests/testing_tools.py --- a/gmyth/tests/testing_tools.py Wed Apr 25 21:31:00 2007 +0100 +++ b/gmyth/tests/testing_tools.py Thu Apr 26 16:07:27 2007 +0100 @@ -21,7 +21,7 @@ class executable: def __init__(self, cmd, ignore): - #assert isinstance(cmd, list) + assert isinstance(cmd, list) self.p = popen2.Popen3(cmd, capturestderr = True) #self.p = popen2.Popen3(cmd) print "Executing command... [ %s ]\n" % cmd @@ -37,12 +37,12 @@ class simple_exe (executable): def __init__(self, exe, ignore): - cmd = './' + exe + cmd = ['./' + exe[0]] + exe[1:] executable.__init__(self, cmd, ignore) class mudflap_exe (executable): def __init__(self, exe, ignore): - cmd = ['./' + exe] + cmd = ['./' + exe[0]] + exe[1:] executable.__init__(self, cmd, ignore) #returns True if completed successfully @@ -57,9 +57,9 @@ class valgrind_exe (executable): def __init__(self, exe, ignore): - suppressions = os.environ['top_srcdir'] + '/tests/regression/suppressions' + suppressions = os.environ['top_srcdir'] + '/tests/suppressions' cmd = ['/usr/bin/valgrind', '--suppressions=' + suppressions, - '--leak-check=full', exe] + '--leak-check=full'] + exe executable.__init__(self, cmd, ignore) #returns True if completed successfully @@ -81,7 +81,8 @@ return errors == 0 def get_gcda(exe): - f = open(exe) + #exe_args = exe.split(' ') + f = open(exe[0]) data = f.read() f.close() a = re.search('/.*\.gcda', data) @@ -103,9 +104,20 @@ return '.libs/lt-' + exe def start(exe, params = [], ignore = 0): - exe = exe + ' ' + ' '.join(params) + #exe = exe + ' ' + ' '.join(params) + exe = [ relink_name(exe) ] + params print 'Executing the command line: ', exe - p = simple_exe(exe, ignore) + #p = simple_exe(exe, ignore) + p = None + if is_coverage(exe): + p = simple_exe(exe, ignore) + elif is_mudflap(exe): + p = mudflap_exe(exe, ignore) + else: + if os.path.exists('/usr/bin/valgrind'): + p = valgrind_exe(exe, ignore) + else: + p = simple_exe(exe, ignore) wait_string(p.stdout, sync_string) return p