Kdump enable/disable fixes #5

Merged
tcooper merged 10 commits from kdump_enable_disable into develop 2021-08-19 23:13:48 +00:00
3 changed files with 67 additions and 117 deletions
Showing only changes of commit b3f12fef7d - Show all commits

View File

@ -386,13 +386,12 @@ sub boot_decrypt {
sub check_release {
# Checks whether the installed release matches a given value. E.g.
# `check_release(23)` checks whether the installed system is
# Fedora 23. The value can be 'Rawhide' or a Fedora release
# number; often you will want to use `get_var('VERSION')`. Expects
# `check_release(8.4)` checks whether the installed system is
# Rocky Linux 8.4. Often you will want to use `get_var('VERSION')`. Expects
# a console prompt to be active when it is called.
my $release = shift;
my $check_command = "grep SUPPORT_PRODUCT_VERSION /etc/os-release";
validate_script_output $check_command, sub { $_ =~ m/REDHAT_SUPPORT_PRODUCT_VERSION=$release/ };
validate_script_output $check_command, sub { $_ =~ m/ROCKY_SUPPORT_PRODUCT_VERSION=$release/ };
}
sub disable_firefox_studies {

View File

@ -33,100 +33,24 @@ sub run {
# Now, we have all the data ready and we can start testing, first let us get
# correct variables to compare the system data with.
# First, we know the basic stuff
my $id = get_var("DISTRI"); # Should be "fedora"
# extract expected version components from ISO name for canned variants,
# which have their os-release rewritten by rpm-ostree, see:
# https://github.com/projectatomic/rpm-ostree/blob/master/docs/manual/treefile.md
# we use the ISO name because rpm-ostree uses elements from the compose
# ID for nightlies, but from the label for candidate composes; BUILD
# always gives us the compose ID, but the ISO name contains the compose
# ID for nightlies but the label for candidate composes, so it works for
# our purposes here.
my $isovar = get_var("ISO");
# Split the ISO variable at "-" and read second-to-last (release
# number) and last (compose ID: date and respin, label: major and
# minor) fields.
my ($cannedver, $cannednum) = (split /-/, $isovar)[-2, -1];
# Get rid of the ".iso" part of the tag.
$cannednum =~ s/\.iso//g;
# Now, we merge the fields into one expression to create the correct canned tag
# that will contain both the version number and the build number.
my $cannedtag = "$cannedver.$cannednum";
# If this is a CoreOS build, though, throw all that away and
# just use the build version
my $build = get_var("BUILD");
if ($build =~ /^Fedora-CoreOS/) {
$cannedtag = (split /-/, $build)[-1];
}
my $id = get_var("DISTRI"); # Should be "rocky"
my $name = ucfirst($id);
# from F35 onwards, $NAME is "Fedora Linux" not just "Fedora"
my $relnum = get_release_number;
my $fullname = $relnum > 34 ? $name . " Linux" : $name;
my $rawrel = get_var("RAWREL", '');
my $version_id = get_var("VERSION"); # Should be the version number or Rawhide.
# IoT has a branch that acts more or less like Rawhide, but has
# its version as the Rawhide release number, not 'Rawhide'. This
# handles that
$version_id = 'Rawhide' if ($version_id eq $rawrel);
my $varstr = spell_version_number($version_id);
my $target = lc($version_id);
$version_id = $rawrel if ($version_id eq "Rawhide");
# $NAME is "Rocky Linux" not just "Rocky"
my $fullname = $name . " Linux";
# the 'generic' os-release in fedora-release has no VARIANT or
# VARIANT_ID and the string used in values like VERSION, that in other
# cases is the VARIANT, is 'Rawhide' for Rawhide and the spelt version
# number for other releases. These are the values we'll see for an
# Everything image.
my $variant_id = "";
my $variant = "generic";
my $version_id = get_var("VERSION"); # Should be the version number.
my ($ver_major, $ver_minor) = split /\./, $version_id;
my $varstr = spell_version_number($version_id);
my $target = lc($ver_major);
# now replace the values with the correct ones if we are testing a
# subvariant that maps to a known variant
my $subvariant = get_var('SUBVARIANT');
my %variants = (
Server => ["server", "Server Edition"],
Workstation => ["workstation", "Workstation Edition"],
AtomicHost => ["atomic.host", "Atomic Host"],
CoreOS => ["coreos", "CoreOS"],
KDE => ["kde", "KDE Plasma"],
Silverblue => ["silverblue", "Silverblue"],
IoT => ["iot", "IoT Edition"],
);
if (exists($variants{$subvariant})) {
($variant_id, $variant) = @{$variants{$subvariant}};
$varstr = $variant;
}
my $reltag = script_output 'rpm -q rocky-release --qf "%{RELEASE}\n"';
my ($relver, $eltag) = split /\./, $reltag;
# If fedora-release-common release starts with a 0, we'll have
# "Prerelease" in varstr
my $reltag = script_output 'rpm -q fedora-release-common --qf "%{RELEASE}\n"';
if (index($reltag, "0.") == 0) {
$varstr .= " Prerelease";
# ...however, we shouldn't just wave this through if we're
# an RC candidate or update compose, those should never be
# done with a 0.x fedora-release-common. so let's blow up
# here if so. unless it's IoT, because IoT is weird
my $label = get_var("LABEL");
if ($label =~ /^(RC|Update)-/ && $subvariant ne "IoT") {
die "RC candidate or update compose should not have 0.x versioned fedora-release!";
}
}
my $version = "$version_id ($varstr)";
# for canned variants, we need to form a different string here by using
# the above created cannedtag. See earlier comment
if (get_var("CANNED")) {
$version = "$cannedtag ($varstr)";
}
my $platform_id = "platform:f$version_id";
my $pretty = "$fullname $version_id ($varstr)";
# Same problem is when testing the PRETTY_NAME.
if (get_var("CANNED")) {
$pretty = "$fullname $cannedtag ($varstr)";
# ...and FCOS uses a different format, sigh
if ($build =~ /^Fedora-CoreOS/) {
$pretty = "Fedora CoreOS $cannedtag";
}
}
my $code_name = get_var("CODENAME", 'Green Obsidian');
my $version = "$version_id ($code_name)";
my $platform_id = "platform:$eltag";
my $pretty = "$fullname $version_id ($code_name)";
#Now. we can start testing the real values from the installed system.
my @fails = ();
@ -141,7 +65,8 @@ sub run {
rec_log "VERSION should be $version and is $strip", $strip eq $version, $failref;
# Test for version_id
rec_log "VERSION_ID should be $version_id and is $content{'VERSION_ID'}", $content{'VERSION_ID'} eq $version_id, $failref;
$strip = strip_marks($content{'VERSION_ID'});
rec_log "VERSION_ID should be $version_id and is $strip", $strip eq $version_id, $failref;
# Test for platform_id
$strip = strip_marks($content{'PLATFORM_ID'});
@ -151,34 +76,24 @@ sub run {
$strip = strip_marks($content{'PRETTY_NAME'});
rec_log "PRETTY_NAME should be $pretty and is $strip", $strip eq $pretty, $failref;
# Test for RH Bugzilla Product
$strip = strip_marks($content{'REDHAT_BUGZILLA_PRODUCT'});
rec_log "REDHAT_BUGZILLA_PRODUCT should be $name and is $strip", $strip eq $name, $failref;
# Test for Rocky Support Product
$strip = strip_marks($content{'ROCKY_SUPPORT_PRODUCT'});
rec_log "ROCKY_SUPPORT_PRODUCT should be $name and is $strip", $strip eq $fullname, $failref;
# Test for RH Bugzilla Product Version
rec_log "REDHAT_BUGZILLA_PRODUCT_VERSION should be $target and is $content{'REDHAT_BUGZILLA_PRODUCT_VERSION'}", $content{'REDHAT_BUGZILLA_PRODUCT_VERSION'} eq $target, $failref;
# Test for Rocky Support Product Version
$strip = strip_marks($content{ROCKY_SUPPORT_PRODUCT_VERSION});
rec_log "ROCKY_SUPPORT_PRODUCT_VERSION should be $target and is $strip", $strip eq $target, $failref;
# Test for RH Support Product
$strip = strip_marks($content{'REDHAT_SUPPORT_PRODUCT'});
rec_log "REDHAT_SUPPORT_PRODUCT should be $name and is $strip", $strip eq $name, $failref;
# VERSION_ID should be 8.4 and is "8.4"
# PLATFORM_ID should be platform: and is platform:el8
# ROCKY_SUPPORT_PRODUCT should be Rocky and is Rocky Linux
# ROCKY_SUPPORT_PRODUCT_VERSION should be and is 8 at /var/lib/openqa/share/tests/rocky/tests/os_release.pm line 95.
# Test for RH Support Product Version
rec_log "REDHAT_SUPPORT_PRODUCT_VERSION should be $target and is $content{'REDHAT_SUPPORT_PRODUCT_VERSION'}", $content{'REDHAT_SUPPORT_PRODUCT_VERSION'} eq $target, $failref;
# Test for Variant but only in case of Server or Workstation
if ($variant ne "generic") {
$strip = strip_marks($content{'VARIANT'});
rec_log "VARIANT should be $variant and is $strip", $strip eq $variant, $failref;
# Test for VARIANT_ID
rec_log "VARIANT_ID should be $variant_id and is $content{'VARIANT_ID'}", $content{'VARIANT_ID'} eq $variant_id, $failref;
}
else {
print "VARIANT was not tested because the compose is not Workstation or Server Edition.\n";
print "VARIANT_ID was not tested because the compose is not Workstation or Server Edition.\n";
}
# Check for fails, count them, collect their messages and die if something was found.
# Check for fails, count them, collect their messages and die if something was found.
my $failcount = scalar @fails;
script_run "echo \"There were $failcount failures in total.\" >> /tmp/os-release.log";
upload_logs "/tmp/os-release.log", failok=>1;

36
tests/rocky_release.pm Normal file
View File

@ -0,0 +1,36 @@
use base "installedtest";
use strict;
use testapi;
use utils;
# This test checks that Rocky release is correctly described in /etc/rocky-release file.
# The content of the file should be: "Rocky Linux release <version> (<code_name>)"
# where "version" is a number of the current Rocky Linux version and "code_name" is the
# code_name for the release.
# At such time we are building the next release that has a new code_name we'll need
# to decide how to implement detection in rocky_release.pm.
# To maintain simplicity (at least initially) we will explicitly define our code_name
# directly. If RAWREL is required in other tests it should be defined during POST or
# in tests to be the same as VERSION.
sub run {
my $self = shift;
# 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");
# Create the expected content of the release file
# and compare it with its real counterpart.
my $expected = "Rocky Linux release $expectver ($code_name)";
validate_script_output 'cat /etc/rocky-release', sub { $_ eq $expected };
}
sub test_flags {
return {always_rollback => 1};
}
1;
# vim: set sw=4 et: