Commit e85a5a61 authored by Clément Stenac's avatar Clément Stenac

A bit of cleanup and test

parent 74543709
......@@ -59,9 +59,12 @@ struct libvlc_input_t
struct libvlc_instance_t *p_instance; ///< Parent instance
};
#define RAISENULL( psz ) { libvlc_exception_raise( p_e, psz ); return NULL; }
#define RAISEVOID( psz ) { libvlc_exception_raise( p_e, psz ); return; }
#define RAISEZERO( psz ) { libvlc_exception_raise( p_e, psz ); return 0; }
#define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
return NULL; }
#define RAISEVOID( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
return; }
#define RAISEZERO( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
return 0; }
# ifdef __cplusplus
}
......
......@@ -122,10 +122,10 @@ libvlc_instance_t * libvlc_new( int , char **, libvlc_exception_t *);
int libvlc_get_vlc_id( libvlc_instance_t *p_instance );
/**
* Destroy a libvlc instance
* Destroy a libvlc instance.
* \param p_instance the instance to destroy
*/
void libvlc_destroy( libvlc_instance_t *);
void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
/** @}*/
......
......@@ -101,7 +101,7 @@ libvlc_instance_t * libvlc_new( int argc, char **argv,
return p_new;
}
void libvlc_destroy( libvlc_instance_t *p_instance )
void libvlc_destroy( libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
{
libvlc_InternalCleanup( p_instance->p_libvlc_int );
libvlc_InternalDestroy( p_instance->p_libvlc_int, VLC_FALSE );
......
......@@ -868,14 +868,13 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
*/
int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
{
/* Free allocated memory */
if( p_libvlc->p_memcpy_module )
{
module_Unneed( p_libvlc, p_libvlc->p_memcpy_module );
p_libvlc->p_memcpy_module = NULL;
}
/* Free module bank ! */
/* Free module bank. It is refcounted, so we call this each time */
module_EndBank( p_libvlc );
FREENULL( p_libvlc->psz_homedir );
......
......@@ -3,15 +3,15 @@ import unittest
import native_libvlc_test
class NativeLibvlcTestCase( unittest.TestCase ):
def testException( self ):
def test1Exception( self ):
"""[LibVLC] Checks libvlc_exception"""
# native_libvlc_test.exception_test()
def testStartup( self ):
native_libvlc_test.exception_test()
def test2Startup( self ):
"""[LibVLC] Checks creation/destroy of libvlc"""
# native_libvlc_test.create_destroy()
def testPlaylist( self ):
native_libvlc_test.create_destroy()
def test3Playlist( self ):
"""[LibVLC] Checks basic playlist interaction"""
# native_libvlc_test.playlist_test()
def testVLM( self ):
native_libvlc_test.playlist_test()
def test4VLM( self ):
"""[LibVLC] Checks VLM wrapper"""
# native_libvlc_test.vlm_test()
native_libvlc_test.vlm_test()
#include "../pyunit.h"
#include <vlc/libvlc.h>
PyObject *exception_test( PyObject *self, PyObject *args )
PyObject *exception_test( PyObject *self, PyObject *args )
{
libvlc_exception_t exception;
libvlc_exception_t exception;
libvlc_exception_init( &exception );
ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" );
ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" );
libvlc_exception_init( &exception );
ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" );
ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" );
libvlc_exception_raise( &exception, NULL );
ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" );
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
libvlc_exception_raise( &exception, NULL );
ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" );
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
libvlc_exception_raise( &exception, "test" );
ASSERT( libvlc_exception_get_message( &exception), "No Message" );
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
libvlc_exception_raise( &exception, "test" );
ASSERT( libvlc_exception_get_message( &exception), "No Message" );
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
libvlc_exception_clear( &exception );
ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" );
libvlc_exception_clear( &exception );
ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" );
Py_INCREF( Py_None );
return Py_None;
Py_INCREF( Py_None );
return Py_None;
}
PyObject *create_destroy( PyObject *self, PyObject *args )
PyObject *create_destroy( PyObject *self, PyObject *args )
{
libvlc_instance_t *p_instance;
char *argv[] = { "vlc", "--quiet" };
libvlc_instance_t *p_i1, *p_i2;
char *argv1[] = { "vlc", "--quiet" };
char *argv2[]= { "vlc", "-vvv" };
int id1,id2;
printf( "\n" );
libvlc_exception_t exception;
libvlc_exception_init( &exception );
p_instance = libvlc_new( 2, argv, &exception );
/* Create and destroy a single instance */
fprintf( stderr, "Create 1\n" );
p_i1 = libvlc_new( 2, argv1, &exception );
ASSERT( p_i1 != NULL, "Instance creation failed" );
ASSERT_NOEXCEPTION;
id1 = libvlc_get_vlc_id( p_i1 );
libvlc_destroy( p_i1, &exception );
ASSERT_NOEXCEPTION;
/* Create and destroy two instances */
fprintf( stderr, "Create 2\n" );
p_i1 = libvlc_new( 2, argv1, &exception );
ASSERT( p_i1 != NULL, "Instance creation failed" );
ASSERT_NOEXCEPTION;
fprintf( stderr, "Create 3\n" );
p_i2 = libvlc_new( 2, argv2, &exception );
ASSERT( p_i2 != NULL, "Instance creation failed" );
ASSERT_NOEXCEPTION;
ASSERT( p_instance != NULL, "Instance creation failed" );
fprintf( stderr, "Destroy 1\n" );
libvlc_destroy( p_i1, &exception );
ASSERT_NOEXCEPTION;
fprintf( stderr, "Destroy 2\n" );
libvlc_destroy( p_i2, &exception );
ASSERT_NOEXCEPTION;
/* Deinit */
fprintf( stderr, "Create 4\n" );
p_i1 = libvlc_new( 2, argv1, &exception );
ASSERT_NOEXCEPTION;
id2 = libvlc_get_vlc_id( p_i1 );
ASSERT( !libvlc_exception_raised( &exception ),
"Exception raised while creating instance" );
ASSERT( id1 == id2, "libvlc object ids do not match after deinit" );
libvlc_destroy( p_instance );
Py_INCREF( Py_None );
return Py_None;
}
......
......@@ -9,6 +9,9 @@ export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-
export LD_LIBRARY_PATH=src/.libs/
# Always dump core
ulimit -c unlimited
python test/test.py -v 2>&1|perl -e \
'$bold = "\033[1m";
$grey = "\033[37m";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment