]> git.sesse.net Git - vlc/commitdiff
A bit of cleanup and test
authorClément Stenac <zorglub@videolan.org>
Mon, 18 Sep 2006 14:16:14 +0000 (14:16 +0000)
committerClément Stenac <zorglub@videolan.org>
Mon, 18 Sep 2006 14:16:14 +0000 (14:16 +0000)
include/libvlc_internal.h
include/vlc/libvlc.h
src/control/core.c
src/libvlc-common.c
test/NativeLibvlcTest.py
test/native/libvlc.c
test/test.sh

index c0d63f3c6d36578f16148eb20daed483012c721a..da05bfa2e648119bc11d454e439f326dd40ec4ab 100644 (file)
@@ -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
 }
index a8173bb07e4631c8a3af2ef02b7179e17892cffe..01b0bfa22e3585b79de2ce9cb1e503a32a74235c 100644 (file)
@@ -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 * );
 
 /** @}*/
 
index 0b869dbcd966528eefef4999df8e76e97c4ede8b..8d4426e8f553f77080076700e31a71b6b6689267 100644 (file)
@@ -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 );
index 01c235b44dca83fb4847df25b1a8a8ffed874400..05d967ad30b88ad1c754e1f727e2f623a276d93f 100644 (file)
@@ -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 );
index dbcd9ee375ff6939eebf7ba9ea1a3add17eebb56..acb74c6510d247304f5ff51d7e661885adb9b440 100644 (file)
@@ -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()
index 5611ae5c779b1065404d551473907edbad0b1a5e..2ff69fa335bfc6b4f078c633a014c7f0303ee0ab 100644 (file)
@@ -1,46 +1,76 @@
 #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;
 }
index 825f118915c090acfc8bb53988e434ace50480bf..88c849924001f8b96ed802189351c3a05ed64148 100755 (executable)
@@ -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";