Changeset e85a5a618dde3b1d131ffca1cd373a9d3f845fc6
- Timestamp:
- 09/18/06 16:16:14
(2 years ago)
- Author:
- Clément Stenac <zorglub@videolan.org>
- git-committer:
- Clément Stenac <zorglub@videolan.org> 1158588974 +0000
- git-parent:
[745437093217075837f234f8bc4144d8bd2b44b4]
- git-author:
- Clément Stenac <zorglub@videolan.org> 1158588974 +0000
- Message:
A bit of cleanup and test
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rf0531d5 |
re85a5a6 |
|
| 60 | 60 | }; |
|---|
| 61 | 61 | |
|---|
| 62 | | #define RAISENULL( psz ) { libvlc_exception_raise( p_e, psz ); return NULL; } |
|---|
| 63 | | #define RAISEVOID( psz ) { libvlc_exception_raise( p_e, psz ); return; } |
|---|
| 64 | | #define RAISEZERO( psz ) { libvlc_exception_raise( p_e, psz ); return 0; } |
|---|
| | 62 | #define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \ |
|---|
| | 63 | return NULL; } |
|---|
| | 64 | #define RAISEVOID( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \ |
|---|
| | 65 | return; } |
|---|
| | 66 | #define RAISEZERO( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \ |
|---|
| | 67 | return 0; } |
|---|
| 65 | 68 | |
|---|
| 66 | 69 | # ifdef __cplusplus |
|---|
| rf8cece2 |
re85a5a6 |
|
| 123 | 123 | |
|---|
| 124 | 124 | /** |
|---|
| 125 | | * Destroy a libvlc instance |
|---|
| | 125 | * Destroy a libvlc instance. |
|---|
| 126 | 126 | * \param p_instance the instance to destroy |
|---|
| 127 | 127 | */ |
|---|
| 128 | | void libvlc_destroy( libvlc_instance_t *); |
|---|
| | 128 | void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * ); |
|---|
| 129 | 129 | |
|---|
| 130 | 130 | /** @}*/ |
|---|
| rf0531d5 |
re85a5a6 |
|
| 102 | 102 | } |
|---|
| 103 | 103 | |
|---|
| 104 | | void libvlc_destroy( libvlc_instance_t *p_instance ) |
|---|
| | 104 | void libvlc_destroy( libvlc_instance_t *p_instance, libvlc_exception_t *p_e ) |
|---|
| 105 | 105 | { |
|---|
| 106 | 106 | libvlc_InternalCleanup( p_instance->p_libvlc_int ); |
|---|
| re9947be |
re85a5a6 |
|
| 869 | 869 | int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release ) |
|---|
| 870 | 870 | { |
|---|
| 871 | | /* Free allocated memory */ |
|---|
| 872 | 871 | if( p_libvlc->p_memcpy_module ) |
|---|
| 873 | 872 | { |
|---|
| … | … | |
| 876 | 875 | } |
|---|
| 877 | 876 | |
|---|
| 878 | | /* Free module bank ! */ |
|---|
| | 877 | /* Free module bank. It is refcounted, so we call this each time */ |
|---|
| 879 | 878 | module_EndBank( p_libvlc ); |
|---|
| 880 | 879 | |
|---|
| r4db506d |
re85a5a6 |
|
| 4 | 4 | |
|---|
| 5 | 5 | class NativeLibvlcTestCase( unittest.TestCase ): |
|---|
| 6 | | def testException( self ): |
|---|
| | 6 | def test1Exception( self ): |
|---|
| 7 | 7 | """[LibVLC] Checks libvlc_exception""" |
|---|
| 8 | | # native_libvlc_test.exception_test() |
|---|
| 9 | | def testStartup( self ): |
|---|
| | 8 | native_libvlc_test.exception_test() |
|---|
| | 9 | def test2Startup( self ): |
|---|
| 10 | 10 | """[LibVLC] Checks creation/destroy of libvlc""" |
|---|
| 11 | | # native_libvlc_test.create_destroy() |
|---|
| 12 | | def testPlaylist( self ): |
|---|
| | 11 | native_libvlc_test.create_destroy() |
|---|
| | 12 | def test3Playlist( self ): |
|---|
| 13 | 13 | """[LibVLC] Checks basic playlist interaction""" |
|---|
| 14 | | # native_libvlc_test.playlist_test() |
|---|
| 15 | | def testVLM( self ): |
|---|
| | 14 | native_libvlc_test.playlist_test() |
|---|
| | 15 | def test4VLM( self ): |
|---|
| 16 | 16 | """[LibVLC] Checks VLM wrapper""" |
|---|
| 17 | | # native_libvlc_test.vlm_test() |
|---|
| | 17 | native_libvlc_test.vlm_test() |
|---|
| r59cd4c2 |
re85a5a6 |
|
| 2 | 2 | #include <vlc/libvlc.h> |
|---|
| 3 | 3 | |
|---|
| 4 | | PyObject *exception_test( PyObject *self, PyObject *args ) |
|---|
| | 4 | PyObject *exception_test( PyObject *self, PyObject *args ) |
|---|
| 5 | 5 | { |
|---|
| 6 | | libvlc_exception_t exception; |
|---|
| | 6 | libvlc_exception_t exception; |
|---|
| 7 | 7 | |
|---|
| 8 | | libvlc_exception_init( &exception ); |
|---|
| 9 | | ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" ); |
|---|
| 10 | | ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" ); |
|---|
| | 8 | libvlc_exception_init( &exception ); |
|---|
| | 9 | ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" ); |
|---|
| | 10 | ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" ); |
|---|
| 11 | 11 | |
|---|
| 12 | | libvlc_exception_raise( &exception, NULL ); |
|---|
| 13 | | ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" ); |
|---|
| 14 | | ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); |
|---|
| | 12 | libvlc_exception_raise( &exception, NULL ); |
|---|
| | 13 | ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" ); |
|---|
| | 14 | ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); |
|---|
| 15 | 15 | |
|---|
| 16 | | libvlc_exception_raise( &exception, "test" ); |
|---|
| 17 | | ASSERT( libvlc_exception_get_message( &exception), "No Message" ); |
|---|
| 18 | | ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); |
|---|
| | 16 | libvlc_exception_raise( &exception, "test" ); |
|---|
| | 17 | ASSERT( libvlc_exception_get_message( &exception), "No Message" ); |
|---|
| | 18 | ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); |
|---|
| 19 | 19 | |
|---|
| 20 | | libvlc_exception_clear( &exception ); |
|---|
| 21 | | ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" ); |
|---|
| | 20 | libvlc_exception_clear( &exception ); |
|---|
| | 21 | ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" ); |
|---|
| 22 | 22 | |
|---|
| 23 | | Py_INCREF( Py_None ); |
|---|
| 24 | | return Py_None; |
|---|
| | 23 | Py_INCREF( Py_None ); |
|---|
| | 24 | return Py_None; |
|---|
| 25 | 25 | } |
|---|
| 26 | 26 | |
|---|
| 27 | | PyObject *create_destroy( PyObject *self, PyObject *args ) |
|---|
| | 27 | PyObject *create_destroy( PyObject *self, PyObject *args ) |
|---|
| 28 | 28 | { |
|---|
| 29 | | libvlc_instance_t *p_instance; |
|---|
| 30 | | char *argv[] = { "vlc", "--quiet" }; |
|---|
| | 29 | libvlc_instance_t *p_i1, *p_i2; |
|---|
| | 30 | char *argv1[] = { "vlc", "--quiet" }; |
|---|
| | 31 | char *argv2[]= { "vlc", "-vvv" }; |
|---|
| | 32 | int id1,id2; |
|---|
| | 33 | |
|---|
| | 34 | printf( "\n" ); |
|---|
| 31 | 35 | |
|---|
| 32 | 36 | libvlc_exception_t exception; |
|---|
| 33 | 37 | libvlc_exception_init( &exception ); |
|---|
| 34 | 38 | |
|---|
| 35 | | p_instance = libvlc_new( 2, argv, &exception ); |
|---|
| | 39 | /* Create and destroy a single instance */ |
|---|
| | 40 | fprintf( stderr, "Create 1\n" ); |
|---|
| | 41 | p_i1 = libvlc_new( 2, argv1, &exception ); |
|---|
| | 42 | ASSERT( p_i1 != NULL, "Instance creation failed" ); |
|---|
| | 43 | ASSERT_NOEXCEPTION; |
|---|
| | 44 | id1 = libvlc_get_vlc_id( p_i1 ); |
|---|
| | 45 | libvlc_destroy( p_i1, &exception ); |
|---|
| | 46 | ASSERT_NOEXCEPTION; |
|---|
| 36 | 47 | |
|---|
| 37 | | ASSERT( p_instance != NULL, "Instance creation failed" ); |
|---|
| | 48 | /* Create and destroy two instances */ |
|---|
| | 49 | fprintf( stderr, "Create 2\n" ); |
|---|
| | 50 | p_i1 = libvlc_new( 2, argv1, &exception ); |
|---|
| | 51 | ASSERT( p_i1 != NULL, "Instance creation failed" ); |
|---|
| | 52 | ASSERT_NOEXCEPTION; |
|---|
| 38 | 53 | |
|---|
| 39 | | ASSERT( !libvlc_exception_raised( &exception ), |
|---|
| 40 | | "Exception raised while creating instance" ); |
|---|
| | 54 | fprintf( stderr, "Create 3\n" ); |
|---|
| | 55 | p_i2 = libvlc_new( 2, argv2, &exception ); |
|---|
| | 56 | ASSERT( p_i2 != NULL, "Instance creation failed" ); |
|---|
| | 57 | ASSERT_NOEXCEPTION; |
|---|
| 41 | 58 | |
|---|
| 42 | | libvlc_destroy( p_instance ); |
|---|
| 43 | | |
|---|
| | 59 | fprintf( stderr, "Destroy 1\n" ); |
|---|
| | 60 | libvlc_destroy( p_i1, &exception ); |
|---|
| | 61 | ASSERT_NOEXCEPTION; |
|---|
| | 62 | fprintf( stderr, "Destroy 2\n" ); |
|---|
| | 63 | libvlc_destroy( p_i2, &exception ); |
|---|
| | 64 | ASSERT_NOEXCEPTION; |
|---|
| | 65 | |
|---|
| | 66 | /* Deinit */ |
|---|
| | 67 | fprintf( stderr, "Create 4\n" ); |
|---|
| | 68 | p_i1 = libvlc_new( 2, argv1, &exception ); |
|---|
| | 69 | ASSERT_NOEXCEPTION; |
|---|
| | 70 | id2 = libvlc_get_vlc_id( p_i1 ); |
|---|
| | 71 | |
|---|
| | 72 | ASSERT( id1 == id2, "libvlc object ids do not match after deinit" ); |
|---|
| | 73 | |
|---|
| 44 | 74 | Py_INCREF( Py_None ); |
|---|
| 45 | 75 | return Py_None; |
|---|
| rf834305 |
re85a5a6 |
|
| 9 | 9 | |
|---|
| 10 | 10 | export LD_LIBRARY_PATH=src/.libs/ |
|---|
| | 11 | |
|---|
| | 12 | # Always dump core |
|---|
| | 13 | ulimit -c unlimited |
|---|
| 11 | 14 | |
|---|
| 12 | 15 | python test/test.py -v 2>&1|perl -e \ |
|---|