Skip to content

Commit bf74d37

Browse files
author
MarcoFalke
committed
Merge #11023: [tests] Add option to attach a python debugger if functional test fails
cc5d38f Add option to attach a python debugger if test fails (John Newbery) Pull request description: Adds a simple option to the test_framework to attach pdb if the test fails. Helpful for catching and debugging intermittent failures: Run the test in a loop with this option. The first failure will cause execution to pause and nodes will be left running for interactive debugging. @sdaftuar Tree-SHA512: 01cfae15fa3f04ed6ec6a99fef60a6c6a59723429309e81eacd6767caf12f5758f59b337804291ecab33a38a2958f36e2b513d201bee72a2eeb207a67046f952
2 parents 2c811e0 + cc5d38f commit bf74d37

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import logging
1212
import optparse
1313
import os
14+
import pdb
1415
import shutil
1516
import subprocess
1617
import sys
@@ -125,6 +126,8 @@ def main(self):
125126
help="Write tested RPC commands into this directory")
126127
parser.add_option("--configfile", dest="configfile",
127128
help="Location of the test framework config file")
129+
parser.add_option("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
130+
help="Attach a python debugger if test fails")
128131
self.add_options(parser)
129132
(self.options, self.args) = parser.parse_args()
130133

@@ -162,6 +165,10 @@ def main(self):
162165
except KeyboardInterrupt as e:
163166
self.log.warning("Exiting after keyboard interrupt")
164167

168+
if success == TestStatus.FAILED and self.options.pdbonfailure:
169+
print("Testcase failed. Attaching python debugger. Enter ? for help")
170+
pdb.set_trace()
171+
165172
if not self.options.noshutdown:
166173
self.log.info("Stopping nodes")
167174
if self.nodes:

0 commit comments

Comments
 (0)