[vlc-devel] [RFC PATCH 2/3] test: refactor test_src_input_stream

Thomas Guillem thomas at gllm.fr
Tue May 24 16:01:35 CEST 2016


---
 test/src/input/stream.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/test/src/input/stream.c b/test/src/input/stream.c
index eb4549c..4f2c407 100644
--- a/test/src/input/stream.c
+++ b/test/src/input/stream.c
@@ -41,6 +41,7 @@
 struct reader
 {
     const char *psz_name;
+    libvlc_instance_t *p_libvlc;
     union {
         FILE *f;
         stream_t *s;
@@ -176,7 +177,7 @@ static void
 stream_close( struct reader *p_reader )
 {
     stream_Delete( p_reader->u.s );
-    libvlc_release( p_reader->p_data );
+    libvlc_release( p_reader->p_libvlc );
     free( p_reader );
 }
 
@@ -214,7 +215,7 @@ stream_open( const char *psz_url )
     p_reader->pf_peek = stream_peek;
     p_reader->pf_tell = stream_tell;
     p_reader->pf_seek = stream_seek;
-    p_reader->p_data = p_vlc;
+    p_reader->p_libvlc = p_vlc;
     p_reader->psz_name = "stream";
     return p_reader;
 }
@@ -345,12 +346,13 @@ int
 main( void )
 {
     struct reader *pp_readers[3];
+    char *psz_url = NULL;
 
     test_init();
 
 #ifndef TEST_NET
+#define NB_READER 2
     char psz_file[PATH_MAX];
-    char *psz_url;
 
     log( "Test local file with libc, and stream\n" );
     assert( realpath( FILE_PATH, psz_file ) == psz_file );
@@ -359,26 +361,21 @@ main( void )
     assert( ( pp_readers[0] = libc_open( psz_file ) ) );
     assert( ( pp_readers[1] = stream_open( psz_url ) ) );
 
-    test( pp_readers, 2, FILE_MD5 );
-    for( unsigned int i = 0; i < 2; ++i )
-        pp_readers[i]->pf_close( pp_readers[i] );
-    free( psz_url );
+    test( pp_readers, NB_READER, FILE_MD5 );
 
 #else
+#define NB_READER 1
 
     log( "Test http url with stream\n" );
     alarm( 0 );
-    if( !( pp_readers[0] = stream_open( HTTP_URL ) ) )
-    {
-        log( "WARNING: can't test http url" );
-        return 0;
-    }
-
-    test( pp_readers, 1, HTTP_MD5 );
-    for( unsigned int i = 0; i < 1; ++i )
-        pp_readers[i]->pf_close( pp_readers[i] );
+    assert( ( pp_readers[0] = stream_open( HTTP_URL ) ) );
 
+    test( pp_readers, NB_READER, HTTP_MD5 );
 #endif
 
+    for( unsigned int i = 0; i < NB_READER; ++i )
+        pp_readers[i]->pf_close( pp_readers[i] );
+    free( psz_url );
+
     return 0;
 }
-- 
2.8.1



More information about the vlc-devel mailing list