create and use get_version_major utility function

This commit is contained in:
Trevor Cooper 2022-07-06 10:01:41 -07:00
parent 2c432c8f2e
commit ecd8dfee2d
Signed by: tcooper
GPG Key ID: 52364D7BBCEB35B8
9 changed files with 32 additions and 15 deletions

View File

@ -8,7 +8,7 @@ use Exporter;
use feature "switch";
use lockapi;
use testapi;
our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type repo_setup setup_workaround_repo cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number get_code_name check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist register_application get_registered_applications solidify_wallpaper/;
our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type repo_setup setup_workaround_repo cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number get_version_major get_code_name check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist register_application get_registered_applications solidify_wallpaper/;
# We introduce this global variable to hold the list of applications that have
# registered during the apps_startstop_test when they have sucessfully run.
@ -63,12 +63,18 @@ sub get_release_number {
return $version
}
sub get_version_major {
my $version = get_var('VERSION');
my $version_major = substr($version, 0, index($version, q/./));
return $version_major
}
sub get_code_name {
my $code_name = 'Green Obsidian';
my $version = get_var('VERSION');
my $ver_major = substr($version, 0, index($version, q/./));
my $version_major = get_version_major;
given($ver_major){
given($version_major){
when ('9') { $code_name = 'Blue Onyx'; }
when ('10') { $code_name = 'Smoky Quartz'; }
when ('11') { $code_name = 'Lavender Calcite'; }
@ -605,7 +611,8 @@ sub _repo_setup_updates {
assert_script_run 'printf "[advisory]\nname=Advisory repo\nbaseurl=file:///opt/update_repo\nenabled=1\nmetadata_expire=3600\ngpgcheck=0" > /etc/yum.repos.d/advisory.repo';
# run an update now (except for upgrade tests)
my $relnum = get_release_number;
if ($relnum > 33) {
my $version_major = get_version_major;
if (($relnum > 33) || ($version_major > 8)) {
# FIXME workaround https://bugzilla.redhat.com/show_bug.cgi?id=1931034
# drop after https://github.com/systemd/systemd/pull/18915 is merged
# and stable
@ -953,7 +960,8 @@ sub start_with_launcher {
# but only after we hit 'down' twice to get into it.
# On F32 and earlier, it just scrolls vertically
my $relnum = get_release_number;
if ($relnum > 32) {
my $version_major = get_version_major;
if (($relnum > 32) || ($version_major > 8)) {
send_key 'down';
send_key 'down';
send_key_until_needlematch($launcher, 'right', 5, 6);

View File

@ -5,7 +5,8 @@ use utils;
sub run {
my $relnum = get_release_number;
if (get_var("LANGUAGE") eq 'japanese' && $relnum > 33) {
my $version_major = get_version_major;
if (get_var("LANGUAGE") eq 'japanese' && (($relnum > 33) || ($version_major > 8))) {
# since g-i-s new user mode was dropped and the replacement
# doesn't do input method selection, and anaconda never has,
# we have to set up the input method manually:

View File

@ -65,7 +65,7 @@ sub run {
# GDM 3.24.1 dumps a cursor in the middle of the screen here...
mouse_hide;
if (get_var("DESKTOP") eq 'gnome') {
if ($version eq '9.0') {
if (get_version_major() > 8) {
send_key_until_needlematch("graphical_login_test_user_highlighted", "tab", 5);
assert_screen "graphical_login_test_user_highlighted";
}
@ -93,6 +93,8 @@ sub run {
send_key "ret";
}
# Welcome tour is here...
# For GNOME, handle initial-setup or welcome tour, unless START_AFTER_TEST
# is set in which case it will have been done already. Always
# do it if ADVISORY_OR_TASK is set, as for the update testing flow,
@ -102,7 +104,8 @@ sub run {
# we might be on the INSTALL_NO_USER flow, check whether
# this happened already
my $relnum = get_release_number;
if ($relnum < 34) {
my $version_major = get_version_major();
if (($relnum < 34) || ($version_major < 9)) {
# before GNOME 40 (F34), we get a per-user version of
# gnome-initial-setup here...
gnome_initial_setup() unless (get_var("_setup_done"));
@ -112,7 +115,7 @@ sub run {
handle_welcome_screen unless (get_var("_welcome_done"));
}
}
if ($version eq '9.0') {
if (get_version_major() > 8) {
handle_welcome_screen unless (get_var("_welcome_done"));
}
if (get_var("DESKTOP") eq 'gnome' && get_var("INSTALL_NO_USER")) {

View File

@ -157,7 +157,8 @@ sub reboot_system {
click_lastmatch;
if (match_has_tag("power_entry")) {
my $relnum = get_release_number;
if ($desktop eq "gnome" && $relnum < 33) {
my $version_major = get_version_major;
if ($desktop eq "gnome" && (($relnum < 33) || ($version_major < 9))) {
# In GNOME before F33, some of the entries are brought together, while
# in KDE and GNOME from F33 onwards they are split and it does not seem
# correct to me to assign restarting tags to needles powering off the

View File

@ -14,6 +14,7 @@ sub run {
my $self = shift;
my $desktop = get_var("DESKTOP");
my $relnum = get_release_number;
my $version_major = get_version_major;
# for the live image case, handle bootloader here
if (get_var("BOOTFROM")) {
do_bootloader(postinstall=>1, params=>'3');
@ -118,7 +119,7 @@ sub run {
}
}
if (get_var("BOOTFROM")) {
if ($desktop eq 'kde' && $relnum > 33) {
if ($desktop eq 'kde' && (($relnum > 33) || ($version_major > 8))) {
# there is not always a permanent notification in F34+,
# if we don't see one, check we saw the transient one
# earlier. FIXME: maybe drop the 'transient' path here

View File

@ -6,13 +6,14 @@ use utils;
sub run {
my $self = shift;
my $relnum = get_release_number;
my $version_major = get_version_major;
my $desktop = get_var("DESKTOP");
check_desktop;
menu_launch_type('terminal');
assert_screen "apps_run_terminal";
# FIXME: workaround for RHBZ#1957858 - test actually works without
# this, but very slowly as characters don't appear on screen
send_key "super-pgup" if ($relnum > 33 && $desktop eq "kde");
send_key "super-pgup" if ((($version_major > 8) || ($relnum > 33)) && $desktop eq "kde");
wait_still_screen 5;
# need to be root
my $rootpass = get_var("ROOT_PASSWORD", "weakpassword");

View File

@ -8,6 +8,7 @@ sub run {
my $self = shift;
my $desktop = get_var('DESKTOP');
my $relnum = get_release_number;
my $version_major = get_version_major;
# use a tty console for repo config and package prep
$self->root_console(tty=>3);
assert_script_run 'dnf config-manager --set-disabled updates-testing';
@ -22,7 +23,7 @@ sub run {
if ($desktop eq 'kde') {
# KDE team tells me until F34 the 'preferred' update method
# was the systray applet...
if ($relnum < 34) {
if (($relnum < 34) || ($version_major < 9)) {
# get rid of notifications which get in the way of the things
# we need to click
click_unwanted_notifications;

View File

@ -27,7 +27,8 @@ sub run {
# The next box we need to type into was moved in FreeIPA 4.8.9,
# which is in F32+ but not F31
my $relnum = get_release_number;
$relnum < 32 ? type_safely "\t\t" : type_safely "\t";
my $version_major = get_version_major;
(($relnum < 32) || ($version_major < 9)) ? type_safely "\t\t" : type_safely "\t";
type_safely "loremipsum";
wait_screen_change { send_key "tab"; };
type_safely "loremipsum";

View File

@ -106,7 +106,7 @@ sub run {
console_type_wait("3\n"); # set username
console_type_wait("$username\n");
# from Rawhide-20190503.n.0 (F31) onwards, 'use password' is default
if (get_release_number() < 31 && lc(get_var('DISTRI')) ne "rocky") {
if ((get_release_number() < 31) || (get_version_major() < 9)) {
# typing "4\n" on abrt screen causes system to reboot, so be careful
run_with_error_check(sub {console_type_wait("4\n")}, $error); # use password
}