blob: a88b1136f1b249b2e1987bc0343938db2d73a0c0 [file] [log] [blame]
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +00001# Test driver for bsddb package.
2"""
3Run all test cases.
4"""
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +00005import sys
Christian Heimes412dc9c2008-01-27 18:55:54 +00006import time
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +00007import unittest
Gregory P. Smith3fd22da2007-08-28 08:05:56 +00008import test.test_support
9from test.test_support import requires, run_unittest, unlink
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000010
Barry Warsaw0a262352002-12-30 20:53:18 +000011# When running as a script instead of within the regrtest framework, skip the
12# requires test, since it's obvious we want to run them.
Guido van Rossumb053cd82006-08-24 03:53:23 +000013if __name__ != '__main__':
Barry Warsaw0a262352002-12-30 20:53:18 +000014 requires('bsddb')
15
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000016import bsddb.test.test_all
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000017if 'verbose' in sys.argv:
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000018 bsddb.test.test_all.verbose = 1
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000019 sys.argv.remove('verbose')
20
21if 'silent' in sys.argv: # take care of old flag, just in case
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000022 bsddb.test.test_all.verbose = 0
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000023 sys.argv.remove('silent')
24
25
Christian Heimes412dc9c2008-01-27 18:55:54 +000026class TimingCheck(unittest.TestCase):
27
28 """This class is not a real test. Its purpose is to print a message
29 periodically when the test runs slowly. This will prevent the buildbots
30 from timing out on slow machines."""
31
32 # How much time in seconds before printing a 'Still working' message.
33 # Since this is run at most once between each test module, use a smaller
34 # interval than other tests.
35 _PRINT_WORKING_MSG_INTERVAL = 4 * 60
36
37 # next_time is used as a global variable that survives each instance.
38 # This is necessary since a new instance will be created for each test.
39 next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
40
41 def testCheckElapsedTime(self):
42 # Print still working message since these tests can be really slow.
43 now = time.time()
44 if self.next_time <= now:
45 TimingCheck.next_time = now + self._PRINT_WORKING_MSG_INTERVAL
46 sys.__stdout__.write(' test_bsddb3 still working, be patient...\n')
47 sys.__stdout__.flush()
48
49
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000050def suite():
Neal Norwitz62a21122006-01-25 05:21:55 +000051 try:
52 # this is special, it used to segfault the interpreter
Martin v. Löwis32ca4422007-08-11 06:13:20 +000053 import bsddb.test.test_1413192
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000054 finally:
55 for f in ['xxx.db','__db.001','__db.002','__db.003','log.0000000001']:
Neal Norwitz14361ff2006-01-25 07:20:47 +000056 unlink(f)
Neal Norwitz62a21122006-01-25 05:21:55 +000057
Barry Warsaw0a262352002-12-30 20:53:18 +000058 test_modules = [
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000059 'test_associate',
60 'test_basics',
61 'test_compat',
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000062 'test_compare',
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000063 'test_dbobj',
Barry Warsaw0a262352002-12-30 20:53:18 +000064 'test_dbshelve',
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000065 'test_dbtables',
66 'test_env_close',
67 'test_get_none',
68 'test_join',
69 'test_lock',
70 'test_misc',
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000071 'test_pickle',
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000072 'test_queue',
73 'test_recno',
74 'test_thread',
75 'test_sequence',
76 'test_cursor_pget_bug',
Barry Warsaw0a262352002-12-30 20:53:18 +000077 ]
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000078
79 alltests = unittest.TestSuite()
80 for name in test_modules:
81 module = __import__("bsddb.test."+name, globals(), locals(), name)
Barry Warsaw0a262352002-12-30 20:53:18 +000082 #print module,name
83 alltests.addTest(module.test_suite())
Christian Heimes412dc9c2008-01-27 18:55:54 +000084 alltests.addTest(unittest.makeSuite(TimingCheck))
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000085 return alltests
86
Barry Warsaw0a262352002-12-30 20:53:18 +000087
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000088# For invocation through regrtest
89def test_main():
Guido van Rossumd8faa362007-04-27 19:54:29 +000090 run_unittest(suite())
Barry Warsaw0a262352002-12-30 20:53:18 +000091
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000092# For invocation as a script
93if __name__ == '__main__':
94 from bsddb import db
Guido van Rossumbe19ed72007-02-09 05:37:30 +000095 print('-=' * 38)
96 print(db.DB_VERSION_STRING)
97 print('bsddb.db.version(): %s' % (db.version(),))
98 print('bsddb.db.__version__: %s' % db.__version__)
99 print('bsddb.db.cvsid: %s' % db.cvsid)
100 print('python version: %s' % sys.version)
101 print('-=' * 38)
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +0000102
Guido van Rossumd8faa362007-04-27 19:54:29 +0000103 test_main()