diff --git a/tests/collect_web_data.pm b/tests/collect_web_data.pm index f1c3c501..a8d7dc34 100644 --- a/tests/collect_web_data.pm +++ b/tests/collect_web_data.pm @@ -6,14 +6,8 @@ use utils; sub run { my $self = shift; - # Let's get the $target release version. Most of the time, - # the version will point to a future release. On Rawhide, - # this will not be a number, so we need to convert it - # to a number. - my $target = get_var('VERSION'); - if (get_var('VERSION') eq 'Rawhide') { - $target = get_var('RAWREL'); - } + # Let's get the $target release version. + my $target = get_release_number(); # The $current release version is the last stable release # around that we want to compare. my $current = get_var('CURRREL'); diff --git a/tests/os_release.pm b/tests/os_release.pm index b78a031f..bd2d0f5a 100644 --- a/tests/os_release.pm +++ b/tests/os_release.pm @@ -65,27 +65,39 @@ sub get_schedule_eol { } # The EOL date is provided as an epoch, so just return it. return $eol; - } sub get_current_date { # This returns the current date in as the epoch # which we need to see if the EOL is correctly set in the future. my $time = localtime; - my $date = $time->strftime('%Y-%m-%d'); - $date = date_to_epoch($date); - return $date; + my %dates; + $dates{'date'} = $time->strftime('%Y-%m-%d'); + $dates{'epoch'} = date_to_epoch($date); + return \%dates; } - sub check_eol_in_year { # This will take the EOL date from the /etc/os-release # file and it will check that it is at least a year in - # the future (when tested on Rawhide, Branched, or Beta) - # or that it is at least a year in the future compared - # to the previously released version (when tested on a released - # version) - my $eol = shift; + # the future (when tested on non published ISOs). + # Returns true if successful. + my $tested = shift; + $tested = date_to_epoch($tested); + my $dates = get_current_date(); + my $current = $dates->{'epoch'} + # The EOL in the os-release.pm must be at least a year + # in the future, so we calculate the epoch difference + # between $tested and $current. + # An epoch year should be + # 1 * 60 (min) *60 (hour) *24 (day) *365 (year) + my $year = 1*60*60*24*365; + my $delta = $tested - $current; + my $bool = 1; + if ($delta < $year) { + $bool = 0; + } + return $bool; } sub run { @@ -207,8 +219,6 @@ sub run { } } - # Check for the correct support day (a.k.a. EOL) - #Now. we can start testing the real values from the installed system. my @fails = (); my $failref = \@fails; @@ -259,6 +269,13 @@ sub run { print "VARIANT_ID was not tested because the compose is not Workstation or Server Edition.\n"; } + + # Test for EOL date in the distant future. + my $os_release_eol = $content{'SUPPORT_END'}; + my $result = check_eol_in_year($os_release_eol); + my $current = get_current_date(); + rec_log("The SUPPORT_END date is $current->{epoch} which is at least a year ahead in time", $result == 1, $failref); + # 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";