Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 1 | # Test driver for bsddb package. |
| 2 | """ |
| 3 | Run all test cases. |
| 4 | """ |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 5 | import sys |
Neal Norwitz | 41ada16 | 2008-01-27 17:13:07 +0000 | [diff] [blame] | 6 | import time |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 7 | import unittest |
Collin Winter | c2898c5 | 2007-04-25 17:29:52 +0000 | [diff] [blame] | 8 | from test.test_support import requires, verbose, run_unittest, unlink |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 9 | |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 10 | # When running as a script instead of within the regrtest framework, skip the |
| 11 | # requires test, since it's obvious we want to run them. |
Collin Winter | c2898c5 | 2007-04-25 17:29:52 +0000 | [diff] [blame] | 12 | if __name__ != '__main__': |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 13 | requires('bsddb') |
| 14 | |
| 15 | verbose = False |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 16 | if 'verbose' in sys.argv: |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 17 | verbose = True |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 18 | sys.argv.remove('verbose') |
| 19 | |
| 20 | if 'silent' in sys.argv: # take care of old flag, just in case |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 21 | verbose = False |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 22 | sys.argv.remove('silent') |
| 23 | |
| 24 | |
Neal Norwitz | 41ada16 | 2008-01-27 17:13:07 +0000 | [diff] [blame] | 25 | class TimingCheck(unittest.TestCase): |
| 26 | |
| 27 | """This class is not a real test. Its purpose is to print a message |
| 28 | periodically when the test runs slowly. This will prevent the buildbots |
| 29 | from timing out on slow machines.""" |
| 30 | |
| 31 | # How much time in seconds before printing a 'Still working' message. |
| 32 | # Since this is run at most once between each test module, use a smaller |
| 33 | # interval than other tests. |
| 34 | _PRINT_WORKING_MSG_INTERVAL = 4 * 60 |
| 35 | |
| 36 | # next_time is used as a global variable that survives each instance. |
| 37 | # This is necessary since a new instance will be created for each test. |
| 38 | next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL |
| 39 | |
| 40 | def testCheckElapsedTime(self): |
| 41 | # Print still working message since these tests can be really slow. |
| 42 | now = time.time() |
| 43 | if self.next_time <= now: |
| 44 | TimingCheck.next_time = now + self._PRINT_WORKING_MSG_INTERVAL |
| 45 | sys.__stdout__.write(' test_bsddb3 still working, be patient...\n') |
| 46 | sys.__stdout__.flush() |
| 47 | |
| 48 | |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 49 | def suite(): |
Neal Norwitz | 62a2112 | 2006-01-25 05:21:55 +0000 | [diff] [blame] | 50 | try: |
| 51 | # this is special, it used to segfault the interpreter |
| 52 | import bsddb.test.test_1413192 |
| 53 | except: |
Neal Norwitz | 14361ff | 2006-01-25 07:20:47 +0000 | [diff] [blame] | 54 | for f in ['__db.001', '__db.002', '__db.003', 'log.0000000001']: |
| 55 | unlink(f) |
Neal Norwitz | 62a2112 | 2006-01-25 05:21:55 +0000 | [diff] [blame] | 56 | |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 57 | test_modules = [ |
| 58 | 'test_associate', |
| 59 | 'test_basics', |
| 60 | 'test_compat', |
| 61 | 'test_dbobj', |
| 62 | 'test_dbshelve', |
| 63 | 'test_dbtables', |
| 64 | 'test_env_close', |
| 65 | 'test_get_none', |
| 66 | 'test_join', |
| 67 | 'test_lock', |
| 68 | 'test_misc', |
| 69 | 'test_queue', |
| 70 | 'test_recno', |
| 71 | 'test_thread', |
Gregory P. Smith | f0547d0 | 2006-06-05 17:38:04 +0000 | [diff] [blame] | 72 | 'test_sequence', |
Gregory P. Smith | 372b583 | 2006-06-05 18:48:21 +0000 | [diff] [blame] | 73 | 'test_cursor_pget_bug', |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 74 | ] |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 75 | |
| 76 | alltests = unittest.TestSuite() |
| 77 | for name in test_modules: |
| 78 | module = __import__("bsddb.test."+name, globals(), locals(), name) |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 79 | #print module,name |
| 80 | alltests.addTest(module.test_suite()) |
Neal Norwitz | 41ada16 | 2008-01-27 17:13:07 +0000 | [diff] [blame] | 81 | alltests.addTest(unittest.makeSuite(TimingCheck)) |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 82 | return alltests |
| 83 | |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 84 | |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 85 | # For invocation through regrtest |
| 86 | def test_main(): |
Collin Winter | c2898c5 | 2007-04-25 17:29:52 +0000 | [diff] [blame] | 87 | run_unittest(suite()) |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 88 | |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 89 | # For invocation as a script |
| 90 | if __name__ == '__main__': |
| 91 | from bsddb import db |
| 92 | print '-=' * 38 |
| 93 | print db.DB_VERSION_STRING |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 94 | print 'bsddb.db.version(): %s' % (db.version(),) |
| 95 | print 'bsddb.db.__version__: %s' % db.__version__ |
| 96 | print 'bsddb.db.cvsid: %s' % db.cvsid |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 97 | print 'python version: %s' % sys.version |
| 98 | print '-=' * 38 |
| 99 | |
Collin Winter | c2898c5 | 2007-04-25 17:29:52 +0000 | [diff] [blame] | 100 | test_main() |