1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-23 18:53:08 +00:00

use validate_script_output instead of typing and needles matching

Use validate_script_output and regex matching instead
of type_string and needles.

Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D637
This commit is contained in:
Jan Sedlák 2015-11-04 14:38:36 +01:00
parent 2e1dc5877b
commit ec6b3ff4a3
36 changed files with 49 additions and 255 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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:

View File

@ -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;

View File

@ -6,13 +6,6 @@
"width": 217,
"height": 19,
"type": "match"
},
{
"xpos": 577,
"ypos": 430,
"width": 89,
"height": 20,
"type": "match"
}
],
"tags": [

View File

@ -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
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -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
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -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"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -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": []
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

View File

@ -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": []
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

View File

@ -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": []
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

View File

@ -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"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -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": []
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -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"
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

View File

@ -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"
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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;
}

View File

@ -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