2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-26 01:34:05 +00:00

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>
This commit is contained in:
Daniel Hilst
2026-09-11 21:09:15 -03:00
parent 4a8877618a
commit 637d953d5a
+8 -2
View File
@@ -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 <<EOF >\/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;