~ubuntu-branches/ubuntu/quantal/pytables/quantal

« back to all changes in this revision

Viewing changes to .pc/disable_blosc.patch/tables/tests/test_all.py

  • Committer: Package Import Robot
  • Author(s): Julian Taylor
  • Date: 2012-02-22 20:02:57 UTC
  • Revision ID: package-import@ubuntu.com-20120222200257-et1xgv12we3ch3eo
Tags: 2.3.1-2ubuntu2
* fix_library_detection.patch:
  fix detection of multiarched libraries, reenables bzip and lzo compression
* disable_blosc.patch:
  disable blosc compressor on arm, not functional due to unaligned memory
  accesses
* make testsuite output verbose

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Run all test cases.
 
3
"""
 
4
 
 
5
import sys
 
6
import os
 
7
import re
 
8
import unittest
 
9
 
 
10
import numpy
 
11
 
 
12
import numexpr
 
13
import tables
 
14
from tables.req_versions import *
 
15
from tables.tests import common
 
16
from tables.utils import detectNumberOfCores
 
17
 
 
18
 
 
19
 
 
20
def get_tuple_version(hexversion):
 
21
    """Get a tuple from a compact version in hex."""
 
22
    h = hexversion
 
23
    return(h & 0xff0000) >> 16, (h & 0xff00) >> 8, h & 0xff
 
24
 
 
25
 
 
26
 
 
27
def suite():
 
28
    test_modules = [
 
29
        'tables.tests.test_attributes',
 
30
        'tables.tests.test_basics',
 
31
        'tables.tests.test_create',
 
32
        'tables.tests.test_backcompat',
 
33
        'tables.tests.test_types',
 
34
        'tables.tests.test_lists',
 
35
        'tables.tests.test_tables',
 
36
        'tables.tests.test_tablesMD',
 
37
        'tables.tests.test_array',
 
38
        'tables.tests.test_earray',
 
39
        'tables.tests.test_carray',
 
40
        'tables.tests.test_vlarray',
 
41
        'tables.tests.test_tree',
 
42
        'tables.tests.test_timetype',
 
43
        'tables.tests.test_do_undo',
 
44
        'tables.tests.test_enum',
 
45
        'tables.tests.test_nestedtypes',
 
46
        'tables.tests.test_hdf5compat',
 
47
        'tables.tests.test_numpy',
 
48
        'tables.tests.test_queries',
 
49
        'tables.tests.test_expression',
 
50
        'tables.tests.test_links',
 
51
        'tables.tests.test_indexes',
 
52
        'tables.tests.test_indexvalues',
 
53
        'tables.tests.test_index_backcompat',
 
54
        # Sub-packages
 
55
        'tables.nodes.tests.test_filenode',
 
56
        #'tables.netcdf3.tests.test_netcdf3',
 
57
    ]
 
58
 
 
59
    # Numeric is now deprecated
 
60
    # Add test_Numeric only if Numeric is installed
 
61
    if False:   # if common.numeric_imported:
 
62
        import Numeric
 
63
        print "Numeric (version %s) is present. Adding the Numeric test suite." % \
 
64
              (Numeric.__version__)
 
65
        if Numeric.__version__ < min_numeric_version:
 
66
            print "*Warning*: Numeric version is lower than recommended: %s < %s" % \
 
67
                  (Numeric.__version__, min_numeric_version)
 
68
        test_modules.append("tables.tests.test_Numeric")
 
69
    else:
 
70
        pass
 
71
        # Do not print this anymore
 
72
        #print "Skipping Numeric test suite."
 
73
 
 
74
    # numarray is now deprecated
 
75
    # Add test_numarray only if numarray is installed
 
76
    if False:   # if common.numarray_imported:
 
77
        import numarray
 
78
        print \
 
79
"""numarray (version %s) is present. Adding the numarray test suite.""" % \
 
80
              (numarray.__version__)
 
81
        if numarray.__version__ < min_numarray_version:
 
82
            print \
 
83
"*Warning*: Numarray version is lower than recommended: %s < %s" % \
 
84
                  (numarray.__version__, min_numarray_version)
 
85
        test_modules.append("tables.tests.test_numarray")
 
86
        test_modules.append("tables.nra.tests.test_nestedrecords")
 
87
        test_modules.append("tables.nra.tests.test_nriterators")
 
88
    else:
 
89
        pass
 
90
        # Do not print this anymore
 
91
        #print "Skipping numarray test suite."
 
92
    #print '-=' * 38
 
93
 
 
94
 
 
95
    # The test for garbage must be run *in the last place*.
 
96
    # Else, it is not as useful.
 
97
    test_modules.append('tables.tests.test_garbage')
 
98
 
 
99
    alltests = unittest.TestSuite()
 
100
    if common.show_memory:
 
101
        # Add a memory report at the beginning
 
102
        alltests.addTest(unittest.makeSuite(common.ShowMemTime))
 
103
    for name in test_modules:
 
104
        exec('from %s import suite as test_suite' % name)
 
105
        alltests.addTest(test_suite())
 
106
        if common.show_memory:
 
107
            # Add a memory report after each test module
 
108
            alltests.addTest(unittest.makeSuite(common.ShowMemTime))
 
109
    return alltests
 
110
 
 
111
 
 
112
def print_versions():
 
113
    """Print all the versions of software that PyTables relies on."""
 
114
    print '-=' * 38
 
115
    print "PyTables version:  %s" % tables.__version__
 
116
    print "HDF5 version:      %s" % tables.whichLibVersion("hdf5")[1]
 
117
    print "NumPy version:     %s" % numpy.__version__
 
118
    tinfo = tables.whichLibVersion("zlib")
 
119
    if numexpr.use_vml:
 
120
        # Get only the main version number and strip out all the rest
 
121
        vml_version = numexpr.get_vml_version()
 
122
        vml_version = re.findall("[0-9.]+", vml_version)[0]
 
123
        vml_avail = "using VML/MKL %s" % vml_version
 
124
    else:
 
125
        vml_avail = "not using Intel's VML/MKL"
 
126
    print "Numexpr version:   %s (%s)" % (numexpr.__version__, vml_avail)
 
127
    if tinfo is not None:
 
128
        print "Zlib version:      %s (%s)" % (tinfo[1], "in Python interpreter")
 
129
    tinfo = tables.whichLibVersion("lzo")
 
130
    if tinfo is not None:
 
131
        print "LZO version:       %s (%s)" % (tinfo[1], tinfo[2])
 
132
    tinfo = tables.whichLibVersion("bzip2")
 
133
    if tinfo is not None:
 
134
        print "BZIP2 version:     %s (%s)" % (tinfo[1], tinfo[2])
 
135
    tinfo = tables.whichLibVersion("blosc")
 
136
    blosc_date = tinfo[2].split()[1]
 
137
    if tinfo is not None:
 
138
        print "Blosc version:     %s (%s)" % (tinfo[1], blosc_date)
 
139
    try:
 
140
        from Cython.Compiler.Main import Version as Cython_Version
 
141
        print 'Cython version:    %s' % Cython_Version.version
 
142
    except:
 
143
        pass
 
144
    print 'Python version:    %s' % sys.version
 
145
    if os.name == 'posix':
 
146
        (sysname, nodename, release, version, machine) = os.uname()
 
147
        print 'Platform:          %s-%s' % (sys.platform, machine)
 
148
    print 'Byte-ordering:     %s' % sys.byteorder
 
149
    print 'Detected cores:    %s' % detectNumberOfCores()
 
150
    print '-=' * 38
 
151
 
 
152
 
 
153
def print_heavy(heavy):
 
154
    if heavy:
 
155
        print """\
 
156
Performing the complete test suite!"""
 
157
    else:
 
158
        print """\
 
159
Performing only a light (yet comprehensive) subset of the test suite.
 
160
If you want a more complete test, try passing the --heavy flag to this script
 
161
(or set the 'heavy' parameter in case you are using tables.test() call).
 
162
The whole suite will take more than 4 hours to complete on a relatively
 
163
modern CPU and around 512 MB of main memory."""
 
164
    print '-=' * 38
 
165
 
 
166
 
 
167
def test(verbose=False, heavy=False):
 
168
    """
 
169
    Run all the tests in the test suite.
 
170
 
 
171
    If `verbose` is set, the test suite will emit messages with full
 
172
    verbosity (not recommended unless you are looking into a certain
 
173
    problem).
 
174
 
 
175
    If `heavy` is set, the test suite will be run in *heavy* mode (you
 
176
    should be careful with this because it can take a lot of time and
 
177
    resources from your computer).
 
178
    """
 
179
    print_versions()
 
180
    print_heavy(heavy)
 
181
 
 
182
    # What a context this is!
 
183
    oldverbose, common.verbose = common.verbose, verbose
 
184
    oldheavy, common.heavy = common.heavy, heavy
 
185
    try:
 
186
        unittest.TextTestRunner().run(suite())
 
187
    finally:
 
188
        common.verbose = oldverbose
 
189
        common.heavy = oldheavy  # there are pretty young heavies, too ;)
 
190
 
 
191
 
 
192
if __name__ == '__main__':
 
193
 
 
194
    hdf5_version = get_tuple_version(tables.whichLibVersion("hdf5")[0])
 
195
    if hdf5_version < min_hdf5_version:
 
196
        print "*Warning*: HDF5 version is lower than recommended: %s < %s" % \
 
197
              (hdf5_version, min_hdf5_version)
 
198
 
 
199
    if numpy.__version__ < min_numpy_version:
 
200
        print "*Warning*: NumPy version is lower than recommended: %s < %s" % \
 
201
              (numpy.__version__, min_numpy_version)
 
202
 
 
203
    # Handle some global flags (i.e. only useful for test_all.py)
 
204
    only_versions = 0
 
205
    args = sys.argv[:]
 
206
    for arg in args:
 
207
        # Remove 'show-versions' for PyTables 2.3 or higher
 
208
        if arg in ['--print-versions', '--show-versions']:
 
209
            only_versions = True
 
210
            sys.argv.remove(arg)
 
211
        elif arg == '--show-memory':
 
212
            common.show_memory = True
 
213
            sys.argv.remove(arg)
 
214
 
 
215
    print_versions()
 
216
    if not only_versions:
 
217
        print_heavy(common.heavy)
 
218
        unittest.main(defaultTest='tables.tests.suite')