mirror of
https://github.com/rocky-linux/os-autoinst-distri-rocky.git
synced 2024-11-25 14:41:27 +00:00
Fix and simplify fedora_release test
Also simplify os_release a bit thanks to the improved spell_ version_number. Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
parent
23552c777d
commit
bf5691e69d
@ -1034,6 +1034,8 @@ sub check_version {
|
||||
|
||||
sub spell_version_number {
|
||||
my $version = shift;
|
||||
# spelt version of Rawhide is...Rawhide
|
||||
return "Rawhide" if ($version eq 'Rawhide');
|
||||
my %ones = (
|
||||
"0" => "Zero",
|
||||
"1" => "One",
|
||||
@ -1070,7 +1072,8 @@ sub spell_version_number {
|
||||
}
|
||||
|
||||
sub rec_log {
|
||||
my ($line, $condition, $failref) = @_;
|
||||
my ($line, $condition, $failref, $filename) = @_;
|
||||
$filename ||= '/tmp/os-release.log';
|
||||
if ($condition) {
|
||||
$line = "${line} - SUCCEEDED\n";
|
||||
}
|
||||
@ -1078,8 +1081,7 @@ sub rec_log {
|
||||
push @$failref, $line;
|
||||
$line = "${line} - FAILED\n";
|
||||
}
|
||||
my $file = "/tmp/os-release.log";
|
||||
script_run "echo \"$line\" >> $file";
|
||||
script_run "echo \"$line\" >> $filename";
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,44 +10,21 @@ use utils;
|
||||
# Before branching, the parenthesis contain the word "Rawhide".
|
||||
|
||||
sub run {
|
||||
# First, let us define some variables needed to run the program.
|
||||
my $self = shift;
|
||||
# The file to be checked
|
||||
my $filename = '/etc/fedora-release';
|
||||
# Version as defined in the RAWREL and VERSION variables. We need both values, because the release
|
||||
# string can be a combination of those two.
|
||||
# Version as defined in the VERSION variable.
|
||||
my $version = get_var('VERSION');
|
||||
my $raw_version = get_var('RAWREL');
|
||||
|
||||
# Read the content of the file to compare.
|
||||
my $line = script_output('cat /etc/fedora-release');
|
||||
chomp $line;
|
||||
|
||||
# Create a spelt form of the version number.
|
||||
my $speltnum = "undefined";
|
||||
my $speltnum = spell_version_number($version);
|
||||
|
||||
if ($version eq "Rawhide") {
|
||||
$speltnum = "Rawhide";
|
||||
$version = $raw_version;
|
||||
}
|
||||
else {
|
||||
$speltnum = spell_version_number($version);
|
||||
# this is the Rawhide release number, which we expect to see.
|
||||
$version = get_var('RAWREL');
|
||||
}
|
||||
|
||||
# Create the ideal content of the release file
|
||||
# Create the expected content of the release file
|
||||
# and compare it with its real counterpart.
|
||||
# Everything is ok, when that matches, otherwise
|
||||
# the script fails.
|
||||
my $releasenote = "Fedora release $version ($speltnum)";
|
||||
my $log = "fedora-release.log";
|
||||
if ($releasenote eq $line) {
|
||||
rec_log $log, "The content in /etc/fedora-release should be $releasenote and is $line: PASSED";
|
||||
upload_logs "/tmp/fedora-release.log", failok=> 1;
|
||||
}
|
||||
else {
|
||||
rec_log $log, "The content in /etc/fedora-release should be $releasenote but is $line: FAILED";
|
||||
upload_logs "/tmp/fedora-release.log", failok=> 1;
|
||||
die "The content in /etc/fedora-release should be $releasenote but is $line.";
|
||||
}
|
||||
my $expected = "Fedora release $version ($speltnum)";
|
||||
validate_script_output 'cat /etc/fedora-release', sub { $_ eq $expected };
|
||||
}
|
||||
|
||||
sub test_flags {
|
||||
|
@ -36,6 +36,7 @@ sub run {
|
||||
my $id = get_var("DISTRI"); # Should be "fedora"
|
||||
my $name = ucfirst($id);
|
||||
my $version_id = get_var("VERSION"); # Should be the version number or Rawhide.
|
||||
my $varstr = spell_version_number($version_id);
|
||||
my $target = lc($version_id);
|
||||
if ($version_id eq "Rawhide") {
|
||||
$version_id = get_var("RAWREL");
|
||||
@ -48,8 +49,6 @@ sub run {
|
||||
# Everything image.
|
||||
my $variant_id = "";
|
||||
my $variant = "generic";
|
||||
my $varstr = "Rawhide";
|
||||
$varstr = spell_version_number($version_id) unless ($target eq 'rawhide');
|
||||
|
||||
# now replace the values with the correct ones if we are testing a
|
||||
# subvariant that maps to a known variant
|
||||
|
Loading…
Reference in New Issue
Block a user