diff --git a/lib/anacondatest.pm b/lib/anacondatest.pm index 5b0d8989..4bc40a79 100644 --- a/lib/anacondatest.pm +++ b/lib/anacondatest.pm @@ -11,10 +11,9 @@ use testapi; sub post_fail_hook { my $self = shift; - # if error dialog is shown, click "report" - it then creates directory structure for ABRT + # if error dialog is shown, it created traceback file my $has_traceback = 0; if (check_screen "anaconda_error", 10) { - assert_and_click "anaconda_report_btn"; # Generage Anaconda ABRT logs $has_traceback = 1; } @@ -30,17 +29,19 @@ sub post_fail_hook { upload_logs "/tmp/dnf.librepo.log"; upload_logs "/tmp/dnf.rpm.log"; - # Upload all ABRT logs if ($has_traceback) { - type_string "cd /var/tmp && tar czvf var_tmp.tar.gz *"; - send_key "ret"; - upload_logs "/var/tmp/var_tmp.tar.gz"; + # Upload Anaconda traceback logs + script_run "tar czf /tmp/anaconda_tb.tar.gz /tmp/anaconda-tb-*"; + upload_logs "/tmp/anaconda_tb.tar.gz"; } - # Upload Anaconda traceback logs - type_string "tar czvf /tmp/anaconda_tb.tar.gz /tmp/anaconda-tb-*"; - send_key "ret"; - upload_logs "/tmp/anaconda_tb.tar.gz"; + # Upload all ABRT logs + script_run "tar czf var_tmp.tar.gz /var/tmp"; + upload_logs "/var/tmp/var_tmp.tar.gz"; + + # Upload /var/log + script_run "tar czf /tmp/var_log.tar.gz /var/log"; + upload_logs "/tmp/var_log.tar.gz"; } else { save_screenshot; diff --git a/lib/fedorabase.pm b/lib/fedorabase.pm index be900ff4..422ed9e2 100644 --- a/lib/fedorabase.pm +++ b/lib/fedorabase.pm @@ -46,7 +46,7 @@ sub console_login { return; } elsif (check_screen $bad, 0) { - type_string "exit\n"; + script_run "exit"; sleep 2; } if ($needuser and check_screen "text_console_login", 0) { diff --git a/lib/fedoradistribution.pm b/lib/fedoradistribution.pm index 5189a021..2a709f90 100644 --- a/lib/fedoradistribution.pm +++ b/lib/fedoradistribution.pm @@ -33,5 +33,12 @@ sub x11_start_program($$$) { send_key "ret", 1; } +sub script_run { + my ($self, $program, $timeout) = @_; + + type_string $program; + send_key "ret", $timeout; +} + 1; # vim: set sw=4 et: diff --git a/lib/installedtest.pm b/lib/installedtest.pm index 0740e637..1ecaabc5 100644 --- a/lib/installedtest.pm +++ b/lib/installedtest.pm @@ -24,24 +24,23 @@ sub post_fail_hook { $self->root_console(tty=>2); - # Upload all ABRT logs - type_string "cd /var/tmp/abrt && tar czvf abrt.tar.gz *"; - send_key "ret"; - upload_logs "/var/tmp/abrt/abrt.tar.gz"; + # If /var/tmp/abrt directory isn't empty (ls doesn't return empty string) + if (validate_script_output "ls /var/tmp/abrt", sub { $_ ne '' }) { + # Upload all ABRT logs + script_run "cd /var/tmp/abrt && tar czvf abrt.tar.gz *"; + upload_logs "/var/tmp/abrt/abrt.tar.gz"; + } # Upload /var/log - type_string "tar czvf /tmp/var_log.tar.gz /var/log"; - send_key "ret"; + script_run "tar czvf /tmp/var_log.tar.gz /var/log"; upload_logs "/tmp/var_log.tar.gz"; } sub check_release { my $self = shift; my $release = shift; - type_string "clear\n"; - type_string "grep SUPPORT_PRODUCT_VERSION /usr/lib/os.release.d/os-release-fedora | grep -q ${release}\n"; - type_string "echo \$?\n"; - assert_screen "console_command_success"; + my $check_command = "grep SUPPORT_PRODUCT_VERSION /usr/lib/os.release.d/os-release-fedora"; + validate_script_output $check_command, sub { $_ =~ m/REDHAT_SUPPORT_PRODUCT_VERSION=$release/ }; } 1; diff --git a/needles/anaconda_error.json b/needles/anaconda_error.json index d16528fa..35c23d63 100644 --- a/needles/anaconda_error.json +++ b/needles/anaconda_error.json @@ -6,13 +6,6 @@ "width": 217, "height": 19, "type": "match" - }, - { - "xpos": 577, - "ypos": 430, - "width": 89, - "height": 20, - "type": "match" } ], "tags": [ diff --git a/needles/anaconda_install_source_check_repo_added.json b/needles/anaconda_install_source_check_repo_added.json deleted file mode 100644 index d3e35d06..00000000 --- a/needles/anaconda_install_source_check_repo_added.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tags": [ - "anaconda_install_source_check_repo_added", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ], - "area": [ - { - "ypos": 17, - "height": 14, - "xpos": 102, - "type": "match", - "width": 304 - } - ] -} diff --git a/needles/anaconda_install_source_check_repo_added.png b/needles/anaconda_install_source_check_repo_added.png deleted file mode 100644 index eee57ab8..00000000 Binary files a/needles/anaconda_install_source_check_repo_added.png and /dev/null differ diff --git a/needles/anaconda_install_source_check_repo_added_eurlatgr.json b/needles/anaconda_install_source_check_repo_added_eurlatgr.json deleted file mode 100644 index d3e35d06..00000000 --- a/needles/anaconda_install_source_check_repo_added_eurlatgr.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tags": [ - "anaconda_install_source_check_repo_added", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ], - "area": [ - { - "ypos": 17, - "height": 14, - "xpos": 102, - "type": "match", - "width": 304 - } - ] -} diff --git a/needles/anaconda_install_source_check_repo_added_eurlatgr.png b/needles/anaconda_install_source_check_repo_added_eurlatgr.png deleted file mode 100644 index 85866175..00000000 Binary files a/needles/anaconda_install_source_check_repo_added_eurlatgr.png and /dev/null differ diff --git a/needles/anaconda_install_source_check_repo_added_inst_repo.json b/needles/anaconda_install_source_check_repo_added_inst_repo.json deleted file mode 100644 index a2dd8e99..00000000 --- a/needles/anaconda_install_source_check_repo_added_inst_repo.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "area": [ - { - "xpos": 229, - "ypos": 17, - "width": 327, - "height": 15, - "type": "match" - } - ], - "tags": [ - "anaconda_install_source_check_repo_added", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ] -} diff --git a/needles/anaconda_install_source_check_repo_added_inst_repo.png b/needles/anaconda_install_source_check_repo_added_inst_repo.png deleted file mode 100644 index b090add8..00000000 Binary files a/needles/anaconda_install_source_check_repo_added_inst_repo.png and /dev/null differ diff --git a/needles/anaconda_report_btn.json b/needles/anaconda_report_btn.json deleted file mode 100644 index 1f219570..00000000 --- a/needles/anaconda_report_btn.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "area": [ - { - "xpos": 577, - "ypos": 430, - "width": 89, - "height": 20, - "type": "match" - } - ], - "tags": [ - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server", - "anaconda_report_btn" - ], - "properties": [] -} diff --git a/needles/anaconda_report_btn.png b/needles/anaconda_report_btn.png deleted file mode 100644 index 14c81f5c..00000000 Binary files a/needles/anaconda_report_btn.png and /dev/null differ diff --git a/needles/console_command_success.json b/needles/console_command_success.json deleted file mode 100644 index 2b3ec03a..00000000 --- a/needles/console_command_success.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "tags": [ - "console_command_success", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ], - "area": [ - { - "width": 1018, - "height": 13, - "xpos": 0, - "ypos": 0, - "type": "match" - } - ], - "properties": [] -} diff --git a/needles/console_command_success.png b/needles/console_command_success.png deleted file mode 100644 index 4ffa51a8..00000000 Binary files a/needles/console_command_success.png and /dev/null differ diff --git a/needles/console_command_success2.json b/needles/console_command_success2.json deleted file mode 100644 index 8eba1d87..00000000 --- a/needles/console_command_success2.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "tags": [ - "console_command_success", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ], - "area": [ - { - "type": "match", - "width": 1012, - "height": 13, - "xpos": 0, - "ypos": 16 - } - ], - "properties": [] -} diff --git a/needles/console_command_success2.png b/needles/console_command_success2.png deleted file mode 100644 index 59089501..00000000 Binary files a/needles/console_command_success2.png and /dev/null differ diff --git a/needles/console_raid_used.json b/needles/console_raid_used.json deleted file mode 100644 index 035fdb8b..00000000 --- a/needles/console_raid_used.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "properties": [], - "area": [ - { - "xpos": 0, - "ypos": 0, - "width": 182, - "height": 15, - "type": "match" - } - ], - "tags": [ - "console_raid_used", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ] -} diff --git a/needles/console_raid_used.png b/needles/console_raid_used.png deleted file mode 100644 index 7c9e97b4..00000000 Binary files a/needles/console_raid_used.png and /dev/null differ diff --git a/needles/console_two_disks_mounted_lvm.json b/needles/console_two_disks_mounted_lvm.json deleted file mode 100644 index d6346bfb..00000000 --- a/needles/console_two_disks_mounted_lvm.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "area": [ - { - "xpos": 191, - "ypos": 15, - "width": 64, - "height": 18, - "type": "match" - }, - { - "xpos": 189, - "ypos": 193, - "width": 67, - "height": 13, - "type": "match" - } - ], - "tags": [ - "console_two_disks_mounted_lvm", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ], - "properties": [] -} diff --git a/needles/console_two_disks_mounted_lvm.png b/needles/console_two_disks_mounted_lvm.png deleted file mode 100644 index 8af5ec66..00000000 Binary files a/needles/console_two_disks_mounted_lvm.png and /dev/null differ diff --git a/needles/provided_disk_intact.json b/needles/provided_disk_intact.json deleted file mode 100644 index 88319d01..00000000 --- a/needles/provided_disk_intact.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tags": [ - "provided_disk_intact", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ], - "area": [ - { - "xpos": 0, - "ypos": 0, - "width": 104, - "height": 155, - "type": "match" - } - ] -} diff --git a/needles/provided_disk_intact.png b/needles/provided_disk_intact.png deleted file mode 100644 index 0b76aa94..00000000 Binary files a/needles/provided_disk_intact.png and /dev/null differ diff --git a/needles/provided_second_partition_intact.json b/needles/provided_second_partition_intact.json deleted file mode 100644 index cc4fd8ac..00000000 --- a/needles/provided_second_partition_intact.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tags": [ - "provided_second_partition_intact", - "ENV-DISTRI-fedora", - "ENV-FLAVOR-server" - ], - "area": [ - { - "xpos": 0, - "ypos": 0, - "width": 88, - "height": 95, - "type": "match" - } - ] -} diff --git a/needles/provided_second_partition_intact.png b/needles/provided_second_partition_intact.png deleted file mode 100644 index a52e9df1..00000000 Binary files a/needles/provided_second_partition_intact.png and /dev/null differ diff --git a/tests/disk_custom_software_raid_postinstall.pm b/tests/disk_custom_software_raid_postinstall.pm index 69db1aaa..314f200e 100644 --- a/tests/disk_custom_software_raid_postinstall.pm +++ b/tests/disk_custom_software_raid_postinstall.pm @@ -5,9 +5,7 @@ use testapi; sub run { assert_screen "root_console"; # check that RAID is used - type_string "reset; cat /proc/mdstat"; - send_key "ret"; - assert_screen "console_raid_used"; + validate_script_output "cat /proc/mdstat", sub { $_ =~ m/Personalities : \[raid1\]/ }; } sub test_flags { diff --git a/tests/disk_guided_delete_partial_postinstall.pm b/tests/disk_guided_delete_partial_postinstall.pm index ef832016..913a3e2c 100644 --- a/tests/disk_guided_delete_partial_postinstall.pm +++ b/tests/disk_guided_delete_partial_postinstall.pm @@ -5,12 +5,8 @@ use testapi; sub run { assert_screen "root_console"; # mount second partition and check that it's intact - type_string 'reset; mount /dev/vda2 /mnt; echo $?'; - send_key "ret"; - assert_screen "console_command_success"; - type_string 'reset; cat /mnt/testfile'; - send_key "ret"; - assert_screen "provided_second_partition_intact"; + validate_script_output 'mount /dev/vda2 /mnt; echo $?', sub { $_ =~ m/0/ }; + validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Oh, hi Mark/ }; } sub test_flags { diff --git a/tests/disk_guided_free_space_postinstall.pm b/tests/disk_guided_free_space_postinstall.pm index d81c8a1a..5db54aef 100644 --- a/tests/disk_guided_free_space_postinstall.pm +++ b/tests/disk_guided_free_space_postinstall.pm @@ -5,12 +5,8 @@ use testapi; sub run { assert_screen "root_console"; # check that first partition is intact - type_string 'reset; mount /dev/vda1 /mnt; echo $?'; - send_key "ret"; - assert_screen "console_command_success"; - type_string 'reset; cat /mnt/testfile'; - send_key "ret"; - assert_screen "provided_disk_intact"; + validate_script_output 'mount /dev/vda1 /mnt; echo $?', sub { $_ =~ m/0/ }; + validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Hello, world!/ }; } sub test_flags { diff --git a/tests/disk_guided_multi_empty_all_postinstall.pm b/tests/disk_guided_multi_empty_all_postinstall.pm index 0d88aeb8..07dc6f6e 100644 --- a/tests/disk_guided_multi_empty_all_postinstall.pm +++ b/tests/disk_guided_multi_empty_all_postinstall.pm @@ -6,9 +6,7 @@ sub run { assert_screen "root_console"; # when two disks are selected in installation, LVM is used - type_string "reset; pvdisplay"; - send_key "ret"; - assert_screen "console_two_disks_mounted_lvm"; + validate_script_output "pvdisplay", sub { $_ =~ m/\/dev\/vda/ && $_ =~ m/\/dev\/vdb/ }; } sub test_flags { diff --git a/tests/disk_guided_multi_postinstall.pm b/tests/disk_guided_multi_postinstall.pm index 04951be4..d2fab440 100644 --- a/tests/disk_guided_multi_postinstall.pm +++ b/tests/disk_guided_multi_postinstall.pm @@ -5,12 +5,8 @@ use testapi; sub run { assert_screen "root_console"; # check that second disk is intact - type_string 'reset; mount /dev/sdb1 /mnt; echo $?'; - send_key "ret"; - assert_screen "console_command_success"; - type_string 'reset; cat /mnt/testfile'; - send_key "ret"; - assert_screen "provided_disk_intact"; + validate_script_output 'mount /dev/sdb1 /mnt; echo $?', sub { $_ =~ m/0/ }; + validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Hello, world!/ }; } sub test_flags { diff --git a/tests/disk_guided_shrink_postinstall.pm b/tests/disk_guided_shrink_postinstall.pm index bf0846bb..4f24755b 100644 --- a/tests/disk_guided_shrink_postinstall.pm +++ b/tests/disk_guided_shrink_postinstall.pm @@ -5,12 +5,8 @@ use testapi; sub run { assert_screen "root_console"; # mount first partition and check that it's intact - type_string 'reset; mount /dev/vda1 /mnt; echo $?'; - send_key "ret"; - assert_screen "console_command_success"; - type_string 'reset; cat /mnt/testfile'; - send_key "ret"; - assert_screen "provided_disk_intact"; + validate_script_output 'mount /dev/vda1 /mnt; echo $?', sub { $_ =~ m/0/ }; + validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Hello, world!/ }; } sub test_flags { diff --git a/tests/install_source_graphical.pm b/tests/install_source_graphical.pm index 6608f4be..386e3d38 100644 --- a/tests/install_source_graphical.pm +++ b/tests/install_source_graphical.pm @@ -50,9 +50,7 @@ sub run { # check that the repo was used $self->root_console; - type_string "grep \"".$repourl."\" /tmp/packaging.log"; # | grep \"added repo\""; - send_key "ret"; - assert_screen "anaconda_install_source_check_repo_added"; + validate_script_output "grep \"".$repourl."\" /tmp/packaging.log", sub { $_ =~ m/added repo: 'anaconda'/ }; send_key "ctrl-alt-f6"; # Anaconda hub diff --git a/tests/install_source_variation.pm b/tests/install_source_variation.pm index 67a41584..3a25f6e9 100644 --- a/tests/install_source_variation.pm +++ b/tests/install_source_variation.pm @@ -16,9 +16,7 @@ sub run { # check that the repo was used $self->root_console; - type_string "grep \"".$repourl."\" /tmp/packaging.log"; #| grep \"added repo\""; - send_key "ret"; - assert_screen "anaconda_install_source_check_repo_added"; + validate_script_output "grep \"".$repourl."\" /tmp/packaging.log", sub { $_ =~ m/added repo: 'anaconda'/ }; send_key "ctrl-alt-f6"; # Anaconda hub diff --git a/tests/uefi_postinstall.pm b/tests/uefi_postinstall.pm index e2807361..70306300 100644 --- a/tests/uefi_postinstall.pm +++ b/tests/uefi_postinstall.pm @@ -9,9 +9,7 @@ sub run { } assert_screen "root_console"; # this test shows if the system is booted with efi - type_string 'reset; [ -d /sys/firmware/efi/ ]; echo $?'; - send_key "ret"; - assert_screen "console_command_success"; + validate_script_output '[ -d /sys/firmware/efi/ ]; echo $?', sub { $_ =~ m/0/ }; } sub test_flags { diff --git a/tests/upgrade_preinstall.pm b/tests/upgrade_preinstall.pm index 224749e6..42ef76f9 100644 --- a/tests/upgrade_preinstall.pm +++ b/tests/upgrade_preinstall.pm @@ -14,17 +14,13 @@ sub run { # switch to TTY3 for both, graphical and console tests $self->root_console(tty=>3); # disable screen blanking (update can take a long time) - type_string "setterm -blank 0\n"; + script_run "setterm -blank 0"; # upgrader should be installed on up-to-date system - type_string 'dnf -y update; echo $?'; - send_key "ret"; + validate_script_output 'dnf -y update; echo $?', sub { $_ =~ m/0/ }, 1800; - assert_screen "console_command_success", 1800; - - type_string "reboot"; - send_key "ret"; + script_run "reboot"; if (get_var('UPGRADE') eq "desktop") { $self->boot_to_login_screen("graphical_login", 30); # GDM takes time to load @@ -33,10 +29,8 @@ sub run { } $self->root_console(tty=>3); - type_string 'dnf -y --enablerepo=updates-testing install dnf-plugin-system-upgrade; echo $?'; - send_key "ret"; - - assert_screen "console_command_success", 1800; + my $update_command = 'dnf -y --enablerepo=updates-testing install dnf-plugin-system-upgrade; echo $?'; + validate_script_output $update_command, sub { $_ =~ m/0/ }, 1800; } diff --git a/tests/upgrade_run.pm b/tests/upgrade_run.pm index f391ef4a..dd0f05e8 100644 --- a/tests/upgrade_run.pm +++ b/tests/upgrade_run.pm @@ -12,10 +12,9 @@ sub run { $args .= " --nogpgcheck"; } # disable screen blanking (download can take a long time) - type_string "setterm -blank 0\n"; + script_run "setterm -blank 0"; - type_string "dnf -y system-upgrade download ${args}"; - send_key "ret"; + script_run "dnf -y system-upgrade download ${args}"; # wait until dnf finishes its work (screen stops moving for 30 seconds) wait_still_screen 30, 6000; # TODO: shorter timeout, longer stillscreen? @@ -23,8 +22,7 @@ sub run { upload_logs "/var/log/dnf.log"; upload_logs "/var/log/dnf.rpm.log"; - type_string "dnf system-upgrade reboot"; - send_key "ret"; + script_run "dnf system-upgrade reboot"; # now offline upgrading starts. user doesn't have to do anything, just wait untill # system reboots and login screen is shown