From 4abc1aecf2fae88810602d8e721ca1734b6a6427 Mon Sep 17 00:00:00 2001 From: Garret Raziel Date: Wed, 15 Jul 2015 07:00:47 +0200 Subject: [PATCH] move logging in as a root into parent class Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D440 --- lib/fedoralog.pm | 19 +++++++++++++++++-- tests/upgrade_postinstall_minimal.pm | 18 +++--------------- tests/upgrade_preinstall_minimal.pm | 21 ++++----------------- tests/upgrade_run_minimal.pm | 10 +--------- 4 files changed, 25 insertions(+), 43 deletions(-) diff --git a/lib/fedoralog.pm b/lib/fedoralog.pm index b586b356..c7cbeb06 100644 --- a/lib/fedoralog.pm +++ b/lib/fedoralog.pm @@ -3,12 +3,14 @@ use base 'basetest'; use testapi; -sub post_fail_hook() { +sub login_as_root { my $self = shift; + my $tty = shift || 1; my $password = get_var("ROOT_PASSWORD", "weakpassword"); - send_key "ctrl-alt-f2"; + send_key "ctrl-alt-f$tty"; assert_screen "text_console_login", 20; + type_string "root"; send_key "ret"; assert_screen "console_password_required", 10; @@ -16,6 +18,19 @@ sub post_fail_hook() { send_key "ret"; assert_screen "root_logged_in", 10; +} + +sub boot_and_login { + my $self = shift; + wait_still_screen 10; + + $self->login_as_root(3); +} + +sub post_fail_hook { + my $self = shift; + + $self->login_as_root(2); # Upload all ABRT logs type_string "cd /var/tmp/abrt && tar czvf abrt.tar.gz *"; diff --git a/tests/upgrade_postinstall_minimal.pm b/tests/upgrade_postinstall_minimal.pm index 1f1b480d..66b4569a 100644 --- a/tests/upgrade_postinstall_minimal.pm +++ b/tests/upgrade_postinstall_minimal.pm @@ -2,23 +2,11 @@ use base "fedoralog"; use strict; use testapi; -sub boot_and_login { - wait_still_screen 10; - - my $password = get_var("ROOT_PASSWORD", "weakpassword"); - - send_key "ctrl-alt-f3"; - assert_screen "text_console_login", 20; - type_string "root"; - send_key "ret"; - assert_screen "console_password_required", 10; - type_string $password; - send_key "ret"; - assert_screen "root_logged_in", 10; -} sub run { - boot_and_login(); + my $self = shift; + + $self->boot_and_login(); assert_screen "console_f22_installed"; } diff --git a/tests/upgrade_preinstall_minimal.pm b/tests/upgrade_preinstall_minimal.pm index d5a961e9..6cae59f7 100644 --- a/tests/upgrade_preinstall_minimal.pm +++ b/tests/upgrade_preinstall_minimal.pm @@ -2,23 +2,10 @@ use base "fedoralog"; use strict; use testapi; -sub boot_and_login { - wait_still_screen 10; - - my $password = get_var("ROOT_PASSWORD", "weakpassword"); - - send_key "ctrl-alt-f3"; - assert_screen "text_console_login", 20; - type_string "root"; - send_key "ret"; - assert_screen "console_password_required", 10; - type_string $password; - send_key "ret"; - assert_screen "root_logged_in", 10; -} - sub run { - boot_and_login(); + my $self = shift; + + $self->boot_and_login(); type_string 'yum -y update; echo $?'; send_key "ret"; @@ -28,7 +15,7 @@ sub run { type_string "reboot"; send_key "ret"; - boot_and_login(); + $self->boot_and_login(); type_string 'yum -y install fedup; echo $?'; send_key "ret"; diff --git a/tests/upgrade_run_minimal.pm b/tests/upgrade_run_minimal.pm index 5913c73d..c59f40de 100644 --- a/tests/upgrade_run_minimal.pm +++ b/tests/upgrade_run_minimal.pm @@ -28,15 +28,7 @@ sub run { assert_screen "grub_fedup", 30; send_key "ret"; - my $counter = 0; - - while (!check_screen ("text_console_login", 10) && $counter < 180) { - if (check_screen "tmp_failed_proc", 1) { - send_key "ctrl-alt-delete"; - } - $counter++; - } - assert_screen "text_console_login", 10; + assert_screen "text_console_login", 6000; }