From aa20bab7139e7f475b46129ae1886b90d900e439 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 12 Jan 2016 09:27:14 -0800 Subject: [PATCH] use assert_script_run when possible Summary: D637 / ec6b3ff4 switched from using needle matches to using validate_script_output when we want to run a console command and check the result. validate_script_output is kinda over- powered when all you want to do is check the command succeeded (returned 0), though. testapi provides assert_script_run for doing exactly that - it runs a script and fails if the script fails (returns anything but 0). This gives us cleaner code and is slightly more robust; validate_script_output uses the mini web server on the worker, which I've occasionally seen crap out, so it seems good to avoid using it when possible. assert_ script_run doesn't need it. Test Plan: Check all (affected) tests still work properly. Reviewers: jskladan, garretraziel Reviewed By: jskladan, garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D714 --- tests/disk_guided_delete_partial_postinstall.pm | 2 +- tests/disk_guided_free_space_postinstall.pm | 2 +- tests/disk_guided_multi_postinstall.pm | 2 +- tests/disk_guided_shrink_postinstall.pm | 2 +- tests/uefi_postinstall.pm | 2 +- tests/upgrade_preinstall.pm | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/disk_guided_delete_partial_postinstall.pm b/tests/disk_guided_delete_partial_postinstall.pm index 913a3e2c..2e876369 100644 --- a/tests/disk_guided_delete_partial_postinstall.pm +++ b/tests/disk_guided_delete_partial_postinstall.pm @@ -5,7 +5,7 @@ use testapi; sub run { assert_screen "root_console"; # mount second partition and check that it's intact - validate_script_output 'mount /dev/vda2 /mnt; echo $?', sub { $_ =~ m/0/ }; + assert_script_run 'mount /dev/vda2 /mnt'; validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Oh, hi Mark/ }; } diff --git a/tests/disk_guided_free_space_postinstall.pm b/tests/disk_guided_free_space_postinstall.pm index 5db54aef..778bf8ef 100644 --- a/tests/disk_guided_free_space_postinstall.pm +++ b/tests/disk_guided_free_space_postinstall.pm @@ -5,7 +5,7 @@ use testapi; sub run { assert_screen "root_console"; # check that first partition is intact - validate_script_output 'mount /dev/vda1 /mnt; echo $?', sub { $_ =~ m/0/ }; + assert_script_run 'mount /dev/vda1 /mnt'; validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Hello, world!/ }; } diff --git a/tests/disk_guided_multi_postinstall.pm b/tests/disk_guided_multi_postinstall.pm index d2fab440..920aa6bf 100644 --- a/tests/disk_guided_multi_postinstall.pm +++ b/tests/disk_guided_multi_postinstall.pm @@ -5,7 +5,7 @@ use testapi; sub run { assert_screen "root_console"; # check that second disk is intact - validate_script_output 'mount /dev/sdb1 /mnt; echo $?', sub { $_ =~ m/0/ }; + assert_script_run 'mount /dev/sdb1 /mnt'; validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Hello, world!/ }; } diff --git a/tests/disk_guided_shrink_postinstall.pm b/tests/disk_guided_shrink_postinstall.pm index 4f24755b..28cfa6ff 100644 --- a/tests/disk_guided_shrink_postinstall.pm +++ b/tests/disk_guided_shrink_postinstall.pm @@ -5,7 +5,7 @@ use testapi; sub run { assert_screen "root_console"; # mount first partition and check that it's intact - validate_script_output 'mount /dev/vda1 /mnt; echo $?', sub { $_ =~ m/0/ }; + assert_script_run 'mount /dev/vda1 /mnt'; validate_script_output 'cat /mnt/testfile', sub { $_ =~ m/Hello, world!/ }; } diff --git a/tests/uefi_postinstall.pm b/tests/uefi_postinstall.pm index 70306300..77dda8ef 100644 --- a/tests/uefi_postinstall.pm +++ b/tests/uefi_postinstall.pm @@ -9,7 +9,7 @@ sub run { } assert_screen "root_console"; # this test shows if the system is booted with efi - validate_script_output '[ -d /sys/firmware/efi/ ]; echo $?', sub { $_ =~ m/0/ }; + assert_script_run '[ -d /sys/firmware/efi/ ]'; } sub test_flags { diff --git a/tests/upgrade_preinstall.pm b/tests/upgrade_preinstall.pm index 42ef76f9..ec4b9a3e 100644 --- a/tests/upgrade_preinstall.pm +++ b/tests/upgrade_preinstall.pm @@ -18,7 +18,7 @@ sub run { # upgrader should be installed on up-to-date system - validate_script_output 'dnf -y update; echo $?', sub { $_ =~ m/0/ }, 1800; + assert_script_run 'dnf -y update', 1800; script_run "reboot"; @@ -29,8 +29,8 @@ sub run { } $self->root_console(tty=>3); - my $update_command = 'dnf -y --enablerepo=updates-testing install dnf-plugin-system-upgrade; echo $?'; - validate_script_output $update_command, sub { $_ =~ m/0/ }, 1800; + my $update_command = 'dnf -y --enablerepo=updates-testing install dnf-plugin-system-upgrade'; + assert_script_run $update_command, 1800; }