2016-09-07 08:34:54 +00:00
|
|
|
use base "anacondatest";
|
|
|
|
use strict;
|
|
|
|
use testapi;
|
2017-01-18 07:15:44 +00:00
|
|
|
use utils;
|
2016-09-07 08:34:54 +00:00
|
|
|
|
2019-11-06 12:55:27 +00:00
|
|
|
|
|
|
|
# this enables you to send a command and some post-command wait time
|
|
|
|
# in one step and also distinguishes between serial console and normal
|
|
|
|
# VNC based console and handles the wait times differently.
|
|
|
|
sub console_type_wait {
|
|
|
|
my ($string, $wait) = @_;
|
|
|
|
$wait ||= 5;
|
|
|
|
type_string $string;
|
|
|
|
if (testapi::is_serial_terminal) {
|
|
|
|
sleep $wait;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
wait_still_screen $wait;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 08:34:54 +00:00
|
|
|
sub run {
|
|
|
|
my $self = shift;
|
2019-11-06 12:55:27 +00:00
|
|
|
|
|
|
|
# First, preset the environment according to the chosen console. This test
|
|
|
|
# can run both on a VNC based console, or a serial console.
|
|
|
|
if (get_var("SERIAL_CONSOLE")) {
|
2019-11-20 16:39:28 +00:00
|
|
|
select_console('virtio-console1');
|
2019-11-06 12:55:27 +00:00
|
|
|
unless (testapi::is_serial_terminal) {
|
|
|
|
die "The test does not run on a serial console when it should.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert_screen "anaconda_main_hub_text";
|
|
|
|
# IMHO it's better to use sleeps than to have needle for every text screen
|
|
|
|
wait_still_screen 5;
|
|
|
|
}
|
2016-09-07 08:34:54 +00:00
|
|
|
|
|
|
|
# prepare for different number of spokes (e. g. as in Atomic DVD)
|
|
|
|
my %spoke_number = (
|
|
|
|
"language" => 1,
|
|
|
|
"timezone" => 2,
|
|
|
|
"source" => 3,
|
|
|
|
"swselection" => 4,
|
|
|
|
"destination" => 5,
|
|
|
|
"network" => 6,
|
|
|
|
"rootpwd" => 7,
|
|
|
|
"user" => 8
|
|
|
|
);
|
|
|
|
|
2019-11-06 12:55:27 +00:00
|
|
|
# The error message that we are going to check for in the text installation
|
|
|
|
# must be different for serial console and a VNC terminal emulator.
|
|
|
|
my $error = "";
|
|
|
|
if (testapi::is_serial_terminal) {
|
|
|
|
$error = "unknown error has occured";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$error = "anaconda_text_error";
|
|
|
|
}
|
|
|
|
|
2016-09-07 08:34:54 +00:00
|
|
|
# Set timezone
|
2019-11-06 12:55:27 +00:00
|
|
|
run_with_error_check(sub {console_type_wait($spoke_number{"timezone"} . "\n")}, $error);
|
|
|
|
console_type_wait("1\n"); # Set timezone
|
|
|
|
console_type_wait("1\n"); # Europe
|
|
|
|
console_type_wait("37\n", 7); # Prague
|
2016-09-07 08:34:54 +00:00
|
|
|
|
|
|
|
# Select disk
|
2019-11-06 12:55:27 +00:00
|
|
|
run_with_error_check(sub {console_type_wait($spoke_number{"destination"} . "\n")}, $error);
|
|
|
|
console_type_wait("c\n"); # first disk selected, continue
|
|
|
|
console_type_wait("c\n"); # use all space selected, continue
|
|
|
|
console_type_wait("c\n", 7); # LVM selected, continue
|
2016-09-07 08:34:54 +00:00
|
|
|
|
|
|
|
# Set root password
|
2019-11-06 12:55:27 +00:00
|
|
|
my $rootpwd = get_var("ROOT_PASSWORD", "weakpassword");
|
|
|
|
run_with_error_check(sub {console_type_wait($spoke_number{"rootpwd"} . "\n")}, $error);
|
|
|
|
console_type_wait("$rootpwd\n");
|
|
|
|
console_type_wait("$rootpwd\n");
|
2016-09-07 08:34:54 +00:00
|
|
|
|
|
|
|
# Create user
|
2019-11-06 12:55:27 +00:00
|
|
|
my $userpwd = get_var("USER_PASSWORD", "weakpassword");
|
|
|
|
my $username = get_var("USER_LOGIN", "test");
|
|
|
|
run_with_error_check(sub {console_type_wait($spoke_number{"user"} . "\n")}, $error);
|
|
|
|
console_type_wait("1\n"); # create new
|
|
|
|
console_type_wait("3\n"); # set username
|
|
|
|
console_type_wait("$username\n");
|
2019-05-22 22:18:08 +00:00
|
|
|
# from Rawhide-20190503.n.0 (F31) onwards, 'use password' is default
|
2019-05-22 22:27:59 +00:00
|
|
|
if (get_release_number() < 31) {
|
2019-05-22 22:18:08 +00:00
|
|
|
# typing "4\n" on abrt screen causes system to reboot, so be careful
|
2019-11-06 12:55:27 +00:00
|
|
|
run_with_error_check(sub {console_type_wait("4\n")}, $error); # use password
|
2019-05-22 22:18:08 +00:00
|
|
|
}
|
2019-11-06 12:55:27 +00:00
|
|
|
console_type_wait("5\n"); # set password
|
|
|
|
console_type_wait("$userpwd\n");
|
|
|
|
console_type_wait("$userpwd\n");
|
|
|
|
console_type_wait("6\n"); # make him an administrator
|
|
|
|
console_type_wait("c\n", 7);
|
2016-09-07 08:34:54 +00:00
|
|
|
|
|
|
|
my $counter = 0;
|
2019-11-06 12:55:27 +00:00
|
|
|
if (testapi::is_serial_terminal) {
|
|
|
|
while (wait_serial("[!]", timeout=>5, quiet=>1)) {
|
|
|
|
if ($counter > 10) {
|
|
|
|
die "There are unfinished spokes in Anaconda";
|
|
|
|
}
|
|
|
|
sleep 10;
|
|
|
|
$counter++;
|
|
|
|
console_type_wait("r\n"); # refresh
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (check_screen "anaconda_main_hub_text_unfinished", 2) {
|
|
|
|
if ($counter > 10) {
|
|
|
|
die "There are unfinished spokes in Anaconda";
|
|
|
|
}
|
|
|
|
sleep 10;
|
|
|
|
$counter++;
|
|
|
|
console_type_wait("r\n"); # refresh
|
2016-09-07 08:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# begin installation
|
2019-11-06 12:55:27 +00:00
|
|
|
console_type_wait("b\n");
|
2016-09-07 08:34:54 +00:00
|
|
|
|
|
|
|
# Wait for install to end. Give Rawhide a bit longer, in case
|
|
|
|
# we're on a debug kernel, debug kernel installs are really slow.
|
|
|
|
my $timeout = 1800;
|
|
|
|
if (lc(get_var('VERSION')) eq "rawhide") {
|
|
|
|
$timeout = 2400;
|
|
|
|
}
|
2019-11-06 12:55:27 +00:00
|
|
|
|
|
|
|
if (testapi::is_serial_terminal) {
|
|
|
|
wait_serial("Installation complete", timeout=>$timeout);
|
|
|
|
if (get_var("SERIAL_CONSOLE") && get_var("OFW")) {
|
2019-11-20 17:04:31 +00:00
|
|
|
# for some reason the check for a prompt times out here, even
|
|
|
|
# though '# ' is clearly in the terminal log; hack it out
|
|
|
|
my $origprompt = $testapi::distri->{serial_term_prompt};
|
|
|
|
$testapi::distri->{serial_term_prompt} = '';
|
2019-11-06 12:55:27 +00:00
|
|
|
$self->root_console();
|
|
|
|
# we need to force the system to load a console on both hvc1
|
|
|
|
# and hvc2 for ppc64 serial console post-install tests
|
|
|
|
assert_script_run 'chroot /mnt/sysimage systemctl enable serial-getty@hvc1';
|
|
|
|
assert_script_run 'chroot /mnt/sysimage systemctl enable serial-getty@hvc2';
|
2019-11-20 17:04:31 +00:00
|
|
|
$testapi::distri->{serial_term_prompt} = $origprompt;
|
2019-11-06 12:55:27 +00:00
|
|
|
# back to anaconda ui
|
2019-11-20 16:39:28 +00:00
|
|
|
select_console("virtio-console1");
|
2019-11-06 12:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert_screen "anaconda_install_text_done", $timeout;
|
|
|
|
}
|
|
|
|
console_type_wait("\n");
|
2016-09-07 08:34:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub test_flags {
|
|
|
|
return { fatal => 1 };
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
# vim: set sw=4 et:
|