forked from os-autoinst/os-autoinst-distri-opensuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_power_action_utils.t
30 lines (26 loc) · 1008 Bytes
/
04_power_action_utils.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use strict;
use warnings;
use Test::Fatal;
use Test::More;
use Test::Warnings;
use Test::MockModule;
use Test::MockObject;
use testapi 'set_var';
use power_action_utils;
is prepare_system_shutdown, undef, 'prepare_system_shutdown has no effect by default';
set_var('BACKEND', 'spvm');
my @calls;
my $mock = Test::MockModule->new('power_action_utils');
$mock->redefine(console => sub {
push @calls, @_;
Test::MockObject->new()->set_true('kill_ssh')->set_true('disable_vnc_stalls')->set_true('stop_serial_grab');
});
is prepare_system_shutdown, undef, 'prepare_system_shutdown for spvm is fine';
is_deeply \@calls, ['root-ssh'], 'root-ssh console accessed';
@calls = [];
set_var('S390_ZKVM', 1);
like exception { prepare_system_shutdown }, qr/required.*SVIRT_VNC_CONSOLE/, 'needs svirt VNC console';
set_var('SVIRT_VNC_CONSOLE', 'my_svirt_vnc');
is prepare_system_shutdown, undef, 'prepare_system_shutdown for zkvm is fine';
is $calls[-1], 'svirt', 'svirt consoles accessed';
done_testing;