Skip to content

Commit

Permalink
Test yast2 kdump in unsupported environment
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mloviska committed Jan 11, 2021
1 parent 40c6afc commit ef9f3ff
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
11 changes: 11 additions & 0 deletions lib/Utils/Backends.pm
Expand Up @@ -40,6 +40,7 @@ use constant {
is_hyperv_in_gui
is_svirt_except_s390x
is_pvm
is_xen_pv
)
],
CONSOLES => [
Expand Down Expand Up @@ -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
Expand Down
33 changes: 30 additions & 3 deletions lib/kdump_utils.pm
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion tests/console/kdump_and_crash.pm
Expand Up @@ -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');
}

Expand Down

0 comments on commit ef9f3ff

Please sign in to comment.