diff --git a/xCAT-test/unit/xcattest_os_selection.t b/xCAT-test/unit/xcattest_os_selection.t index eed16fc128..9b55327cac 100644 --- a/xCAT-test/unit/xcattest_os_selection.t +++ b/xCAT-test/unit/xcattest_os_selection.t @@ -60,6 +60,56 @@ is(xCAT::Test::OS::current_os(a_system('lsb-release' => "DISTRIB_ID=Ubuntu\n")), 'Ubuntu is named from lsb-release'); is(xCAT::Test::OS::current_os(a_system('os-release' => qq{ID="sles"\nVERSION="15-SP6"\n})), 'sles', 'SLES is named from os-release'); + +# openSUSE. /etc/os-release carries ID="opensuse-leap" and no "sles" anywhere, and Leap ships +# none of redhat-release, lsb-release or SuSE-release, so current_os fell through its os-release +# arm and returned undef. xcattest then warned "Use of uninitialized value $currentos" four +# times per case and rejected every one: "Test case reg_linux_diskfull_installation_flat has an +# invalid OS option - Linux / There is no valid case to run". 328 of the shipped cases declare +# os:Linux, so an openSUSE management node ran none of them, and the two cases were skipped +# rather than failed -- no result at all. +# +# Measured 2026-10-24 on xcat20-mn, an openSUSE Leap 15.6 management node: current_os answered +# UNDEF, /etc/os-release holds ID="opensuse-leap" and VERSION_ID="15.6", and none of the three +# fallback files exist. +# +# openSUSE answers with the SLE family rather than a name of its own, which was decided on +# 2026-09-18 for the same bug against the routine xcattest carried before xCAT::Test::OS +# existed. Leap and SLE of the same major share a package set, sles.pm claims leap15, and +# xcat.org publishes the Leap dependencies under sles15. It also lets the 18 cases written +# os:sles select a Leap node, which a separate name would not. +my $LEAP_OS_RELEASE = <<'REL'; +NAME="openSUSE Leap" +VERSION="15.6" +ID="opensuse-leap" +ID_LIKE="suse opensuse" +VERSION_ID="15.6" +PRETTY_NAME="openSUSE Leap 15.6" +REL + +is(xCAT::Test::OS::current_os(a_system('os-release' => $LEAP_OS_RELEASE)), 'sles', + 'openSUSE Leap is the SLE family whose package set it shares'); + +my $leap16 = $LEAP_OS_RELEASE; +$leap16 =~ s/15\.6/16.0/g; +is(xCAT::Test::OS::current_os(a_system('os-release' => $leap16)), 'sles', + 'at any Leap version, so a new release needs no change here'); + +# Leap 42.3, which the sles12 cell runs, spells its ID without the -leap suffix. +my $leap42 = $LEAP_OS_RELEASE; +$leap42 =~ s/ID="opensuse-leap"/ID="opensuse"/; +$leap42 =~ s/15\.6/42.3/g; +is(xCAT::Test::OS::current_os(a_system('os-release' => $leap42)), 'sles', + 'the older spelling, ID="opensuse", is recognised too'); + +is(xCAT::Test::OS::current_os( + a_system('os-release' => qq{NAME="openSUSE Tumbleweed"\nID="opensuse-tumbleweed"\n})), + 'sles', 'Tumbleweed answers rather than falling through silently'); + +# The thing that actually broke: an empty answer matches no os: restriction at all. +my @linux = xCAT::Test::OS::linux_aliases(); +ok(scalar(grep { xCAT::Test::OS::current_os(a_system('os-release' => $LEAP_OS_RELEASE)) =~ /$_/i } @linux), + 'an openSUSE Leap management node matches an os:Linux case'); is(xCAT::Test::OS::current_os(a_system()), 'aix', 'a system with none of the release files is aix, as before');