~ubuntu-branches/ubuntu/trusty/libavg/trusty-proposed

« back to all changes in this revision

Viewing changes to src/test/Test.py

  • Committer: Package Import Robot
  • Author(s): OXullo Intersecans
  • Date: 2011-12-06 22:44:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20111206224456-qc7250z3ya1vi8s9
Tags: 1.7.0-0ubuntu1
* New upstream release (LP: #899183)
* Remove patches 0002-libav-0.7.patch, 0003-fglrx-segfault-on-startup.patch
  now merged to upstream
* Remove unnecessary .la files
* Update debian/watch file
* Fix debian/copyright dep-5 compliancy
* Update standards to version 3.9.2
* Add man pages for avg_checktouch, avg_checkvsync, avg_showsvg
* Minor debian/rules enhancement
* Add librsvg2-dev, libgdk-pixbuf2.0-dev to Build-Depends
* Proper transition to dh_python2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
3
# libavg - Media Playback Engine.
4
 
# Copyright (C) 2003-2008 Ulrich von Zadow
 
4
# Copyright (C) 2003-2011 Ulrich von Zadow
5
5
#
6
6
# This library is free software; you can redistribute it and/or
7
7
# modify it under the terms of the GNU Lesser General Public
20
20
# Current versions can be found at www.libavg.de
21
21
#
22
22
 
 
23
'''
 
24
Runner for libavg unit tests
 
25
 
 
26
On autotools-based systems, tests are performed on a local libavg package.
 
27
This package is created by symlinking all the relevant files in a local, temporary
 
28
directory, letting python find it as first instance.
 
29
On windows, instead, tests are always carried on after distutils installs the package.
 
30
'''
 
31
 
23
32
import sys
24
33
import os
25
34
import shutil
26
 
 
27
 
 
28
 
g_TempPackageDir = None
29
 
 
 
35
import atexit
 
36
 
 
37
def cleanup(folder):
 
38
    if os.path.isdir(folder):
 
39
        print 'Wiping out directory: %s' % folder
 
40
        shutil.rmtree(folder)
30
41
 
31
42
def symtree(src, dest):
32
43
    os.mkdir(dest)
37
48
            (os.path.isfile(fpath) and os.path.splitext(f)[1] == '.py'))):
38
49
                os.symlink(os.path.join(os.pardir, src, f), os.path.join(dest, f))
39
50
 
40
 
        
 
51
 
41
52
if sys.platform != 'win32':
42
 
    g_TempPackageDir = os.path.join(os.getcwd(), 'libavg')
43
 
    if os.getenv('srcdir') in ('.', None):
 
53
    tempPackageDir = os.path.join(os.getcwd(), 'libavg')
 
54
    # Possible values for srcdir:
 
55
    # '.': make check
 
56
    # None: ./Test.py
 
57
    # dir name: make distcheck
 
58
    srcDir = os.getenv("srcdir",".")
 
59
    if srcDir == '.':
 
60
        # Running make check or ./Test.py
44
61
        if os.path.basename(os.getcwd()) != 'test':
45
62
            raise RuntimeError('Manual tests must be performed inside directory "test"')
46
63
        
47
 
        if os.path.isdir(g_TempPackageDir):
48
 
            print 'Cleaning up old test package'
49
 
            shutil.rmtree(g_TempPackageDir)
 
64
        cleanup(tempPackageDir)
50
65
        
51
66
        try:
52
 
            # We're running make check / manual tests
53
67
            symtree('../python', 'libavg')
54
 
            # os.system('cp -r ../python libavg')
55
 
            os.symlink('../../wrapper/__init__.py', 'libavg/__init__.py')
56
68
        except OSError:
57
69
            pass
58
70
    else:
59
 
        # make distcheck
 
71
        # Running make distcheck
60
72
        symtree('../../../../src/python', 'libavg')
61
 
        os.symlink('../../../../../src/wrapper/__init__.py', 'libavg/__init__.py')
62
 
        sys.path.insert(0, os.getcwd())
 
73
 
 
74
        # distcheck doesn't want leftovers (.pyc files)
 
75
        atexit.register(lambda tempPackageDir=tempPackageDir: cleanup(tempPackageDir))
63
76
    
64
 
    os.symlink('../../wrapper/.libs/avg.so', 'libavg/avg.so')
 
77
    if os.path.exists('../wrapper/.libs/avg.so'):
 
78
        # Normal case: use the local version (not the installed one)
 
79
        os.symlink('../../wrapper/.libs/avg.so', 'libavg/avg.so')
 
80
    elif os.path.exists('../../avg.so'):
 
81
        # Mac version after installer dmg
 
82
        pass
 
83
    else:
 
84
        raise RuntimeError('Compile libavg before running tests or use "make check"')
65
85
 
66
 
    # The following lines help to prevent the test to be run
 
86
    # The following line prevents the test to be run
67
87
    # with an unknown version of libavg, which can be hiding somewhere
68
88
    # in the system
 
89
    sys.path.insert(0, os.getcwd())
 
90
 
 
91
    # Meaningful only for distcheck
 
92
    os.chdir(srcDir)
 
93
 
69
94
    import libavg
70
95
    libavg.avg.Logger.get().trace(libavg.avg.Logger.APP, "Using libavg from: "+
71
96
            os.path.dirname(libavg.__file__))
72
97
 
73
 
    cpfx = os.path.commonprefix((libavg.__file__, os.getcwd()))
74
 
    
75
 
#    if cpfx != os.getcwd():
76
 
#        raise RuntimeError(
77
 
#            'Tests would be performed with a non-local libavg package (%s)'
78
 
#            % libavg.__file__)
79
 
 
80
 
srcDir = os.getenv("srcdir",".")
81
 
os.chdir(srcDir)
82
98
 
83
99
import testapp   
84
100
   
94
110
import PythonTest
95
111
import AnimTest
96
112
import EventTest
97
 
from EventTest import mainMouseDown
98
 
from EventTest import mainMouseUp
99
 
 
 
113
import InputDeviceTest
 
114
import AVGAppTest
 
115
import UITest
100
116
 
101
117
app = testapp.TestApp()
102
118
 
112
128
app.registerSuiteFactory('python', PythonTest.pythonTestSuite)
113
129
app.registerSuiteFactory('anim', AnimTest.animTestSuite)
114
130
app.registerSuiteFactory('event', EventTest.eventTestSuite)
115
 
 
116
 
 
117
 
try:
118
 
    app.run()
119
 
finally:
120
 
    if g_TempPackageDir is not None:
121
 
        try:
122
 
            shutil.rmtree(g_TempPackageDir)
123
 
        except OSError:
124
 
            print 'ERROR: Cannot clean up test package directory'
 
131
app.registerSuiteFactory('inputdevice', InputDeviceTest.inputDeviceTestSuite)
 
132
app.registerSuiteFactory('ui', UITest.uiTestSuite)
 
133
app.registerSuiteFactory('avgapp', AVGAppTest.avgAppTestSuite)
 
134
 
 
135
app.run()
125
136
 
126
137
sys.exit(app.exitCode())
127
138