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 |
Christian Heimes | 412dc9c | 2008-01-27 18:55:54 +0000 | [diff] [blame^] | 6 | import time |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 7 | import unittest |
Gregory P. Smith | 3fd22da | 2007-08-28 08:05:56 +0000 | [diff] [blame] | 8 | import test.test_support |
| 9 | from test.test_support import requires, run_unittest, unlink |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 10 | |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 11 | # 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 Rossum | b053cd8 | 2006-08-24 03:53:23 +0000 | [diff] [blame] | 13 | if __name__ != '__main__': |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 14 | requires('bsddb') |
| 15 | |
Gregory P. Smith | 3fd22da | 2007-08-28 08:05:56 +0000 | [diff] [blame] | 16 | import bsddb.test.test_all |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 17 | if 'verbose' in sys.argv: |
Gregory P. Smith | 3fd22da | 2007-08-28 08:05:56 +0000 | [diff] [blame] | 18 | bsddb.test.test_all.verbose = 1 |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 19 | sys.argv.remove('verbose') |
| 20 | |
| 21 | if 'silent' in sys.argv: # take care of old flag, just in case |
Gregory P. Smith | 3fd22da | 2007-08-28 08:05:56 +0000 | [diff] [blame] | 22 | bsddb.test.test_all.verbose = 0 |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 23 | sys.argv.remove('silent') |
| 24 | |
| 25 | |
Christian Heimes | 412dc9c | 2008-01-27 18:55:54 +0000 | [diff] [blame^] | 26 | class 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öwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 50 | def suite(): |
Neal Norwitz | 62a2112 | 2006-01-25 05:21:55 +0000 | [diff] [blame] | 51 | try: |
| 52 | # this is special, it used to segfault the interpreter |
Martin v. Löwis | 32ca442 | 2007-08-11 06:13:20 +0000 | [diff] [blame] | 53 | import bsddb.test.test_1413192 |
Gregory P. Smith | 3fd22da | 2007-08-28 08:05:56 +0000 | [diff] [blame] | 54 | finally: |
| 55 | for f in ['xxx.db','__db.001','__db.002','__db.003','log.0000000001']: |
Neal Norwitz | 14361ff | 2006-01-25 07:20:47 +0000 | [diff] [blame] | 56 | unlink(f) |
Neal Norwitz | 62a2112 | 2006-01-25 05:21:55 +0000 | [diff] [blame] | 57 | |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 58 | test_modules = [ |
Martin v. Löwis | cccc58d | 2007-08-10 08:36:56 +0000 | [diff] [blame] | 59 | 'test_associate', |
| 60 | 'test_basics', |
| 61 | 'test_compat', |
Gregory P. Smith | 3fd22da | 2007-08-28 08:05:56 +0000 | [diff] [blame] | 62 | 'test_compare', |
Martin v. Löwis | cccc58d | 2007-08-10 08:36:56 +0000 | [diff] [blame] | 63 | 'test_dbobj', |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 64 | 'test_dbshelve', |
Martin v. Löwis | cccc58d | 2007-08-10 08:36:56 +0000 | [diff] [blame] | 65 | 'test_dbtables', |
| 66 | 'test_env_close', |
| 67 | 'test_get_none', |
| 68 | 'test_join', |
| 69 | 'test_lock', |
| 70 | 'test_misc', |
Gregory P. Smith | 3fd22da | 2007-08-28 08:05:56 +0000 | [diff] [blame] | 71 | 'test_pickle', |
Martin v. Löwis | cccc58d | 2007-08-10 08:36:56 +0000 | [diff] [blame] | 72 | 'test_queue', |
| 73 | 'test_recno', |
| 74 | 'test_thread', |
| 75 | 'test_sequence', |
| 76 | 'test_cursor_pget_bug', |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 77 | ] |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 78 | |
| 79 | alltests = unittest.TestSuite() |
| 80 | for name in test_modules: |
| 81 | module = __import__("bsddb.test."+name, globals(), locals(), name) |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 82 | #print module,name |
| 83 | alltests.addTest(module.test_suite()) |
Christian Heimes | 412dc9c | 2008-01-27 18:55:54 +0000 | [diff] [blame^] | 84 | alltests.addTest(unittest.makeSuite(TimingCheck)) |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 85 | return alltests |
| 86 | |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 87 | |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 88 | # For invocation through regrtest |
| 89 | def test_main(): |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 90 | run_unittest(suite()) |
Barry Warsaw | 0a26235 | 2002-12-30 20:53:18 +0000 | [diff] [blame] | 91 | |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 92 | # For invocation as a script |
| 93 | if __name__ == '__main__': |
| 94 | from bsddb import db |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 95 | 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öwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 102 | |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 103 | test_main() |