Permalink
Browse files

[svn r4451] use 'real' DD tool for bisecting

--HG--
branch : trunk
  • Loading branch information...
1 parent 11d7375 commit ca70326c86495ea81095f4a10f62b0703e41a46e scoder committed Aug 8, 2010
Showing with 970 additions and 39 deletions.
  1. +943 −0 DD.py
  2. +27 −39 bisect_crashes.py
View
Oops, something went wrong.
View
@@ -11,6 +11,7 @@
sys.path.insert(1, test_base_path)
import test
+from DD import DD
cfg = test.Options()
cfg.verbosity = 0
@@ -27,46 +28,33 @@ def find_tests():
test_files = test.get_test_files(cfg)
return test.get_test_cases(test_files, cfg)
-def run_tests(test_cases):
- if not test_cases:
- return True
- write('Running subset of %d tests [%s .. %s]',
- len(test_cases), test_cases[0].id(), test_cases[-1].id())
- pid = os.fork()
- if not pid:
- # child executes tests
- runner = test.CustomTestRunner(cfg, None)
- suite = unittest.TestSuite()
- suite.addTests(test_cases)
- os._exit( not runner.run(suite).wasSuccessful() )
- cid, retval = os.waitpid(pid, 0)
- if retval:
- write('exit status: %d, signal: %d', retval >> 8, retval % 0xFF)
- return (retval % 0xFF) == 0 # signal
-
-def bisect_tests():
+class DDTester(DD):
+ def _test(self, test_cases):
+ if not test_cases:
+ return self.PASS
+ test_cases = [ item[-1] for item in test_cases ]
+ write('Running subset of %d tests [%s .. %s]',
+ len(test_cases), test_cases[0].id(), test_cases[-1].id())
+ pid = os.fork()
+ if not pid:
+ # child executes tests
+ runner = test.CustomTestRunner(cfg, None)
+ suite = unittest.TestSuite()
+ suite.addTests(test_cases)
+ os._exit( not runner.run(suite).wasSuccessful() )
+ cid, retval = os.waitpid(pid, 0)
+ if retval:
+ write('exit status: %d, signal: %d', retval >> 8, retval % 0xFF)
+ if (retval % 0xFF) != 0: # signal received?
+ return self.FAIL
+ return self.PASS
+
+def dd_tests():
tests = find_tests()
write('Found %d tests', len(tests))
- shift = len(tests) // 4
- failed = []
- while len(tests) > 1 and shift > 0:
- mid = len(tests) // 2 + 1
- left, right = tests[:mid], tests[mid:]
-
- if not run_tests(left):
- failed = left[:]
- tests = left
- shift = len(tests) // 4 + 1
- elif not run_tests(right):
- failed = right[:]
- tests = right
- shift = len(tests) // 4 + 1
- else:
- # retry
- shift //= 2
- tests = tests[shift:] + tests[:shift]
- # looks like we can't make the set of tests any smaller
- return failed
+ dd = DDTester()
+ min_tests = dd.ddmin( list(enumerate(tests)) )
+ return [ item[-1] for item in min_tests ]
if __name__ == '__main__':
- write('Failing tests:\n%s', '\n'.join([test.id() for test in bisect_tests()]))
+ write('Failing tests:\n%s', '\n'.join([test.id() for test in dd_tests()]))

0 comments on commit ca70326

Please sign in to comment.