blob: 3938ec1302463a57ff49cf73e92873b29d5419d9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0
Stephen Warren10e50632016-01-15 11:15:24 -07002# Copyright (c) 2015 Stephen Warren
3# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
Stephen Warren10e50632016-01-15 11:15:24 -07004
5# Common logic to interact with U-Boot via the console. This class provides
6# the interface that tests use to execute U-Boot shell commands and wait for
7# their results. Sub-classes exist to perform board-type-specific setup
8# operations, such as spawning a sub-process for Sandbox, or attaching to the
9# serial console of real hardware.
10
11import multiplexed_log
12import os
13import pytest
14import re
15import sys
Stephen Warren97a54662016-01-22 12:30:09 -070016import u_boot_spawn
Stephen Warren10e50632016-01-15 11:15:24 -070017
18# Regexes for text we expect U-Boot to send to the console.
Heiko Schocherce251232018-12-05 11:29:54 +010019pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))')
Yan Liu365a7532020-07-21 11:12:05 -040020pattern_u_boot_spl2_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))')
Stephen Warren5af83c42016-02-05 18:04:43 -070021pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}[^\r\n]*\\))')
Stephen Warren10e50632016-01-15 11:15:24 -070022pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
23pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
24pattern_error_notification = re.compile('## Error: ')
Stephen Warren3bd79d32016-01-27 23:57:50 -070025pattern_error_please_reset = re.compile('### ERROR ### Please RESET the board ###')
Stephen Warren10e50632016-01-15 11:15:24 -070026
Stephen Warren1115a972016-01-27 23:57:48 -070027PAT_ID = 0
28PAT_RE = 1
29
30bad_pattern_defs = (
31 ('spl_signon', pattern_u_boot_spl_signon),
Yan Liu365a7532020-07-21 11:12:05 -040032 ('spl2_signon', pattern_u_boot_spl2_signon),
Stephen Warren1115a972016-01-27 23:57:48 -070033 ('main_signon', pattern_u_boot_main_signon),
34 ('stop_autoboot_prompt', pattern_stop_autoboot_prompt),
35 ('unknown_command', pattern_unknown_command),
36 ('error_notification', pattern_error_notification),
Stephen Warren3bd79d32016-01-27 23:57:50 -070037 ('error_please_reset', pattern_error_please_reset),
Stephen Warren1115a972016-01-27 23:57:48 -070038)
39
Stephen Warren10e50632016-01-15 11:15:24 -070040class ConsoleDisableCheck(object):
Stephen Warren75e731e2016-01-26 13:41:30 -070041 """Context manager (for Python's with statement) that temporarily disables
Stephen Warren10e50632016-01-15 11:15:24 -070042 the specified console output error check. This is useful when deliberately
43 executing a command that is known to trigger one of the error checks, in
44 order to test that the error condition is actually raised. This class is
45 used internally by ConsoleBase::disable_check(); it is not intended for
Stephen Warren75e731e2016-01-26 13:41:30 -070046 direct usage."""
Stephen Warren10e50632016-01-15 11:15:24 -070047
48 def __init__(self, console, check_type):
49 self.console = console
50 self.check_type = check_type
51
52 def __enter__(self):
53 self.console.disable_check_count[self.check_type] += 1
Stephen Warren1115a972016-01-27 23:57:48 -070054 self.console.eval_bad_patterns()
Stephen Warren10e50632016-01-15 11:15:24 -070055
56 def __exit__(self, extype, value, traceback):
57 self.console.disable_check_count[self.check_type] -= 1
Stephen Warren1115a972016-01-27 23:57:48 -070058 self.console.eval_bad_patterns()
Stephen Warren10e50632016-01-15 11:15:24 -070059
Michal Simek6b463182016-05-19 07:57:41 +020060class ConsoleSetupTimeout(object):
61 """Context manager (for Python's with statement) that temporarily sets up
62 timeout for specific command. This is useful when execution time is greater
63 then default 30s."""
64
65 def __init__(self, console, timeout):
66 self.p = console.p
67 self.orig_timeout = self.p.timeout
68 self.p.timeout = timeout
69
70 def __enter__(self):
71 return self
72
73 def __exit__(self, extype, value, traceback):
74 self.p.timeout = self.orig_timeout
75
Stephen Warren10e50632016-01-15 11:15:24 -070076class ConsoleBase(object):
Stephen Warren75e731e2016-01-26 13:41:30 -070077 """The interface through which test functions interact with the U-Boot
Stephen Warren10e50632016-01-15 11:15:24 -070078 console. This primarily involves executing shell commands, capturing their
79 results, and checking for common error conditions. Some common utilities
Stephen Warren75e731e2016-01-26 13:41:30 -070080 are also provided too."""
Stephen Warren10e50632016-01-15 11:15:24 -070081
82 def __init__(self, log, config, max_fifo_fill):
Stephen Warren75e731e2016-01-26 13:41:30 -070083 """Initialize a U-Boot console connection.
Stephen Warren10e50632016-01-15 11:15:24 -070084
85 Can only usefully be called by sub-classes.
86
87 Args:
88 log: A mulptiplex_log.Logfile object, to which the U-Boot output
89 will be logged.
90 config: A configuration data structure, as built by conftest.py.
91 max_fifo_fill: The maximum number of characters to send to U-Boot
92 command-line before waiting for U-Boot to echo the characters
93 back. For UART-based HW without HW flow control, this value
94 should be set less than the UART RX FIFO size to avoid
95 overflow, assuming that U-Boot can't keep up with full-rate
96 traffic at the baud rate.
97
98 Returns:
99 Nothing.
Stephen Warren75e731e2016-01-26 13:41:30 -0700100 """
Stephen Warren10e50632016-01-15 11:15:24 -0700101
102 self.log = log
103 self.config = config
104 self.max_fifo_fill = max_fifo_fill
105
106 self.logstream = self.log.get_stream('console', sys.stdout)
107
108 # Array slice removes leading/trailing quotes
109 self.prompt = self.config.buildconfig['config_sys_prompt'][1:-1]
Stephen Warren6d083402016-08-16 19:58:59 -0600110 self.prompt_compiled = re.compile('^' + re.escape(self.prompt), re.MULTILINE)
Stephen Warren10e50632016-01-15 11:15:24 -0700111 self.p = None
Stephen Warren1115a972016-01-27 23:57:48 -0700112 self.disable_check_count = {pat[PAT_ID]: 0 for pat in bad_pattern_defs}
113 self.eval_bad_patterns()
Stephen Warren10e50632016-01-15 11:15:24 -0700114
115 self.at_prompt = False
116 self.at_prompt_logevt = None
Stephen Warren10e50632016-01-15 11:15:24 -0700117
Stephen Warren1115a972016-01-27 23:57:48 -0700118 def eval_bad_patterns(self):
119 self.bad_patterns = [pat[PAT_RE] for pat in bad_pattern_defs \
120 if self.disable_check_count[pat[PAT_ID]] == 0]
121 self.bad_pattern_ids = [pat[PAT_ID] for pat in bad_pattern_defs \
122 if self.disable_check_count[pat[PAT_ID]] == 0]
123
Stephen Warren10e50632016-01-15 11:15:24 -0700124 def close(self):
Stephen Warren75e731e2016-01-26 13:41:30 -0700125 """Terminate the connection to the U-Boot console.
Stephen Warren10e50632016-01-15 11:15:24 -0700126
127 This function is only useful once all interaction with U-Boot is
128 complete. Once this function is called, data cannot be sent to or
129 received from U-Boot.
130
131 Args:
132 None.
133
134 Returns:
135 Nothing.
Stephen Warren75e731e2016-01-26 13:41:30 -0700136 """
Stephen Warren10e50632016-01-15 11:15:24 -0700137
138 if self.p:
139 self.p.close()
140 self.logstream.close()
141
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900142 def wait_for_boot_prompt(self, loop_num = 1):
Masami Hiramatsu0ff22782022-02-16 15:15:52 +0900143 """Wait for the boot up until command prompt. This is for internal use only.
144 """
145 try:
146 bcfg = self.config.buildconfig
147 config_spl = bcfg.get('config_spl', 'n') == 'y'
148 config_spl_serial = bcfg.get('config_spl_serial', 'n') == 'y'
149 env_spl_skipped = self.config.env.get('env__spl_skipped', False)
150 env_spl2_skipped = self.config.env.get('env__spl2_skipped', True)
151
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900152 while loop_num > 0:
153 loop_num -= 1
154 if config_spl and config_spl_serial and not env_spl_skipped:
155 m = self.p.expect([pattern_u_boot_spl_signon] +
156 self.bad_patterns)
157 if m != 0:
158 raise Exception('Bad pattern found on SPL console: ' +
159 self.bad_pattern_ids[m - 1])
160 if not env_spl2_skipped:
161 m = self.p.expect([pattern_u_boot_spl2_signon] +
162 self.bad_patterns)
163 if m != 0:
164 raise Exception('Bad pattern found on SPL2 console: ' +
165 self.bad_pattern_ids[m - 1])
166 m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns)
Masami Hiramatsu0ff22782022-02-16 15:15:52 +0900167 if m != 0:
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900168 raise Exception('Bad pattern found on console: ' +
Masami Hiramatsu0ff22782022-02-16 15:15:52 +0900169 self.bad_pattern_ids[m - 1])
Masami Hiramatsu0ff22782022-02-16 15:15:52 +0900170 self.u_boot_version_string = self.p.after
171 while True:
172 m = self.p.expect([self.prompt_compiled,
173 pattern_stop_autoboot_prompt] + self.bad_patterns)
174 if m == 0:
175 break
176 if m == 1:
177 self.p.send(' ')
178 continue
179 raise Exception('Bad pattern found on console: ' +
180 self.bad_pattern_ids[m - 2])
181
182 except Exception as ex:
183 self.log.error(str(ex))
184 self.cleanup_spawn()
185 raise
186 finally:
187 self.log.timestamp()
188
Stephen Warren10e50632016-01-15 11:15:24 -0700189 def run_command(self, cmd, wait_for_echo=True, send_nl=True,
Masami Hiramatsu0ff22782022-02-16 15:15:52 +0900190 wait_for_prompt=True, wait_for_reboot=False):
Stephen Warren75e731e2016-01-26 13:41:30 -0700191 """Execute a command via the U-Boot console.
Stephen Warren10e50632016-01-15 11:15:24 -0700192
193 The command is always sent to U-Boot.
194
195 U-Boot echoes any command back to its output, and this function
196 typically waits for that to occur. The wait can be disabled by setting
197 wait_for_echo=False, which is useful e.g. when sending CTRL-C to
198 interrupt a long-running command such as "ums".
199
200 Command execution is typically triggered by sending a newline
201 character. This can be disabled by setting send_nl=False, which is
202 also useful when sending CTRL-C.
203
204 This function typically waits for the command to finish executing, and
205 returns the console output that it generated. This can be disabled by
206 setting wait_for_prompt=False, which is useful when invoking a long-
207 running command such as "ums".
208
209 Args:
210 cmd: The command to send.
Heinrich Schuchardtbec160a2017-09-14 12:27:07 +0200211 wait_for_echo: Boolean indicating whether to wait for U-Boot to
Stephen Warren10e50632016-01-15 11:15:24 -0700212 echo the command text back to its output.
213 send_nl: Boolean indicating whether to send a newline character
214 after the command string.
215 wait_for_prompt: Boolean indicating whether to wait for the
216 command prompt to be sent by U-Boot. This typically occurs
217 immediately after the command has been executed.
Masami Hiramatsu0ff22782022-02-16 15:15:52 +0900218 wait_for_reboot: Boolean indication whether to wait for the
219 reboot U-Boot. If this sets True, wait_for_prompt must also
220 be True.
Stephen Warren10e50632016-01-15 11:15:24 -0700221
222 Returns:
223 If wait_for_prompt == False:
224 Nothing.
225 Else:
226 The output from U-Boot during command execution. In other
227 words, the text U-Boot emitted between the point it echod the
228 command string and emitted the subsequent command prompts.
Stephen Warren75e731e2016-01-26 13:41:30 -0700229 """
Stephen Warren10e50632016-01-15 11:15:24 -0700230
Stephen Warren10e50632016-01-15 11:15:24 -0700231 if self.at_prompt and \
232 self.at_prompt_logevt != self.logstream.logfile.cur_evt:
233 self.logstream.write(self.prompt, implicit=True)
234
Stephen Warren10e50632016-01-15 11:15:24 -0700235 try:
236 self.at_prompt = False
237 if send_nl:
238 cmd += '\n'
239 while cmd:
240 # Limit max outstanding data, so UART FIFOs don't overflow
241 chunk = cmd[:self.max_fifo_fill]
242 cmd = cmd[self.max_fifo_fill:]
243 self.p.send(chunk)
244 if not wait_for_echo:
245 continue
246 chunk = re.escape(chunk)
247 chunk = chunk.replace('\\\n', '[\r\n]')
Stephen Warren1115a972016-01-27 23:57:48 -0700248 m = self.p.expect([chunk] + self.bad_patterns)
Stephen Warren10e50632016-01-15 11:15:24 -0700249 if m != 0:
250 self.at_prompt = False
251 raise Exception('Bad pattern found on console: ' +
Stephen Warren1115a972016-01-27 23:57:48 -0700252 self.bad_pattern_ids[m - 1])
Stephen Warren10e50632016-01-15 11:15:24 -0700253 if not wait_for_prompt:
254 return
Masami Hiramatsu0ff22782022-02-16 15:15:52 +0900255 if wait_for_reboot:
256 self.wait_for_boot_prompt()
257 else:
258 m = self.p.expect([self.prompt_compiled] + self.bad_patterns)
259 if m != 0:
260 self.at_prompt = False
261 raise Exception('Bad pattern found on console: ' +
262 self.bad_pattern_ids[m - 1])
Stephen Warren10e50632016-01-15 11:15:24 -0700263 self.at_prompt = True
264 self.at_prompt_logevt = self.logstream.logfile.cur_evt
265 # Only strip \r\n; space/TAB might be significant if testing
266 # indentation.
267 return self.p.before.strip('\r\n')
268 except Exception as ex:
269 self.log.error(str(ex))
270 self.cleanup_spawn()
271 raise
Stephen Warrenb1c556a2017-10-27 11:04:08 -0600272 finally:
273 self.log.timestamp()
Stephen Warren10e50632016-01-15 11:15:24 -0700274
Simon Glass2436bb02016-07-03 09:40:42 -0600275 def run_command_list(self, cmds):
276 """Run a list of commands.
277
278 This is a helper function to call run_command() with default arguments
279 for each command in a list.
280
281 Args:
Simon Glassd5deca02016-07-31 17:35:04 -0600282 cmd: List of commands (each a string).
Simon Glass2436bb02016-07-03 09:40:42 -0600283 Returns:
Simon Glass2ca73112016-07-31 17:35:09 -0600284 A list of output strings from each command, one element for each
285 command.
Simon Glass2436bb02016-07-03 09:40:42 -0600286 """
Simon Glass2ca73112016-07-31 17:35:09 -0600287 output = []
Simon Glass2436bb02016-07-03 09:40:42 -0600288 for cmd in cmds:
Simon Glass2ca73112016-07-31 17:35:09 -0600289 output.append(self.run_command(cmd))
Simon Glass2436bb02016-07-03 09:40:42 -0600290 return output
291
Stephen Warren10e50632016-01-15 11:15:24 -0700292 def ctrlc(self):
Stephen Warren75e731e2016-01-26 13:41:30 -0700293 """Send a CTRL-C character to U-Boot.
Stephen Warren10e50632016-01-15 11:15:24 -0700294
295 This is useful in order to stop execution of long-running synchronous
296 commands such as "ums".
297
298 Args:
299 None.
300
301 Returns:
302 Nothing.
Stephen Warren75e731e2016-01-26 13:41:30 -0700303 """
Stephen Warren10e50632016-01-15 11:15:24 -0700304
Stephen Warrena88c4172016-01-22 12:30:10 -0700305 self.log.action('Sending Ctrl-C')
Stephen Warren10e50632016-01-15 11:15:24 -0700306 self.run_command(chr(3), wait_for_echo=False, send_nl=False)
307
Stephen Warrenef824f52016-01-22 12:30:12 -0700308 def wait_for(self, text):
Stephen Warren75e731e2016-01-26 13:41:30 -0700309 """Wait for a pattern to be emitted by U-Boot.
Stephen Warrenef824f52016-01-22 12:30:12 -0700310
311 This is useful when a long-running command such as "dfu" is executing,
312 and it periodically emits some text that should show up at a specific
313 location in the log file.
314
315 Args:
316 text: The text to wait for; either a string (containing raw text,
317 not a regular expression) or an re object.
318
319 Returns:
320 Nothing.
Stephen Warren75e731e2016-01-26 13:41:30 -0700321 """
Stephen Warrenef824f52016-01-22 12:30:12 -0700322
323 if type(text) == type(''):
324 text = re.escape(text)
Stephen Warren68a9bb62016-01-27 23:57:49 -0700325 m = self.p.expect([text] + self.bad_patterns)
326 if m != 0:
327 raise Exception('Bad pattern found on console: ' +
328 self.bad_pattern_ids[m - 1])
Stephen Warrenef824f52016-01-22 12:30:12 -0700329
Stephen Warren97a54662016-01-22 12:30:09 -0700330 def drain_console(self):
Stephen Warren75e731e2016-01-26 13:41:30 -0700331 """Read from and log the U-Boot console for a short time.
Stephen Warren97a54662016-01-22 12:30:09 -0700332
333 U-Boot's console output is only logged when the test code actively
334 waits for U-Boot to emit specific data. There are cases where tests
335 can fail without doing this. For example, if a test asks U-Boot to
336 enable USB device mode, then polls until a host-side device node
337 exists. In such a case, it is useful to log U-Boot's console output
338 in case U-Boot printed clues as to why the host-side even did not
339 occur. This function will do that.
340
341 Args:
342 None.
343
344 Returns:
345 Nothing.
Stephen Warren75e731e2016-01-26 13:41:30 -0700346 """
Stephen Warren97a54662016-01-22 12:30:09 -0700347
348 # If we are already not connected to U-Boot, there's nothing to drain.
349 # This should only happen when a previous call to run_command() or
350 # wait_for() failed (and hence the output has already been logged), or
351 # the system is shutting down.
352 if not self.p:
353 return
354
355 orig_timeout = self.p.timeout
356 try:
357 # Drain the log for a relatively short time.
358 self.p.timeout = 1000
359 # Wait for something U-Boot will likely never send. This will
360 # cause the console output to be read and logged.
361 self.p.expect(['This should never match U-Boot output'])
Stephen Warren677b9cc2018-09-20 16:55:03 -0600362 except:
363 # We expect a timeout, since U-Boot won't print what we waited
364 # for. Squash it when it happens.
365 #
366 # Squash any other exception too. This function is only used to
367 # drain (and log) the U-Boot console output after a failed test.
368 # The U-Boot process will be restarted, or target board reset, once
369 # this function returns. So, we don't care about detecting any
370 # additional errors, so they're squashed so that the rest of the
371 # post-test-failure cleanup code can continue operation, and
372 # correctly terminate any log sections, etc.
Stephen Warren97a54662016-01-22 12:30:09 -0700373 pass
374 finally:
375 self.p.timeout = orig_timeout
376
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900377 def ensure_spawned(self, expect_reset=False):
Stephen Warren75e731e2016-01-26 13:41:30 -0700378 """Ensure a connection to a correctly running U-Boot instance.
Stephen Warren10e50632016-01-15 11:15:24 -0700379
380 This may require spawning a new Sandbox process or resetting target
381 hardware, as defined by the implementation sub-class.
382
383 This is an internal function and should not be called directly.
384
385 Args:
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900386 expect_reset: Boolean indication whether this boot is expected
387 to be reset while the 1st boot process after main boot before
388 prompt. False by default.
Stephen Warren10e50632016-01-15 11:15:24 -0700389
390 Returns:
391 Nothing.
Stephen Warren75e731e2016-01-26 13:41:30 -0700392 """
Stephen Warren10e50632016-01-15 11:15:24 -0700393
394 if self.p:
395 return
396 try:
Stephen Warren80eea632016-02-11 11:46:12 -0700397 self.log.start_section('Starting U-Boot')
Stephen Warren10e50632016-01-15 11:15:24 -0700398 self.at_prompt = False
Stephen Warren10e50632016-01-15 11:15:24 -0700399 self.p = self.get_spawn()
400 # Real targets can take a long time to scroll large amounts of
401 # text if LCD is enabled. This value may need tweaking in the
402 # future, possibly per-test to be optimal. This works for 'help'
403 # on board 'seaboard'.
Stephen Warren33db1ee2016-02-04 16:11:50 -0700404 if not self.config.gdbserver:
405 self.p.timeout = 30000
Stephen Warren10e50632016-01-15 11:15:24 -0700406 self.p.logfile_read = self.logstream
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900407 if expect_reset:
408 loop_num = 2
409 else:
410 loop_num = 1
411 self.wait_for_boot_prompt(loop_num = loop_num)
Stephen Warren10e50632016-01-15 11:15:24 -0700412 self.at_prompt = True
413 self.at_prompt_logevt = self.logstream.logfile.cur_evt
414 except Exception as ex:
415 self.log.error(str(ex))
416 self.cleanup_spawn()
417 raise
Stephen Warren80eea632016-02-11 11:46:12 -0700418 finally:
Stephen Warrenb1c556a2017-10-27 11:04:08 -0600419 self.log.timestamp()
Stephen Warren80eea632016-02-11 11:46:12 -0700420 self.log.end_section('Starting U-Boot')
Stephen Warren10e50632016-01-15 11:15:24 -0700421
422 def cleanup_spawn(self):
Stephen Warren75e731e2016-01-26 13:41:30 -0700423 """Shut down all interaction with the U-Boot instance.
Stephen Warren10e50632016-01-15 11:15:24 -0700424
425 This is used when an error is detected prior to re-establishing a
426 connection with a fresh U-Boot instance.
427
428 This is an internal function and should not be called directly.
429
430 Args:
431 None.
432
433 Returns:
434 Nothing.
Stephen Warren75e731e2016-01-26 13:41:30 -0700435 """
Stephen Warren10e50632016-01-15 11:15:24 -0700436
437 try:
438 if self.p:
439 self.p.close()
440 except:
441 pass
442 self.p = None
443
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900444 def restart_uboot(self, expect_reset=False):
Simon Glass37c2ce12016-07-31 17:35:08 -0600445 """Shut down and restart U-Boot."""
446 self.cleanup_spawn()
Masami Hiramatsu4d3b9962022-02-16 15:16:02 +0900447 self.ensure_spawned(expect_reset)
Simon Glass37c2ce12016-07-31 17:35:08 -0600448
Simon Glass9bc20832016-07-04 11:58:39 -0600449 def get_spawn_output(self):
450 """Return the start-up output from U-Boot
451
452 Returns:
453 The output produced by ensure_spawed(), as a string.
454 """
455 if self.p:
456 return self.p.get_expect_output()
457 return None
458
Stephen Warren10e50632016-01-15 11:15:24 -0700459 def validate_version_string_in_text(self, text):
Stephen Warren75e731e2016-01-26 13:41:30 -0700460 """Assert that a command's output includes the U-Boot signon message.
Stephen Warren10e50632016-01-15 11:15:24 -0700461
462 This is primarily useful for validating the "version" command without
463 duplicating the signon text regex in a test function.
464
465 Args:
466 text: The command output text to check.
467
468 Returns:
469 Nothing. An exception is raised if the validation fails.
Stephen Warren75e731e2016-01-26 13:41:30 -0700470 """
Stephen Warren10e50632016-01-15 11:15:24 -0700471
472 assert(self.u_boot_version_string in text)
473
474 def disable_check(self, check_type):
Stephen Warren75e731e2016-01-26 13:41:30 -0700475 """Temporarily disable an error check of U-Boot's output.
Stephen Warren10e50632016-01-15 11:15:24 -0700476
477 Create a new context manager (for use with the "with" statement) which
478 temporarily disables a particular console output error check.
479
480 Args:
481 check_type: The type of error-check to disable. Valid values may
482 be found in self.disable_check_count above.
483
484 Returns:
485 A context manager object.
Stephen Warren75e731e2016-01-26 13:41:30 -0700486 """
Stephen Warren10e50632016-01-15 11:15:24 -0700487
488 return ConsoleDisableCheck(self, check_type)
Michal Simek6b463182016-05-19 07:57:41 +0200489
490 def temporary_timeout(self, timeout):
491 """Temporarily set up different timeout for commands.
492
493 Create a new context manager (for use with the "with" statement) which
494 temporarily change timeout.
495
496 Args:
497 timeout: Time in milliseconds.
498
499 Returns:
500 A context manager object.
501 """
502
503 return ConsoleSetupTimeout(self, timeout)