diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-11-24 17:48:39 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-11-24 11:34:30 +0100 |
commit | ea1889d4b58e80c12de87f3987da49e4da1e9717 (patch) | |
tree | e212e9438c5a100bdcbb3727a8029ebe96138b84 /wintest/wintest.py | |
parent | 6ead7fbae534b7cc25310d8ea2875fc2e737a2b7 (diff) | |
download | samba-ea1889d4b58e80c12de87f3987da49e4da1e9717.tar.gz |
wintest: added an IPv6 address, and use fully qualified hostname
this also makes the resolv.conf handling more robust
Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Wed Nov 24 11:34:30 CET 2010 on sn-devel-104
Diffstat (limited to 'wintest/wintest.py')
-rw-r--r-- | wintest/wintest.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/wintest/wintest.py b/wintest/wintest.py index 81e2eda5157..36d0659f031 100644 --- a/wintest/wintest.py +++ b/wintest/wintest.py @@ -117,6 +117,7 @@ class wintest(): f.close() def run_cmd(self, cmd, dir=".", show=None, output=False, checkfail=True): + '''run a command''' cmd = self.substitute(cmd) if isinstance(cmd, list): self.info('$ ' + " ".join(cmd)) @@ -133,7 +134,9 @@ class wintest(): else: return subprocess.call(cmd, shell=shell, cwd=dir) + def run_child(self, cmd, dir="."): + '''create a child and return the Popen handle to it''' cwd = os.getcwd() cmd = self.substitute(cmd) if isinstance(cmd, list): @@ -145,7 +148,7 @@ class wintest(): else: shell=True os.chdir(dir) - ret = subprocess.Popen(cmd, shell=shell) + ret = subprocess.Popen(cmd, shell=shell, stderr=subprocess.STDOUT) os.chdir(cwd) return ret @@ -200,7 +203,7 @@ class wintest(): retries = retries - 1 raise RuntimeError("Failed to find %s" % contains) - def pexpect_spawn(self, cmd, timeout=60): + def pexpect_spawn(self, cmd, timeout=60, crlf=True): '''wrapper around pexpect spawn''' cmd = self.substitute(cmd) self.info("$ " + cmd) @@ -214,8 +217,9 @@ class wintest(): line = self.substitute(line) return ret.old_expect(line, timeout=timeout) - ret.old_sendline = ret.sendline - ret.sendline = sendline_sub + if crlf: + ret.old_sendline = ret.sendline + ret.sendline = sendline_sub ret.old_expect = ret.expect ret.expect = expect_sub @@ -223,8 +227,11 @@ class wintest(): def get_nameserver(self): '''Get the current nameserver from /etc/resolv.conf''' - child = self.pexpect_spawn('cat /etc/resolv.conf') - child.expect('nameserver') + child = self.pexpect_spawn('cat /etc/resolv.conf', crlf=False) + i = child.expect(['Generated by wintest', 'nameserver']) + if i == 0: + child.expect('your original resolv.conf') + child.expect('nameserver') child.expect('\d+.\d+.\d+.\d+') return child.after |