From e469ff08cf5d6d6cef865233cfd154415d8b233a Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 22 Oct 2026 17:21:08 -0300 Subject: [PATCH] test(xcat-core): catch a netboot handler that is not executable dracut dispatches the network root in 45net-lib/netroot.sh with handler=$(command -v "${netroot%%:*}root"). command -v skips a file without the execute bit, so an xcatroot shipped mode 0644 makes the node print "No handler for netroot type 'xcat'" and power off in its initramfs. genimage copies the file with the mode it reads from the share tree, and dracut's inst_script keeps that mode, so the mode in the repository is what reaches the node. The new test asserts the execute bit on every xcatroot under xCAT-server/share/xcat/netboot and xCAT-genesis-base. It fails on the current tree, on xCAT-server/share/xcat/netboot/rh/dracut_105/stateless/xcatroot. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/netboot_xcatroot_executable.t | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 xCAT-test/unit/netboot_xcatroot_executable.t diff --git a/xCAT-test/unit/netboot_xcatroot_executable.t b/xCAT-test/unit/netboot_xcatroot_executable.t new file mode 100644 index 0000000000..102619e9da --- /dev/null +++ b/xCAT-test/unit/netboot_xcatroot_executable.t @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +# Every xcatroot xCAT ships must carry the execute bit. +# +# dracut dispatches the network root through 45net-lib/netroot.sh, which does +# handler=$(command -v "${netroot%%:*}root"). command -v skips a file without +# the execute bit, so a non-executable xcatroot makes netroot.sh print +# "No handler for netroot type 'xcat'" and the node powers off in its +# initramfs. genimage copies the file with the mode it finds in the share tree +# (chmod($perm & 07777)), and dracut's inst_script keeps that mode, so the mode +# in the repository is what reaches the initramfs. +use strict; +use warnings; + +use File::Basename qw(dirname); +use File::Find qw(find); +use File::Spec; +use Test::More; + +my $root = File::Spec->rel2abs(File::Spec->catdir(dirname(__FILE__), '..', '..')); + +my @trees = grep { -d } map { File::Spec->catdir($root, $_) } + ('xCAT-server/share/xcat/netboot', 'xCAT-genesis-base'); + +die "no netboot tree under $root" unless @trees; + +my @handlers; +find(sub { push @handlers, $File::Find::name if $_ eq 'xcatroot' && -f $_ }, @trees); + +# A positive control: an empty list would pass every assertion below. +cmp_ok(scalar(@handlers), '>=', 5, scalar(@handlers) . ' xcatroot handlers found'); + +for my $handler (sort @handlers) { + ok(-x $handler, File::Spec->abs2rel($handler, $root) . ' is executable'); +} + +done_testing();