Note: some tests may fail without an internet connection.
+Additional usage notes
+----------------------
+
+- Not everything is logged into pytest's standard output. To inspect the logs of
+ `kresd` itself, see `/tmp/pytest-of-<username>/pytest-current`.
+- The `rr` and `valgrind` parameters of the `Kresd` constructor may be used to
+ gain further information on failing tests. Simply set them to `True` in the
+ test cases temporarily if you need them.
+ - `rr=True` will record the execution of `kresd`, which can then be replayed
+ with the usual `rr replay` command.
+ - `valgrind=True` will run `kresd` under `valgrind`, the results of which
+ can be inspected in `kresd`'s logs (see above).
+
Developer notes
---------------
class Kresd(ContextDecorator):
def __init__(
self, workdir, port=None, tls_port=None, ip=None, ip6=None, certname=None,
- verbose=True, hints=None, forward=None, policy_test_pass=False):
+ verbose=True, hints=None, forward=None, policy_test_pass=False, rr=False,
+ valgrind=False):
if ip is None and ip6 is None:
raise ValueError("IPv4 or IPv6 must be specified!")
self.workdir = str(workdir)
self.hints = {} if hints is None else hints
self.forward = forward
self.policy_test_pass = policy_test_pass
+ self.rr = rr
+ self.valgrind = valgrind
if certname:
self.tls_cert_path = os.path.join(CERTS_DIR, certname + '.cert.pem')
create_file_from_template(KRESD_CONF_TEMPLATE, self.config_path, {'kresd': self})
self.logfile = open(self.logfile_path, 'w', encoding='UTF-8')
+
+ proc_args = ['kresd', '-c', self.config_path, '-n', self.workdir]
+ if self.rr:
+ proc_args = ['rr', 'record', '--'] + proc_args
+ if self.valgrind:
+ proc_args = ['valgrind', '--'] + proc_args
+
self.process = subprocess.Popen(
- ['kresd', '-c', self.config_path, '-n', self.workdir],
+ proc_args,
stderr=self.logfile, env=os.environ.copy())
try: