No need to wait for the password prompt to appear twice.  If a login prompt is
received after a password prompt, it means the password/username was incorrect.

Signed-off-by: Michael Goldish <[email protected]>
---
 client/tests/kvm/kvm_utils.py |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 178a665..d7e205d 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -556,14 +556,17 @@ def _remote_login(session, username, password, prompt, 
timeout=10):
                     raise LoginAuthenticationError("Got password prompt twice",
                                                    text)
             elif match == 2:  # "login:"
-                if login_prompt_count == 0:
+                if login_prompt_count == 0 and password_prompt_count == 0:
                     logging.debug("Got username prompt; sending '%s'" % 
username)
                     session.sendline(username)
                     login_prompt_count += 1
                     continue
                 else:
-                    raise LoginAuthenticationError("Got username prompt twice",
-                                                   text)
+                    if login_prompt_count > 0:
+                        msg = "Got username prompt twice"
+                    else:
+                        msg = "Got username prompt after password prompt"
+                    raise LoginAuthenticationError(msg, text)
             elif match == 3:  # "Connection closed"
                 raise LoginError("Client said 'connection closed'", text)
             elif match == 4:  # "Connection refused"
-- 
1.7.3.4

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to