diff --git a/lib/installedtest.pm b/lib/installedtest.pm index 125c5ce7..b48971d3 100644 --- a/lib/installedtest.pm +++ b/lib/installedtest.pm @@ -101,16 +101,6 @@ sub repo_setup { script_run "cat /etc/yum.repos.d/{fedora,fedora-rawhide}.repo"; } -# switch to the desktop where the VT is -sub desktop_vt { - if (get_var("DESKTOP") eq 'gnome') { - send_key 'ctrl-alt-f2'; - } - else { - send_key 'ctrl-alt-f1'; - } -} - 1; # vim: set sw=4 et: diff --git a/lib/main_common.pm b/lib/main_common.pm index 67faaa49..4c97ea9f 100644 --- a/lib/main_common.pm +++ b/lib/main_common.pm @@ -6,7 +6,7 @@ use base 'Exporter'; use Exporter; use testapi; -our @EXPORT = qw/run_with_error_check check_type_string type_safely type_very_safely/; +our @EXPORT = qw/run_with_error_check check_type_string type_safely type_very_safely desktop_vt/; sub run_with_error_check { my ($func, $error_screen) = @_; @@ -48,3 +48,17 @@ sub type_very_safely { check_type_string($string, size => 1, still => 5, max_interval => 1); wait_still_screen 5; } + +# Figure out what tty the desktop is on, switch to it. Assumes we're +# at a root console +sub desktop_vt { + # use ps to find the tty of Xwayland or Xorg + my $xout; + # don't fail test if we don't find any process, just guess tty1 + eval { $xout = script_output 'ps -C Xwayland,Xorg -o tty --no-headers'; }; + my $tty = 1; # default + while ($xout =~ /tty(\d)/g) { + $tty = $1; # most recent match is probably best + } + send_key "ctrl-alt-f${tty}"; +} diff --git a/tests/desktop_notifications_postinstall.pm b/tests/desktop_notifications_postinstall.pm index 3f328d2f..3512cdcb 100644 --- a/tests/desktop_notifications_postinstall.pm +++ b/tests/desktop_notifications_postinstall.pm @@ -23,7 +23,7 @@ sub run { # just assume we're gonna win $self->root_console(tty=>3); prepare_test_packages; - $self->desktop_vt(); + desktop_vt; # now, WE WAIT. this is just an unconditional wait - rather than # breaking if we see an update notification appear - so we catch # things that crash a few minutes after startup, etc. diff --git a/tests/desktop_update_graphical_postinstall.pm b/tests/desktop_update_graphical_postinstall.pm index 133f7219..9f689998 100644 --- a/tests/desktop_update_graphical_postinstall.pm +++ b/tests/desktop_update_graphical_postinstall.pm @@ -12,7 +12,7 @@ sub run { assert_script_run 'dnf config-manager --set-disabled updates-testing'; prepare_test_packages; # get back to the desktop - $self->desktop_vt(); + desktop_vt; # run the updater if ($desktop eq 'kde') { # KDE team tells me the 'preferred' update method is the