From a1aa237c6461f191ef847a0c54bcf7190b7e7204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:30:32 -0300 Subject: [PATCH] test(xcatd): cover the version release comparison Checks that xCAT::Version->Release strips the git-commit decoration, that the same release from different snapshots compares equal, and that a real release difference is still reported. That distinction is what lets xcatd separate a real version mismatch from a same-release build difference. --- xCAT-test/unit/version_release.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 xCAT-test/unit/version_release.t diff --git a/xCAT-test/unit/version_release.t b/xCAT-test/unit/version_release.t new file mode 100644 index 000000000..9dc2e44fd --- /dev/null +++ b/xCAT-test/unit/version_release.t @@ -0,0 +1,32 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use FindBin; +use Test::More; + +use lib "$FindBin::Bin/../../perl-xCAT"; +require xCAT::Version; + +# xcatd tells a real version mismatch (different release) from a same-release +# build difference by comparing xCAT::Version->Release. Release must strip the +# build-specific decoration the build stamps onto the version string, so nodes +# at the same release built from different snapshots are not reported as a +# version mismatch. + +my $va = "Version 2.18.2 (git commit aaaaaaaaaaaaaaaa)"; +my $vb = "Version 2.18.2 (git commit bbbbbbbbbbbbbbbb)"; +my $vc = "Version 2.19.0 (git commit cccccccccccccccc)"; + +is(xCAT::Version->Release($va), "Version 2.18.2", + 'Release strips the git-commit decoration'); +is(xCAT::Version->Release($va), xCAT::Version->Release($vb), + 'the same release built from different snapshots compares equal'); +isnt(xCAT::Version->Release($va), xCAT::Version->Release($vc), + 'a real release difference is still reported'); + +# A string with no decoration is returned unchanged. +is(xCAT::Version->Release("Version 2.18.2"), "Version 2.18.2", + 'a version without decoration is left as is'); + +done_testing();