console: Add a console buffer

It is useful to be able to record console output and provide console input
via a buffer. This provides sandbox with the ability to run a command and
check its output. If the console is set to silent then no visible output
is generated.

This also provides a means to fix the problem where tests produce unwanted
output, such as errors or warnings. This can be confusing. We can instead
set the console to silent and record this output. It can be checked later
in the test if required.

It is possible that this may prove useful for non-test situations. For
example the console output may be suppressed for normal operations, but
recorded and stored for access by the OS. That feature is not implemented
at present.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2015-11-08 23:47:48 -07:00
parent b7b65090b2
commit 9854a8748c
6 changed files with 125 additions and 1 deletions

View File

@ -21,6 +21,7 @@
*/
#ifndef __ASSEMBLY__
#include <membuff.h>
#include <linux/list.h>
typedef struct global_data {
@ -103,6 +104,10 @@ typedef struct global_data {
#endif
struct udevice *cur_serial_dev; /* current serial device */
struct arch_global_data arch; /* architecture-specific data */
#ifdef CONFIG_CONSOLE_RECORD
struct membuff console_out; /* console output */
struct membuff console_in; /* console input */
#endif
} gd_t;
#endif
@ -121,5 +126,6 @@ typedef struct global_data {
#define GD_FLG_FULL_MALLOC_INIT 0x00200 /* Full malloc() is ready */
#define GD_FLG_SPL_INIT 0x00400 /* spl_init() has been called */
#define GD_FLG_SKIP_RELOC 0x00800 /* Don't relocate */
#define GD_FLG_RECORD 0x01000 /* Record console */
#endif /* __ASM_GENERIC_GBL_DATA_H */