mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-10 01:24:30 +01:00
test_lightningd: fix valgrind detection on children.
I tracked down a bug, and couldn't figure out why valgrind wasn't
finding it.
From man valgrind:
--log-file=<filename>
Specifies that Valgrind should send all of its messages to the
specified file. If the file name is empty, it causes an abort.
There are three special format specifiers that can be used in the
file name.
%p is replaced with the current process ID. This is very useful for
program that invoke multiple processes. WARNING: If you use
--trace-children=yes and your program invokes multiple processes OR
your program forks without calling exec afterwards, and you don't
use this specifier (or the %q specifier below), the Valgrind output
from all those processes will go into one file, possibly jumbled
up, and possibly incomplete.
"possibly incomplete" indeed!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -9,6 +9,7 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import sqlite3
|
||||
import string
|
||||
import sys
|
||||
@@ -114,7 +115,7 @@ class NodeFactory(object):
|
||||
'--trace-children=yes',
|
||||
'--trace-children-skip=*bitcoin-cli*',
|
||||
'--error-exitcode=7',
|
||||
'--log-file={}/valgrind-errors'.format(node.daemon.lightning_dir)
|
||||
'--log-file={}/valgrind-errors.%p'.format(node.daemon.lightning_dir)
|
||||
] + node.daemon.cmd_line
|
||||
|
||||
node.daemon.start()
|
||||
@@ -135,10 +136,14 @@ class BaseLightningDTests(unittest.TestCase):
|
||||
self.node_factory = NodeFactory(self, self.executor)
|
||||
|
||||
def getValgrindErrors(self, node):
|
||||
error_file = '{}valgrind-errors'.format(node.daemon.lightning_dir)
|
||||
with open(error_file, 'r') as f:
|
||||
errors = f.read().strip()
|
||||
return errors, error_file
|
||||
for error_file in os.listdir(node.daemon.lightning_dir):
|
||||
if not re.match("valgrind-errors.\d+", error_file):
|
||||
continue;
|
||||
with open(os.path.join(node.daemon.lightning_dir, error_file), 'r') as f:
|
||||
errors = f.read().strip()
|
||||
if errors:
|
||||
return errors, error_file
|
||||
return None, None
|
||||
|
||||
def printValgrindErrors(self, node):
|
||||
errors, fname = self.getValgrindErrors(node)
|
||||
|
||||
Reference in New Issue
Block a user