From ee3005b8f7452a3685c4d6d41546a99fe493b0b0 Mon Sep 17 00:00:00 2001 From: Trevor Cooper Date: Thu, 30 Jun 2022 21:29:19 -0700 Subject: [PATCH] add and use get_code_name() utility function - remove the undocumented CODENAME test variable - codenames from https://git.rockylinux.org/staging/rpms/rocky-release/-/blob/r9/code --- lib/utils.pm | 23 ++++++++++++++++++++--- tests/os_release.pm | 2 +- tests/rocky_release.pm | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/utils.pm b/lib/utils.pm index c3296578..397d253a 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -5,9 +5,10 @@ use strict; use base 'Exporter'; 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 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_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. @@ -62,6 +63,22 @@ sub get_release_number { return $version } +sub get_code_name { + my $code_name = 'Green Obsidian'; + my $version = get_var('VERSION'); + my $ver_major = substr($version, 0, index($version, q/./)); + + given($ver_major){ + when ('9') { $code_name = 'Blue Onyx'; } + when ('10') { $code_name = 'Smoky Quartz'; } + when ('11') { $code_name = 'Lavender Calcite'; } + default{ + $code_name = 'Green Obsidian'; + } + } + return $code_name; +} + # Figure out what tty the desktop is on, switch to it. Assumes we're # at a root console sub desktop_vt { @@ -1360,8 +1377,8 @@ sub register_application { } # The KDE desktop tests are very difficult to maintain, because the transparency -# of the menu requires a lot of different needles to cover the elements. -# Therefore it is useful to change the background to a solid colour. +# of the menu requires a lot of different needles to cover the elements. +# Therefore it is useful to change the background to a solid colour. # Since many needles have been already created with a black background # we will keep it that way. The following code has been taken from the # KDE startstop tests but it is good to have it here, because it will be diff --git a/tests/os_release.pm b/tests/os_release.pm index b675b353..70356f34 100644 --- a/tests/os_release.pm +++ b/tests/os_release.pm @@ -47,7 +47,7 @@ sub run { my $reltag = script_output 'rpm -q rocky-release --qf "%{RELEASE}\n"'; my ($relver, $eltag) = split /\./, $reltag; - my $code_name = get_var("CODENAME", 'Green Obsidian'); + my $code_name = get_code_name(); my $version = "$version_id ($code_name)"; my $platform_id = "platform:$eltag"; my $pretty = "$fullname $version_id ($code_name)"; diff --git a/tests/rocky_release.pm b/tests/rocky_release.pm index 62ec091d..c365dc62 100644 --- a/tests/rocky_release.pm +++ b/tests/rocky_release.pm @@ -20,7 +20,7 @@ sub run { # Version as defined in the VERSION variable. my $expectver = get_var('VERSION'); # Code Name as defined in the CODENAME variable or default. - my $code_name = get_var('CODENAME', "Green Obsidian"); + my $code_name = get_code_name(); # Create the expected content of the release file # and compare it with its real counterpart. my $expected = "Rocky Linux release $expectver ($code_name)";