From f0c7803595b0769e56ffe132559fc539c79bad77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sun, 6 Sep 2026 04:31:10 -0300 Subject: [PATCH] test(xCAT-test): cover the declaration of the loader build tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com> --- .../xcat_server_grub_mkimage_dependency.t | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 xCAT-test/unit/xcat_server_grub_mkimage_dependency.t diff --git a/xCAT-test/unit/xcat_server_grub_mkimage_dependency.t b/xCAT-test/unit/xcat_server_grub_mkimage_dependency.t new file mode 100644 index 000000000..a130a0f3a --- /dev/null +++ b/xCAT-test/unit/xcat_server_grub_mkimage_dependency.t @@ -0,0 +1,39 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use File::Spec; +use FindBin; +use Test::More; + +# copycd builds the riscv64 boot loader by running grub-mkimage, and the plugin that runs it ships +# in xcat-server. Nothing declared the package that provides that command, so a management or +# service node installed without it copies riscv64 media and then produces no loader at all, while +# DHCP keeps pointing every riscv64 node at the path where the loader should be. +# +# grub-common provides /usr/bin/grub-mkimage on every supported Ubuntu release. That the plugin +# runs grub-mkimage is shown by ubuntu_copycd_grub2_loader.t, which drives it through a stub. + +my $repo_root = File::Spec->rel2abs( File::Spec->catdir( $FindBin::Bin, '..', '..' ) ); + +sub depends_of { + my ($package) = @_; + my $file = File::Spec->catfile( $repo_root, $package, 'debian', 'control' ); + open( my $fh, '<', $file ) or die "Unable to read $file: $!"; + my $control = do { local $/; <$fh> }; + close($fh); + my ($depends) = $control =~ /^Depends:\s*(.*)$/m; + return [ split( /\s*,\s*/, $depends // '' ) ]; +} + +my $server = depends_of('xCAT-server'); +ok( scalar( grep { /^grub-common\b/ } @{$server} ), + 'xcat-server depends on the package that provides grub-mkimage' ); + +# The plugin runs there, so the metapackages inherit it and must not carry their own copy. +foreach my $package (qw(xCAT xCATsn)) { + is_deeply( [ grep { /^grub-common\b/ } @{ depends_of($package) } ], [], + "$package leaves the dependency with the package that runs the command" ); +} + +done_testing();