@@ -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
@@ -125,11 +120,27 @@ def third_boot [] {
125120
126121 echo $" ($boot_dir )/($dir_prefix )(cat /var/first-verity )" | save /var/to-be-deleted-kernel
127122
123+ # Switching and rebooting here won't delete the old kernel because we still
124+ # have it as the rollback deployment
125+ echo "
126+ FROM localhost/bootc-derived-initrd
127+ RUN echo 'another file' > /usr/share/another-one
128+ " | podman build - t localhost/bootc-prefinal . - f -
129+
130+
131+ bootc switch -- transport containers-storage localhost/bootc-prefinal
132+
133+ tmt-reboot
134+ }
135+
136+ def fourth_boot [] {
137+ assert equal $booted.image.image " localhost/bootc-prefinal"
138+
128139 # Now we create a new image derived from the current kernel + initrd
129140 # Switching to this and rebooting should remove the old kernel + initrd
130141 echo "
131142 FROM localhost/bootc-derived-initrd
132- RUN echo 'another file' > /usr/share/another-one
143+ RUN echo 'another file 1 ' > /usr/share/another-one-1
133144 " | podman build - t localhost/bootc-final . - f -
134145
135146
@@ -138,19 +149,44 @@ def third_boot [] {
138149 tmt-reboot
139150}
140151
141- def fourth_boot [] {
152+ def fifth_boot [] {
142153 let bootloader = (bootc status -- json | from json ).status.booted.composefs.bootloader
143154
144155 if ($bootloader | str downcase ) == " systemd" {
145156 # TODO: Some concrete API for this would be great
146157 mkdir /var/tmp/efi
147- mount /dev/vda2 /var/tmp/efi
158+ mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
148159 }
149160
150161 assert equal $booted.image.image " localhost/bootc-final"
151162 assert (not ((cat /var/to-be-deleted-kernel | path exists )))
152163
153- tap ok
164+ # Now we want to test preservation of shared BLS binaries
165+ # This takes at least 3 reboots
166+ 1 .. 3 | each { |i |
167+ echo $"
168+ FROM localhost/bootc-derived-initrd
169+ RUN echo '($i )' > /usr/share/($i )
170+ " | podman build - t $" localhost/bootc-shared-($i )" . - f -
171+ }
172+
173+ bootc switch -- transport containers-storage localhost/bootc-shared-1
174+
175+ tmt-reboot
176+ }
177+
178+ def sixth_boot [i : int ] {
179+ assert equal $booted.image.image $" localhost/bootc-shared-($i )"
180+
181+ # Just this being booted counts as success
182+ if $i == 3 {
183+ tap ok
184+ return
185+ }
186+
187+ bootc switch -- transport containers-storage $" localhost/bootc-shared-($i + 1 )"
188+
189+ tmt-reboot
154190}
155191
156192def main [] {
@@ -159,6 +195,10 @@ def main [] {
159195 " 1" => second_boot ,
160196 " 2" => third_boot ,
161197 " 3" => fourth_boot ,
198+ " 4" => fifth_boot ,
199+ " 5" => { sixth_boot 1 },
200+ " 6" => { sixth_boot 2 },
201+ " 7" => { sixth_boot 3 },
162202 $o => { error make { msg : $" Invalid TMT_REBOOT_COUNT ($o )" } },
163203 }
164204}
0 commit comments