Skip to content

Commit d6af14a

Browse files
cdeckerrustyrussell
authored andcommitted
pytest: Valgrind errors trump exit value errors
Raising the exception about non-zero exit values into the teardown. This was previously masking the valgrind errors. Now valgrind errors > crash errors > non-zero return value. Still hoping to catch that elusive [7, 0] return value on travis. Signed-off-by: Christian Decker <[email protected]>
1 parent bab0693 commit d6af14a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/test_lightningd.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def killall(self):
140140
except:
141141
failed = True
142142
rcs.append(n.daemon.proc.returncode)
143-
if failed:
144-
raise Exception("At least one lightning exited with non-zero return code: {}".format(rcs))
143+
return rcs
144+
145145

146146

147147
class BaseLightningDTests(unittest.TestCase):
@@ -190,7 +190,7 @@ def printCrashLog(self, node):
190190
return 1 if errors else 0
191191

192192
def tearDown(self):
193-
self.node_factory.killall()
193+
rcs = self.node_factory.killall()
194194
self.executor.shutdown(wait=False)
195195

196196
err_count = 0
@@ -199,14 +199,18 @@ def tearDown(self):
199199
for node in self.node_factory.nodes:
200200
err_count += self.printValgrindErrors(node)
201201
if err_count:
202-
raise ValueError(
203-
"{} nodes reported valgrind errors".format(err_count))
202+
raise ValueError("{} nodes reported valgrind errors".format(err_count))
204203

205204
for node in self.node_factory.nodes:
206205
err_count += self.printCrashLog(node)
207206
if err_count:
208-
raise ValueError(
209-
"{} nodes had crash.log files".format(err_count))
207+
raise ValueError("{} nodes had crash.log files".format(err_count))
208+
209+
# Which nodes may fail? Mask away the ones that we know will fail
210+
failmask = [not n.may_fail for n in self.node_factory.nodes]
211+
unexpected = [(failmask[i] * rcs[i]) for i in range(len(rcs))]
212+
if len([u for u in unexpected if u > 0]) > 0:
213+
raise Exception("At least one lightning exited with unexpected non-zero return code: {}".format(unexpected))
210214

211215
class LightningDTests(BaseLightningDTests):
212216
def connect(self):

0 commit comments

Comments
 (0)