From 637d953d5a6e475804ccd7d9194dae7f9a1bbe34 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:09:15 -0300 Subject: [PATCH] test(xcat-core): the storage harness counts two partitioning branches by hand ubuntu_subiquity_storage.t rewrites every /tmp/partitionfile redirect in the extracted block into a scratch tree, and bails out unless it rewrote exactly two. The number is the count of firmware branches the script had when the harness was written, so adding a branch stops the test rather than covering it. The guard now counts the branches it found and requires one redirect each, and fails separately if any path escaped the sandbox. It still bails out on a block with fewer than two branches, which would mean the extraction stopped matching. Still red on the PReP case of the previous commit: the block does not ask uname for the machine architecture yet. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/ubuntu_subiquity_storage.t | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xCAT-test/unit/ubuntu_subiquity_storage.t b/xCAT-test/unit/ubuntu_subiquity_storage.t index a6983d543..a41f1ac4a 100644 --- a/xCAT-test/unit/ubuntu_subiquity_storage.t +++ b/xCAT-test/unit/ubuntu_subiquity_storage.t @@ -41,9 +41,15 @@ BAIL_OUT('the block no longer asks uname for the machine architecture') my $sandbox = File::Temp::tempdir( CLEANUP => 1 ); my $partfile = File::Spec->catfile( $sandbox, 'partitionfile' ); +# One redirect per firmware branch. Counting the branches rather than naming a number +# keeps the guard true when a branch is added, and still fails loudly if a redirect +# escapes the sandbox. +my $branches = () = $storage_block =~ /^\s*cat <\/tmp\/partitionfile$/mg; my $rewrites = ( $storage_block =~ s{/tmp/partitionfile}{$partfile}g ); -BAIL_OUT("expected two partition-file redirects to sandbox, rewrote $rewrites") - unless $rewrites == 2; +BAIL_OUT("the block writes the partition file in $branches places and $rewrites were rewritten") + unless $branches >= 2 && $rewrites == $branches; +BAIL_OUT('a partition-file path escaped the sandbox') + if $storage_block =~ m{/tmp/partitionfile}; my %YAML_FOR;