X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=test%2Fintegration%2Ftestlib%2Fproc.py;h=ffa0a5f50c536d41478e7f537082a42af4dedc94;hb=b4280adda649c177ad27349fad4d51c2ebd9d35d;hp=1faea55099ecdb2629c64c4eea0269aa324b5351;hpb=0289162552cd85375605044c696e2a3294e7aa9a;p=tinc diff --git a/test/integration/testlib/proc.py b/test/integration/testlib/proc.py index 1faea550..ffa0a5f5 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" @@ -148,6 +149,11 @@ class Tinc: """Return path to a subdirectory within the working dir for this node.""" return os.path.join(self._work_dir, *paths) + @property + def work_dir(self): + """Node's working directory.""" + return self._work_dir + @property def script_up(self) -> str: """Name of the hosts/XXX-up script for this node.""" @@ -213,12 +219,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) @@ -231,7 +237,7 @@ class Tinc: 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] @@ -243,7 +249,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