lib/serial_terminal.pm

add_serial_console

add_serial_console($console);

Adds $console to /etc/securetty (unless already in file), enables systemd service and start it. It requires selecting root console before.

prepare_serial_console

prepare_serial_console();

Wrapper for add_serial_console.

Configure serial consoles for virtio support (root-virtio-terminal and user-virtio-terminal).

NOTE: if test plans to use more consoles via VIRTIO_CONSOLE_NUM, it have to call add_serial_console() with proper console name (beware different number for ppc64le).

get_login_message

get_login_message();

Get login message printed by OS at the end of the boot. Suitable for testing whether boot has been finished:

wait_serial(get_login_message(), 300);

set_serial_prompt

set_serial_prompt($user);

Set serial terminal prompt to given string.

login

login($user);

Enters root's name and password to login. Also sets the prompt to something static without ANSI escape sequences (i.e. a single #) and changes the terminal width.

download_file

download_file($src, $dst [, force => $force][, chunk_size => $cz][, chunk_retry => $cr])

Download a file from worker to SUT using the current serial terminal. The file is split into chunks chunk_size and each chunk is verified with checksum. If a chunk fails, the upload will be retried up to chunk_retry times, before giving up. To overwrite destination use force. This function die on any failure.

upload_file upload_file($src, $dst, [, chunk_size => $cz][, chunk_retry => $cr]);

Upload a file from SUT to the worker using the current serial terminal. The file is parted into chunks chunk_size and each chunk gets is verified with checksum. If a chunk fail we retry it chunk_retry times, before give up. The file is placed in the ulogs/ directory of the worker.

This function die on any failure.

select_serial_terminal

select_serial_terminal($root[, $prompt]);

Select most suitable text console. The optional parameter root controls whether the console will have root privileges or not. Passing any value that evaluates to true will select a root console (default). Passing any value that evaluates to false will select unprivileged user console. The choice is made by BACKEND and other variables.

Purpose of this wrapper is to avoid if/else conditions when selecting console.

Optional root parameter specifies, whether use root user (root=1, also default when parameter not specified) or prefer non-root user if available.

Variables affecting behavior: VIRTIO_CONSOLE=0 disables virtio console (use {root,user}-console instead of the default {root-,user-}virtio-terminal) NOTE: virtio console is enabled by default (VIRTIO_CONSOLE=1). For ppc64le it requires to call prepare_serial_console() to before first use (used in console/system_prepare and shutdown/cleanup_before_shutdown modules) and console=hvc0 in kernel parameters (add it to autoyast profile or update grub setup manually with add_grub_cmdline_settings()).

SERIAL_CONSOLE=0 disables serial console (use {root,user}-console instead of the default {root-,}sut-serial) NOTE: serial console is disabled by default on all but s390x machines (SERIAL_CONSOLE=0), because it's not working yet on other machines (see poo#55985). For s390x it requires console=ttysclp0 in kernel parameters (add it to autoyast profile or update grub setup manually with add_grub_cmdline_settings()).

On ikvm|ipmi|spvm|pvm_hmc it's expected, that use_ssh_serial_console() has been called (done via activate_console()) therefore SERIALDEV has been set and we can use root-ssh console directly.

select_user_serial_terminal

select_user_serial_terminal([$prompt]);

Select most suitable text console with non-root user. The choice is made by BACKEND and other variables.