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.
This commit is contained in:
Colin Walters 2025-03-21 08:11:50 -04:00
parent ba2f9a93b2
commit 75f2f7d50d

View File

@ -33,6 +33,8 @@ assert_not_journal_grep() {
fi
}
block_size=$(stat --file-system /boot -c '%s')
# make two fake ostree commits with modified kernels of about the same size
cd /root
mkdir -p rootfs/usr/lib/modules/`uname -r`
@ -53,9 +55,8 @@ assert_bootfs_has_n_bootcsum_dirs() {
}
consume_bootfs_space() {
local free_blocks block_size
local free_blocks
free_blocks=${1:-$(stat --file-system /boot -c '%a')}
block_size=$(stat --file-system /boot -c '%s')
# leave 1 block free
unshare -m bash -c \
"mount -o rw,remount /boot && \
@ -173,11 +174,13 @@ assert_journal_grep "$cursor" "updating bootloader in two steps"
unconsume_bootfs_space
mkdir -p rootfs/usr/lib/modules/`uname -r`/dtb
(set +x; for i in {1..10000}; do echo -n x > rootfs/usr/lib/modules/`uname -r`/dtb/$i; done)
dtbcount=10000
(set +x; for i in {1..${dtbcount}}; do echo -n x > rootfs/usr/lib/modules/`uname -r`/dtb/$i; done)
ostree commit --base modkernel1 -P --tree=dir=rootfs -b modkernel3
# a naive estimator would think all those files just take 10000 bytes
consume_bootfs_space "$((free_blocks_kernel_and_initrd - 10000))"
dtb_naive_space=$((${dtbcount} / ${block_size}))
consume_bootfs_space "$((free_blocks_kernel_and_initrd - ${dtb_naive_space}))"
rpm-ostree rebase :modkernel3
cursor=$(journal_cursor)