|
6 | 6 |
|
7 | 7 |
|
8 | 8 | class PexpectHelper: |
9 | | - DEFAULT_PROMPT = "/ #" |
10 | | - |
11 | 9 | default_bug_patterns = [ |
12 | 10 | 'Unable to handle kernel paging request', |
13 | 11 | 'Oops: Kernel access of bad area', |
@@ -103,26 +101,28 @@ def cmd(self, cmd): |
103 | 101 | self.expect_prompt() |
104 | 102 |
|
105 | 103 |
|
106 | | -def standard_boot(p, login=False, user='root', password=None, timeout=-1, prompt=None): |
107 | | - if prompt is None: |
108 | | - prompt = p.DEFAULT_PROMPT |
109 | | - |
110 | | - p.push_prompt(prompt) |
111 | | - |
| 104 | +def standard_boot(p, login=False, user='root', password=None, timeout=-1): |
112 | 105 | logging.info("Waiting for kernel to boot") |
113 | | - p.expect("Freeing unused kernel ", timeout=timeout) |
| 106 | + i = p.expect([p.prompt, "login:", "Freeing unused kernel "], timeout=timeout) |
| 107 | + |
| 108 | + if i == 0: |
| 109 | + # We booted straight to a prompt, we're done |
| 110 | + pass |
| 111 | + elif login: |
| 112 | + if i != 1: |
| 113 | + logging.info("Kernel came up, waiting for login ...") |
| 114 | + p.expect("login:", timeout=timeout) |
114 | 115 |
|
115 | | - if login: |
116 | | - logging.info("Kernel came up, waiting for login ...") |
117 | | - p.expect("login:", timeout=timeout) |
118 | 116 | p.send(user) |
119 | 117 | if password is not None: |
120 | 118 | p.expect("Password:", timeout=timeout) |
121 | 119 | p.send(password) |
| 120 | + |
| 121 | + p.expect_prompt(timeout=timeout) |
122 | 122 | else: |
123 | 123 | logging.info("Kernel came up, waiting for prompt ...") |
| 124 | + p.expect_prompt(timeout=timeout) |
124 | 125 |
|
125 | | - p.expect_prompt(timeout=timeout) |
126 | 126 | logging.info("Booted to shell prompt") |
127 | 127 |
|
128 | 128 |
|
|
0 commit comments