X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=test%2Fintegration%2Ftestlib%2Fproc.py;h=d5cbee484c200e461437ac4ed8d2357645629151;hb=fa87753574693e3d71dd035983cbdfb136fdb0d8;hp=8ac65baf0cd7fb3e61d6eaf85ecb60aa63f42bef;hpb=9a012e485a2ed5ea5a28903d93bc625767bb20b2;p=tinc diff --git a/test/integration/testlib/proc.py b/test/integration/testlib/proc.py index 8ac65baf..d5cbee48 100755 --- a/test/integration/testlib/proc.py +++ b/test/integration/testlib/proc.py @@ -50,6 +50,7 @@ class Feature(Enum): OPENSSL = "openssl" READLINE = "readline" TUNEMU = "tunemu" + SANDBOX = "sandbox" UML = "uml" VDE = "vde" @@ -213,12 +214,12 @@ class Tinc: return self._port def cmd( - self, *args: str, code: T.Optional[int] = 0, stdin: T.Optional[str] = None + self, *args: str, code: T.Optional[int] = 0, stdin: T.Optional[T.AnyStr] = None ) -> T.Tuple[str, str]: """Run command through tinc, writes `stdin` to it (if the argument is not None), check its return code (if the argument is not None), and return (stdout, stderr). """ - proc = self.tinc(*args) + proc = self.tinc(*args, binary=isinstance(stdin, bytes)) log.debug('tinc %s: PID %d, in "%s", want code %s', self, proc.pid, stdin, code) out, err = proc.communicate(stdin, timeout=60) @@ -229,12 +230,9 @@ class Tinc: if code is not None: check.equals(code, res) - # Check that port was not used by something else - check.not_in("Can't bind to ", err) - return out if out else "", err if err else "" - def tinc(self, *args: str) -> subp.Popen: + def tinc(self, *args: str, binary=False) -> subp.Popen: """Start tinc with the specified arguments.""" args = tuple(filter(bool, args)) cmd = [path.TINC_PATH, *self._common_args, *args] @@ -246,7 +244,7 @@ class Tinc: stdin=subp.PIPE, stdout=subp.PIPE, stderr=subp.PIPE, - encoding="utf-8", + encoding=None if binary else "utf-8", ) self._procs.append(proc) return proc