The patch looks sane to me. A very good thing that can be done for remote_login() is to tune the tmeouts. I have seen especialy with windows guests or sometimes when the machine is heavily loaded the timeouts elapse and the test fails. When I increased the timeouts the test did not fail. internal_timeout=0.5 is too less in my views and even timeouts of 10 seconds prove insufficient sometimes. Do you too have any such experience? On Sun, May 24, 2009 at 9:16 PM, Michael Goldish <mgoldish@xxxxxxxxxx> wrote: > 1. Make the 'login:' regular expression stricter so it doesn't match > 'Last login: ...' messages. > 2. Make the 'password:' regular expression stricter. > 3. Handle 'Connection refused' messages. > > Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> > --- > client/tests/kvm_runtest_2/kvm_utils.py | 13 +++++++++---- > 1 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/client/tests/kvm_runtest_2/kvm_utils.py b/client/tests/kvm_runtest_2/kvm_utils.py > index be8ad95..5736cf6 100644 > --- a/client/tests/kvm_runtest_2/kvm_utils.py > +++ b/client/tests/kvm_runtest_2/kvm_utils.py > @@ -413,7 +413,8 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10): > > while True: > (match, text) = sub.read_until_last_line_matches( > - ["[Aa]re you sure", "[Pp]assword:", "[Ll]ogin:", "[Cc]onnection.*closed", prompt], > + [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"^\s*[Ll]ogin:\s*$", > + r"[Cc]onnection.*closed", r"[Cc]onnection.*refused", prompt], > timeout=timeout, internal_timeout=0.5) > if match == 0: # "Are you sure you want to continue connecting" > kvm_log.debug("Got 'Are you sure...'; sending 'yes'") > @@ -437,11 +438,15 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10): > kvm_log.debug("Got 'Connection closed'") > sub.close() > return None > - elif match == 4: # prompt > + elif match == 4: # "Connection refused" > + kvm_log.debug("Got 'Connection refused'") > + sub.close() > + return None > + elif match == 5: # prompt > kvm_log.debug("Got shell prompt -- logged in") > return sub > else: # match == None > - kvm_log.debug("Timeout or process terminated") > + kvm_log.debug("Timeout elapsed or process terminated") > sub.close() > return None > > @@ -470,7 +475,7 @@ def remote_scp(command, password, timeout=300, login_timeout=10): > > while True: > (match, text) = sub.read_until_last_line_matches( > - ["[Aa]re you sure", "[Pp]assword:", "lost connection"], > + [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"lost connection"], > timeout=_timeout, internal_timeout=0.5) > if match == 0: # "Are you sure you want to continue connecting" > kvm_log.debug("Got 'Are you sure...'; sending 'yes'") > -- > 1.5.4.1 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- Sudhir Kumar -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html