Changeset 0fbf13c30976400ed00ccf72ce8d7c84c981d628

Show
Ignore:
Timestamp:
08/19/06 18:19:56 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1156004396 +0000
git-parent:

[23d27c9c9cec127459721c3b9420eb349109b477]

git-author:
Clément Stenac <zorglub@videolan.org> 1156004396 +0000
Message:

* Tests for previous commit
* Improve test output

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • test/native/gc.c

    rd42739f r0fbf13c  
    4040}; 
    4141 
     42asserts = 0; 
     43 
    4244DECLARE_MODULE( native_gc_test ) 
  • test/native/init.c

    r89471fa r0fbf13c  
     1#include "../pyunit.h" 
    12#include "tests.h" 
    23 
     4PyObject *init( PyObject *self, PyObject *args ) 
     5{ 
     6    (void)setvbuf (stdout, NULL, _IONBF, 0); 
     7    Py_INCREF( Py_None ); 
     8    return Py_None; 
     9} 
     10 
    311static PyMethodDef native_libvlc_test_methods[] = { 
     12   DEF_METHOD( init, "Init some stuff" ) 
    413   DEF_METHOD( create_destroy, "Create and destroy" ) 
    514   DEF_METHOD( exception_test, "Test Exception handling" ) 
     
    1221   DEF_METHOD( gui_chains_test, "Test interactions between chains and GUI" ) 
    1322   DEF_METHOD( psz_chains_test, "Test building of chain strings" ) 
     23   DEF_METHOD( bsearch_direct_test, "Test Bsearch without structure" ) 
     24   DEF_METHOD( bsearch_member_test, "Test Bsearch with structure" ) 
     25   DEF_METHOD( dict_test, "Test dictionnaries" ) 
    1426   { NULL, NULL, 0, NULL } 
    1527}; 
    1628 
     29asserts =0; 
     30 
    1731DECLARE_MODULE( native_libvlc_test ) 
  • test/native/tests.h

    r89471fa r0fbf13c  
    11#include "../pyunit.h" 
    22 
     3/* Libvlc */ 
    34PyObject *exception_test( PyObject *self, PyObject *args ); 
    45PyObject *create_destroy( PyObject *self, PyObject *args ); 
     
    67PyObject *vlm_test( PyObject *self, PyObject *args ); 
    78 
     9/* Stats */ 
    810PyObject *timers_test( PyObject *self, PyObject *args ); 
    911 
     
    1214PyObject *i18n_atof_test( PyObject *self, PyObject *args ); 
    1315 
     16/* Profiles */ 
    1417PyObject *chains_test( PyObject *self, PyObject *args ); 
    1518PyObject *gui_chains_test( PyObject *self, PyObject *args ); 
    1619PyObject *psz_chains_test( PyObject *self, PyObject *args ); 
     20 
     21/* Algo */ 
     22PyObject *bsearch_direct_test( PyObject *self, PyObject *args ); 
     23PyObject *bsearch_member_test( PyObject *self, PyObject *args ); 
     24PyObject *dict_test( PyObject *self, PyObject *args ); 
     25 
  • test/native/url.c

    r525b810 r0fbf13c  
    4343{ 
    4444    printf( "\n" ); 
    45     (void)setvbuf (stdout, NULL, _IONBF, 0); 
    4645    if( !test_decode ("this_should_not_be_modified_1234", 
    4746                     "this_should_not_be_modified_1234") ) return NULL; 
  • test/pyunit.h

    r89471fa r0fbf13c  
    11#include <Python.h> 
    22 
    3 #define ASSERT( a, message ) if( !(a) ) { PyErr_SetString( PyExc_AssertionError, message " - " #a ); return NULL; } 
     3extern int asserts; 
     4 
     5#define ASSERT( a, message ) asserts++;if( !(a) ) { PyErr_SetString( PyExc_AssertionError, message " - " #a ); return NULL; } 
    46 
    57#define DECLARE_MODULE( module ) PyMODINIT_FUNC init##module( void ) {  \ 
     
    79} 
    810 
    9 #define ASSERT_NOEXCEPTION if( libvlc_exception_raised( &exception ) ) { \ 
     11#define ASSERT_NOEXCEPTION asserts++; if( libvlc_exception_raised( &exception ) ) { \ 
    1012         if( libvlc_exception_get_message( &exception ) )  PyErr_SetString( PyExc_AssertionError, libvlc_exception_get_message( &exception ) ); \ 
    1113         else PyErr_SetString( PyExc_AssertionError, "Exception raised" ); return NULL; } 
    1214 
    13 #define ASSERT_EXCEPTION if( !libvlc_exception_raised( &exception ) ) { \ 
     15#define ASSERT_EXCEPTION asserts ++; if( !libvlc_exception_raised( &exception ) ) { \ 
    1416         if( libvlc_exception_get_message( &exception ) )  PyErr_SetString( PyExc_AssertionError, libvlc_exception_get_message( &exception ) ); \ 
    1517         else PyErr_SetString( PyExc_AssertionError, "Exception not raised" ); return NULL; } 
  • test/setup.py

    r89471fa r0fbf13c  
    4242native_libvlc_test = Extension( 'native_libvlc_test', 
    4343                sources = ['native/init.c', 'native/url.c', 'native/i18n.c', 
    44                 'native/stats.c', 'native/libvlc.c', 'native/profiles.c'], 
     44                'native/stats.c', 'native/libvlc.c', 'native/profiles.c', 
     45                'native/algo.c'], 
    4546                include_dirs = ['../include', '../', '/usr/win32/include' ], 
    4647                extra_objects = [ '../src/.libs/libvlc.so' ], 
  • test/test.py

    r96fe8ff r0fbf13c  
    99 
    1010import sys, os, re, unittest 
     11import native_libvlc_test 
     12 
    1113 
    1214def printAndRun( module ): 
    13     print "Running tests from module " + module.__name__; 
     15#    print "Running tests from module " + module.__name__; 
    1416    return unittest.defaultTestLoader.loadTestsFromModule( module ) 
    1517 
     
    2224    moduleNames = map(filenameToModuleName, files)          
    2325    modules = map(__import__, moduleNames)                  
     26     
     27    native_libvlc_test.init() 
     28 
    2429#    load = unittest.defaultTestLoader.loadTestsFromModule 
    2530    load = printAndRun 
  • test/test.sh

    r4db506d r0fbf13c  
    11#! /bin/sh 
    22 
     3set -e 
     4python setup.py build  
    35 
    46cd .. 
     7# TODO: FIXME !! 
    58export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3:test/build/lib.linux-x86_64-2.3 
    69 
    7 LD_LIBRARY_PATH=src/.libs/ python test/test.py -v 
     10export LD_LIBRARY_PATH=src/.libs/ 
     11 
     12python test/test.py -v 2>&1|perl  -e \ 
     13'$bold = "\033[1m"; 
     14$grey  = "\033[37m"; 
     15$green  = "\033[32m"; 
     16$blue  = "\033[34m"; 
     17$red  = "\033[31m"; 
     18$reset = "\033[0m"; 
     19 
     20# Combinations 
     21$info   = $reset; 
     22$ok     = $green; 
     23$err    = $red.$bold; 
     24 
     25while(<STDIN>) 
     26
     27     $line = $_; 
     28     chomp $line; 
     29     if( $line =~ s/^(\[[A-z0-9]*\]\s.*)\.\.\.\sok$/$info$1\.\.\.$ok ok/g ||  
     30         $line =~ s/^(\[[A-z0-9]*\]\s.*)\.\.\.\sFAIL$/$info$1\.\.\.$err FAIL/g|| 
     31         $line =~ s/^(\[[A-z0-9]*\]\s.*)\.\.\.(.)*$/$info$1\.\.\.$2/g ||  
     32         $line =~ s/^(ok)$/$ok$1/ig || $line =~ s/^FAIL$/$err FAIL/g ||  
     33         $line =~ s/(Ran\s.*)/$info$1/g ) 
     34     { 
     35        print $line.$reset."\n"; 
     36     } 
     37     else 
     38     { 
     39        print $grey.$line."\n"; 
     40     } 
     41}' 
     42