Changeset 0fbf13c30976400ed00ccf72ce8d7c84c981d628
- 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
| rd42739f |
r0fbf13c |
|
| 40 | 40 | }; |
|---|
| 41 | 41 | |
|---|
| | 42 | asserts = 0; |
|---|
| | 43 | |
|---|
| 42 | 44 | DECLARE_MODULE( native_gc_test ) |
|---|
| r89471fa |
r0fbf13c |
|
| | 1 | #include "../pyunit.h" |
|---|
| 1 | 2 | #include "tests.h" |
|---|
| 2 | 3 | |
|---|
| | 4 | PyObject *init( PyObject *self, PyObject *args ) |
|---|
| | 5 | { |
|---|
| | 6 | (void)setvbuf (stdout, NULL, _IONBF, 0); |
|---|
| | 7 | Py_INCREF( Py_None ); |
|---|
| | 8 | return Py_None; |
|---|
| | 9 | } |
|---|
| | 10 | |
|---|
| 3 | 11 | static PyMethodDef native_libvlc_test_methods[] = { |
|---|
| | 12 | DEF_METHOD( init, "Init some stuff" ) |
|---|
| 4 | 13 | DEF_METHOD( create_destroy, "Create and destroy" ) |
|---|
| 5 | 14 | DEF_METHOD( exception_test, "Test Exception handling" ) |
|---|
| … | … | |
| 12 | 21 | DEF_METHOD( gui_chains_test, "Test interactions between chains and GUI" ) |
|---|
| 13 | 22 | 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" ) |
|---|
| 14 | 26 | { NULL, NULL, 0, NULL } |
|---|
| 15 | 27 | }; |
|---|
| 16 | 28 | |
|---|
| | 29 | asserts =0; |
|---|
| | 30 | |
|---|
| 17 | 31 | DECLARE_MODULE( native_libvlc_test ) |
|---|
| r89471fa |
r0fbf13c |
|
| 1 | 1 | #include "../pyunit.h" |
|---|
| 2 | 2 | |
|---|
| | 3 | /* Libvlc */ |
|---|
| 3 | 4 | PyObject *exception_test( PyObject *self, PyObject *args ); |
|---|
| 4 | 5 | PyObject *create_destroy( PyObject *self, PyObject *args ); |
|---|
| … | … | |
| 6 | 7 | PyObject *vlm_test( PyObject *self, PyObject *args ); |
|---|
| 7 | 8 | |
|---|
| | 9 | /* Stats */ |
|---|
| 8 | 10 | PyObject *timers_test( PyObject *self, PyObject *args ); |
|---|
| 9 | 11 | |
|---|
| … | … | |
| 12 | 14 | PyObject *i18n_atof_test( PyObject *self, PyObject *args ); |
|---|
| 13 | 15 | |
|---|
| | 16 | /* Profiles */ |
|---|
| 14 | 17 | PyObject *chains_test( PyObject *self, PyObject *args ); |
|---|
| 15 | 18 | PyObject *gui_chains_test( PyObject *self, PyObject *args ); |
|---|
| 16 | 19 | PyObject *psz_chains_test( PyObject *self, PyObject *args ); |
|---|
| | 20 | |
|---|
| | 21 | /* Algo */ |
|---|
| | 22 | PyObject *bsearch_direct_test( PyObject *self, PyObject *args ); |
|---|
| | 23 | PyObject *bsearch_member_test( PyObject *self, PyObject *args ); |
|---|
| | 24 | PyObject *dict_test( PyObject *self, PyObject *args ); |
|---|
| | 25 | |
|---|
| r525b810 |
r0fbf13c |
|
| 43 | 43 | { |
|---|
| 44 | 44 | printf( "\n" ); |
|---|
| 45 | | (void)setvbuf (stdout, NULL, _IONBF, 0); |
|---|
| 46 | 45 | if( !test_decode ("this_should_not_be_modified_1234", |
|---|
| 47 | 46 | "this_should_not_be_modified_1234") ) return NULL; |
|---|
| r89471fa |
r0fbf13c |
|
| 1 | 1 | #include <Python.h> |
|---|
| 2 | 2 | |
|---|
| 3 | | #define ASSERT( a, message ) if( !(a) ) { PyErr_SetString( PyExc_AssertionError, message " - " #a ); return NULL; } |
|---|
| | 3 | extern int asserts; |
|---|
| | 4 | |
|---|
| | 5 | #define ASSERT( a, message ) asserts++;if( !(a) ) { PyErr_SetString( PyExc_AssertionError, message " - " #a ); return NULL; } |
|---|
| 4 | 6 | |
|---|
| 5 | 7 | #define DECLARE_MODULE( module ) PyMODINIT_FUNC init##module( void ) { \ |
|---|
| … | … | |
| 7 | 9 | } |
|---|
| 8 | 10 | |
|---|
| 9 | | #define ASSERT_NOEXCEPTION if( libvlc_exception_raised( &exception ) ) { \ |
|---|
| | 11 | #define ASSERT_NOEXCEPTION asserts++; if( libvlc_exception_raised( &exception ) ) { \ |
|---|
| 10 | 12 | if( libvlc_exception_get_message( &exception ) ) PyErr_SetString( PyExc_AssertionError, libvlc_exception_get_message( &exception ) ); \ |
|---|
| 11 | 13 | else PyErr_SetString( PyExc_AssertionError, "Exception raised" ); return NULL; } |
|---|
| 12 | 14 | |
|---|
| 13 | | #define ASSERT_EXCEPTION if( !libvlc_exception_raised( &exception ) ) { \ |
|---|
| | 15 | #define ASSERT_EXCEPTION asserts ++; if( !libvlc_exception_raised( &exception ) ) { \ |
|---|
| 14 | 16 | if( libvlc_exception_get_message( &exception ) ) PyErr_SetString( PyExc_AssertionError, libvlc_exception_get_message( &exception ) ); \ |
|---|
| 15 | 17 | else PyErr_SetString( PyExc_AssertionError, "Exception not raised" ); return NULL; } |
|---|
| r89471fa |
r0fbf13c |
|
| 42 | 42 | native_libvlc_test = Extension( 'native_libvlc_test', |
|---|
| 43 | 43 | 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'], |
|---|
| 45 | 46 | include_dirs = ['../include', '../', '/usr/win32/include' ], |
|---|
| 46 | 47 | extra_objects = [ '../src/.libs/libvlc.so' ], |
|---|
| r96fe8ff |
r0fbf13c |
|
| 9 | 9 | |
|---|
| 10 | 10 | import sys, os, re, unittest |
|---|
| | 11 | import native_libvlc_test |
|---|
| | 12 | |
|---|
| 11 | 13 | |
|---|
| 12 | 14 | def printAndRun( module ): |
|---|
| 13 | | print "Running tests from module " + module.__name__; |
|---|
| | 15 | # print "Running tests from module " + module.__name__; |
|---|
| 14 | 16 | return unittest.defaultTestLoader.loadTestsFromModule( module ) |
|---|
| 15 | 17 | |
|---|
| … | … | |
| 22 | 24 | moduleNames = map(filenameToModuleName, files) |
|---|
| 23 | 25 | modules = map(__import__, moduleNames) |
|---|
| | 26 | |
|---|
| | 27 | native_libvlc_test.init() |
|---|
| | 28 | |
|---|
| 24 | 29 | # load = unittest.defaultTestLoader.loadTestsFromModule |
|---|
| 25 | 30 | load = printAndRun |
|---|
| r4db506d |
r0fbf13c |
|
| 1 | 1 | #! /bin/sh |
|---|
| 2 | 2 | |
|---|
| | 3 | set -e |
|---|
| | 4 | python setup.py build |
|---|
| 3 | 5 | |
|---|
| 4 | 6 | cd .. |
|---|
| | 7 | # TODO: FIXME !! |
|---|
| 5 | 8 | export 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 |
|---|
| 6 | 9 | |
|---|
| 7 | | LD_LIBRARY_PATH=src/.libs/ python test/test.py -v |
|---|
| | 10 | export LD_LIBRARY_PATH=src/.libs/ |
|---|
| | 11 | |
|---|
| | 12 | python 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 | |
|---|
| | 25 | while(<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 | |
|---|