]> git.sesse.net Git - vlc/commitdiff
Skeleton for testing libvlc
authorClément Stenac <zorglub@videolan.org>
Sun, 29 Jan 2006 17:00:31 +0000 (17:00 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 29 Jan 2006 17:00:31 +0000 (17:00 +0000)
test/NativeLibvlcTest.py [new file with mode: 0644]
test/PyMediaControlBaseTest.py [moved from test/BaseTest.py with 100% similarity]
test/PyMediaControlPlaylistTest.py [moved from test/PlaylistTest.py with 100% similarity]
test/PyMediaControlVariablesTest.py [moved from test/VariablesTest.py with 100% similarity]
test/native_libvlc/native_libvlc_test.c [new file with mode: 0644]
test/pyunit.h [new file with mode: 0644]
test/setup.py [new file with mode: 0644]
test/test.sh

diff --git a/test/NativeLibvlcTest.py b/test/NativeLibvlcTest.py
new file mode 100644 (file)
index 0000000..fcef0a1
--- /dev/null
@@ -0,0 +1,8 @@
+import vlc
+import unittest
+
+import native_libvlc_test
+
+class NativeLibvlcTestCase( unittest.TestCase ):
+    def testMe( self ):
+       native_libvlc_test.create_destroy()
diff --git a/test/native_libvlc/native_libvlc_test.c b/test/native_libvlc/native_libvlc_test.c
new file mode 100644 (file)
index 0000000..36df199
--- /dev/null
@@ -0,0 +1,16 @@
+#include "../pyunit.h"
+
+static PyObject *create_destroy( PyObject *self, PyObject *args )
+{
+     /* Test stuff here */
+     
+     Py_INCREF( Py_None );
+     return Py_None;
+}
+
+static PyMethodDef native_libvlc_test_methods[] = {
+   DEF_METHOD( create_destroy, "Create and destroy" )
+   { NULL, NULL, 0, NULL }
+};
+
+DECLARE_MODULE( native_libvlc_test )
diff --git a/test/pyunit.h b/test/pyunit.h
new file mode 100644 (file)
index 0000000..3fc5978
--- /dev/null
@@ -0,0 +1,9 @@
+#include <Python.h>
+
+#define ASSERT( a, message ) if( !(a) ) { fprintf( stderr, "ASSERTION FAILED\n" ); PyErr_SetString( PyExc_AssertionError, message ); return NULL; }
+
+#define DECLARE_MODULE( module ) PyMODINIT_FUNC init##module( void ) {  \
+        Py_InitModule( #module, module##_methods );                     \
+}
+
+#define DEF_METHOD( method, desc ) { #method, method, METH_VARARGS, desc},
diff --git a/test/setup.py b/test/setup.py
new file mode 100644 (file)
index 0000000..a43ac97
--- /dev/null
@@ -0,0 +1,49 @@
+from distutils.core import setup,Extension
+import os
+
+def get_vlcconfig():
+    vlcconfig=None
+    for n in ( 'vlc-config',
+               os.path.sep.join( ( '..', 'vlc-config' ))):
+        if os.path.exists(n):
+            vlcconfig=n
+            break
+    if vlcconfig is None:
+        print "*** Warning *** Cannot find vlc-config"
+    elif os.sys.platform == 'win32':
+        # Win32 does not know how to invoke the shell itself.
+        vlcconfig="sh %s" % vlcconfig
+    return vlcconfig
+
+def get_cflags():
+    vlcconfig=get_vlcconfig()
+    if vlcconfig is None:
+        return []
+    else:
+        cflags=os.popen('%s --cflags' % vlcconfig, 'r').readline().rstrip().split()
+        return cflags
+
+def get_ldflags():
+    vlcconfig=get_vlcconfig()
+    if vlcconfig is None:
+        return []
+    else:
+       os.environ['top_builddir'] = '..'
+       ldflags = []
+       if os.sys.platform == 'darwin':
+           ldflags = "-read_only_relocs warning".split()
+        ldflags.extend(os.popen('%s --libs vlc pic builtin' % vlcconfig, 'r').readline().rstrip().split())
+       if os.sys.platform == 'darwin':
+           ldflags.append('-lstdc++')
+        return ldflags
+
+# To compile in a local vlc tree
+native_libvlc_test = Extension( 'native_libvlc_test',
+                sources = ['native_libvlc/native_libvlc_test.c'],
+                include_dirs = ['../include', '../', '/usr/win32/include' ],
+                extra_objects = [ '../lib/libvlc_pic.a' ],
+                extra_compile_args = get_cflags(),
+                           extra_link_args = [ '-L../..' ]  + get_ldflags(),
+                )
+
+setup( name = 'native_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] )
index 2d41795d797fb7f95abde4aa32802c9a1d4e21b1..9981fa7423561d95c3fed3e1e64b1bbbbb3382cd 100755 (executable)
@@ -2,6 +2,6 @@
 
 # FIXME - Get real .so
 cd ..
-export PYTHONPATH=$PYTHONPATH:bindings/python/build/lib.linux-i686-2.3
+export PYTHONPATH=$PYTHONPATH:bindings/python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3
 
 python test/test.py -v