From 75c874ebadd4aac99d92b142ebdd60789b335f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:15:59 -0300 Subject: [PATCH] test(ubuntu): cover a partitionfile layout on the partitionfile disk A layout without a match that follows a disk file gets a match on the disk the file selects, resolved when it is a link, and a use_gap layout that follows a disk file stops the install. A layout with its own match and a layout without a disk entry are kept as written. --- .../native/ubuntu_subiquity_install_disk.t | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/xCAT-test/native/ubuntu_subiquity_install_disk.t b/xCAT-test/native/ubuntu_subiquity_install_disk.t index dbcf016365..1131c30629 100644 --- a/xCAT-test/native/ubuntu_subiquity_install_disk.t +++ b/xCAT-test/native/ubuntu_subiquity_install_disk.t @@ -57,7 +57,8 @@ my $writer = "#!/bin/sh\ncat >/tmp/partitionfile <<'EOF'\n${layout}EOF\n"; my $diskscript = "#!/bin/sh\necho /dev/disk/by-id/scripted >/tmp/xcat.install_disk\n"; # Each case: label, the partitionfile entries as [prefix, file contents], and the disk the storage -# config must name, or undef when the install must stop before a storage config exists. +# config must name, or undef when the install must stop before a storage config exists. A fourth +# value is the whole storage config of a layout. my @cases = ( ['no partitionfile', [], '/dev/sdz'], ['a disk file', [['d:', "/dev/disk/by-id/nvme-pinned /dev/sdb\n"]], '/dev/disk/by-id/nvme-pinned'], @@ -80,9 +81,19 @@ my @cases = ( ['a layout file with an empty storage section', [['', "storage:\n"]], undef], ['a layout file with a null storage section', [['', "storage: null\n"]], undef], ['a layout file that starts a YAML document', [['', "---\n$layout"]], '/dev/disk/by-id/custom'], + ['a layout without a match after a disk file', [['', "storage:\n layout:\n name: direct\n"], + ['d:', "/dev/disk/by-id/nvme-link\n"]], undef, + "storage:\n layout:\n name: direct\n match:\n path: /dev/nvme7n1\n"], + ['a layout with its own match after a disk file', [['', "storage:\n layout:\n name: direct\n match:\n ssd: true\n"], + ['d:', "/dev/disk/by-id/nvme-link\n"]], undef, + "storage:\n layout:\n name: direct\n match:\n ssd: true\n"], + ['a layout without a match and no disk entry', [['', "storage:\n layout:\n name: direct\n"]], undef, + "storage:\n layout:\n name: direct\n"], + ['a use_gap layout after a disk file', [['', "storage:\n layout:\n name: direct\n mode: use_gap\n"], + ['d:', "/dev/disk/by-id/nvme-link\n"]], undef], ); for my $case (@cases) { - my ($label, $entries, $expected) = @$case; + my ($label, $entries, $expected, $expected_layout) = @$case; subtest $label => sub { my $part = render_part('pre.ubuntu.subiquity', qr/(^base64decode\(\)\n.*^exit 0$)/ms, @$entries); ok($part, 'the rendered script defines base64decode before the partitioning') or return; @@ -90,6 +101,11 @@ for my $case (@cases) { write_text("$root/part.sh", $part); my ($rc, $output) = sandbox_run($root, {read_only => {"$root/efi" => '/sys/firmware/efi', "$root/by-id" => '/dev/disk/by-id', "$root/nvme7n1" => '/dev/nvme7n1'}}, $shell, '/fixture/part.sh'); + if (defined $expected_layout) { + is($rc, 0, "the partitioning runs under $shell") or diag($output); + is(storage_config($root), $expected_layout, 'the storage config is the expected layout'); + return; + } if (!defined $expected) { isnt($rc, 0, "the pre-install script fails under $shell"); ok(!-e "$root/tmp/partitionfile", 'and leaves no storage config to inject');