Skip to content

Commit 75f2f7d

Browse files
committed
tests/auto-prune: Don't go negative
- First I kept wondering what the magic of 10000 was here before looking above and noticing it matched the number of dtb files. Make a shared variable so the connection is more obvious - Next, I *believe* the intention of this test was to test the edge case of bytes vs blocks, but we ended up subtracting blocks and I think recent FCOS images happened to get small enough that we started going negative here. Fix this to convert the bytes into blocks.
1 parent ba2f9a9 commit 75f2f7d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/kolainst/destructive/auto-prune.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ assert_not_journal_grep() {
3333
fi
3434
}
3535

36+
block_size=$(stat --file-system /boot -c '%s')
37+
3638
# make two fake ostree commits with modified kernels of about the same size
3739
cd /root
3840
mkdir -p rootfs/usr/lib/modules/`uname -r`
@@ -53,9 +55,8 @@ assert_bootfs_has_n_bootcsum_dirs() {
5355
}
5456

5557
consume_bootfs_space() {
56-
local free_blocks block_size
58+
local free_blocks
5759
free_blocks=${1:-$(stat --file-system /boot -c '%a')}
58-
block_size=$(stat --file-system /boot -c '%s')
5960
# leave 1 block free
6061
unshare -m bash -c \
6162
"mount -o rw,remount /boot && \
@@ -173,11 +174,13 @@ assert_journal_grep "$cursor" "updating bootloader in two steps"
173174
unconsume_bootfs_space
174175

175176
mkdir -p rootfs/usr/lib/modules/`uname -r`/dtb
176-
(set +x; for i in {1..10000}; do echo -n x > rootfs/usr/lib/modules/`uname -r`/dtb/$i; done)
177+
dtbcount=10000
178+
(set +x; for i in {1..${dtbcount}}; do echo -n x > rootfs/usr/lib/modules/`uname -r`/dtb/$i; done)
177179
ostree commit --base modkernel1 -P --tree=dir=rootfs -b modkernel3
178180

179181
# a naive estimator would think all those files just take 10000 bytes
180-
consume_bootfs_space "$((free_blocks_kernel_and_initrd - 10000))"
182+
dtb_naive_space=$((${dtbcount} / ${block_size}))
183+
consume_bootfs_space "$((free_blocks_kernel_and_initrd - ${dtb_naive_space}))"
181184

182185
rpm-ostree rebase :modkernel3
183186
cursor=$(journal_cursor)

0 commit comments

Comments
 (0)