From ef9f3ff8beed9fbf4fe5427512d63050a541e2af Mon Sep 17 00:00:00 2001 From: mloviska Date: Mon, 11 Jan 2021 09:53:04 +0100 Subject: [PATCH] Test yast2 kdump in unsupported environment YaST2 currently detects the environment and alerts the user in case there is an attempt to configure kdump in Xen DomU system which is not supported. --- lib/Utils/Backends.pm | 11 +++++++++++ lib/kdump_utils.pm | 33 +++++++++++++++++++++++++++++--- tests/console/kdump_and_crash.pm | 5 ++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/lib/Utils/Backends.pm b/lib/Utils/Backends.pm index be42b27abc03..800765e1738e 100644 --- a/lib/Utils/Backends.pm +++ b/lib/Utils/Backends.pm @@ -40,6 +40,7 @@ use constant { is_hyperv_in_gui is_svirt_except_s390x is_pvm + is_xen_pv ) ], CONSOLES => [ @@ -142,6 +143,16 @@ sub is_hyperv_in_gui { return is_hyperv && !check_var('VIDEOMODE', 'text'); } +=head2 is_xen_pv + +Returns true if the current VM runs in Xen host in paravirtual mode + +=cut + +sub is_xen_pv { + return check_var('VIRSH_VMM_FAMILY', 'xen') && check_var('VIRSH_VMM_TYPE', 'linux'); +} + =head2 is_svirt_except_s390x Returns true if the current instance is running as svirt backend except s390x diff --git a/lib/kdump_utils.pm b/lib/kdump_utils.pm index b98b44af5819..abe870736ff0 100644 --- a/lib/kdump_utils.pm +++ b/lib/kdump_utils.pm @@ -14,7 +14,7 @@ use warnings; use testapi; use utils; use registration; -use Utils::Backends 'is_pvm'; +use Utils::Backends qw(is_pvm is_xen_pv); use Utils::Architectures qw(is_ppc64le is_aarch64); use power_action_utils 'power_action'; use version_utils qw(is_sle is_jeos is_leap is_tumbleweed is_opensuse); @@ -113,6 +113,20 @@ sub prepare_for_kdump { zypper_call("mr -d $opensuse_debug_repos"); } +sub handle_warning_not_supported { + my $warning = shift; + + if ($warning eq 'yast2-kdump-not-supported') { + send_key 'ret'; + assert_screen 'yast2-kdump-cannot-read-mem'; + send_key 'ret'; + } elsif ($warning eq 'yast2-kdump-cannot-read-mem') { + send_key 'ret'; + } else { + die "Unknown warning message\n"; + } +} + # use yast2 kdump to enable the kdump service sub activate_kdump { # restart info will appear only when change has been done @@ -121,7 +135,18 @@ sub activate_kdump { my $memory_total = script_output('kdumptool calibrate | awk \'/Total:/ {print $2}\''); my $memory_kdump = $memory_total >= 2048 ? 1024 : 320; my $module_name = y2_module_consoletest::yast2_console_exec(yast2_module => 'kdump', yast2_opts => '--ncurses'); - assert_screen([qw(yast2-kdump-disabled yast2-kdump-enabled)], 200); + my @initial_tags = qw(yast2-kdump-disabled yast2-kdump-enabled); + push(@initial_tags, + (is_sle('>=15-sp3')) ? 'yast2-kdump-not-supported' : 'yast2-kdump-cannot-read-mem') if (is_xen_pv); + + assert_screen(\@initial_tags, 200); + if (match_has_tag('yast2-kdump-not-supported') || match_has_tag('yast2-kdump-cannot-read-mem')) { + handle_warning_not_supported(pop(@initial_tags)); + assert_screen(\@initial_tags, 200); + send_key 'alt-c'; + wait_serial("$module_name-16") || die "'yast2 kdump' didn't finish"; + return 16; + } if (match_has_tag('yast2-kdump-disabled')) { # enable kdump send_key('alt-u'); @@ -218,7 +243,9 @@ sub configure_service { } prepare_for_kdump($test_type); - activate_kdump; + if (activate_kdump == 16) { + return 16; + } # restart to activate kdump power_action('reboot', keepconsole => is_pvm); diff --git a/tests/console/kdump_and_crash.pm b/tests/console/kdump_and_crash.pm index 4a7ff4a0622a..bc6080c068ef 100644 --- a/tests/console/kdump_and_crash.pm +++ b/tests/console/kdump_and_crash.pm @@ -20,7 +20,10 @@ use kdump_utils; sub run { select_console('root-console'); - kdump_utils::configure_service('function'); + if (kdump_utils::configure_service('function') == 16) { + record_info 'Not supported', 'Kdump is not supported in a PV DomU'; + return; + } kdump_utils::check_function('function'); }