Skip to content

Commit 2acf235

Browse files
test: Add test for GC-ing shared Type1 entries
Add a test to make sure we do not GC shared Type1 entries when they're still referenced Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 77481f4 commit 2acf235

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

tmt/tests/booted/test-composefs-gc.nu

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ def second_boot [] {
5353

5454
let path = cat /var/large-file-marker-objpath
5555

56-
echo "\$path"
57-
echo $path
58-
5956
assert ($path | path exists)
6057

6158
# Create another image with a different initrd so we can test kernel + initrd cleanup
@@ -107,14 +104,12 @@ def third_boot [] {
107104
let boot_dir = if ($bootloader | str downcase) == "systemd" {
108105
# TODO: Some concrete API for this would be great
109106
mkdir /var/tmp/efi
110-
mount /dev/vda2 /var/tmp/efi
107+
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
111108
"/var/tmp/efi/EFI/Linux"
112109
} else {
113110
"/sysroot/boot"
114111
}
115112

116-
print $"bootdir ($boot_dir)"
117-
118113
assert ($"($boot_dir)/($dir_prefix)($booted_verity)" | path exists)
119114

120115
# This is for the rollback, but since the rollback and the very
@@ -144,13 +139,38 @@ def fourth_boot [] {
144139
if ($bootloader | str downcase) == "systemd" {
145140
# TODO: Some concrete API for this would be great
146141
mkdir /var/tmp/efi
147-
mount /dev/vda2 /var/tmp/efi
142+
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
148143
}
149144

150145
assert equal $booted.image.image "localhost/bootc-final"
151146
assert (not ((cat /var/to-be-deleted-kernel | path exists)))
152147

153-
tap ok
148+
# Now we want to test preservation of shared BLS binaries
149+
# This takes at least 3 reboots
150+
1..3 | each { |i|
151+
echo $"
152+
FROM localhost/bootc-derived-initrd
153+
RUN echo '($i)' > /usr/share/($i)
154+
" | podman build -t $"localhost/bootc-shared-($i)" . -f -
155+
}
156+
157+
bootc switch --transport containers-storage localhost/bootc-shared-1
158+
159+
tmt-reboot
160+
}
161+
162+
def fifth_boot [i: int] {
163+
assert equal $booted.image.image $"localhost/bootc-shared-($i)"
164+
165+
# Just this being booted counts as success
166+
if $i == 3 {
167+
tap ok
168+
return
169+
}
170+
171+
bootc switch --transport containers-storage $"localhost/bootc-shared-($i + 1)"
172+
173+
tmt-reboot
154174
}
155175

156176
def main [] {
@@ -159,6 +179,9 @@ def main [] {
159179
"1" => second_boot,
160180
"2" => third_boot,
161181
"3" => fourth_boot,
182+
"4" => { fifth_boot 1 },
183+
"5" => { fifth_boot 2 },
184+
"6" => { fifth_boot 3 },
162185
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
163186
}
164187
}

0 commit comments

Comments
 (0)