Skip to content

Commit cc5d38f

Browse files
committed
Add option to attach a python debugger if test fails
1 parent fa64636 commit cc5d38f

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)