Skip to content

Commit

Permalink
ktest: use overlays to store arch-specific bcachefs-tools build
Browse files Browse the repository at this point in the history
when running tests, eg test1 on arch 1, and then on arch 2,
the whole bcachefs-tools package needs to be rebuilt:
all binaries of arch 1 need to be erased, and recompiled for arch 2
when going back to arch 1, it happens again

This patch fixes the issue by applying a arch-specific overlay,
so bcachefs-tools doesn't need a full rebuild every time.
The overlay is mounted via fuse-overlay.
If this isn't available, it will fall back to rsync,
causing a larger waste of disk space,
and not-applied-immediately git commits.

Signed-of-by: jpsollie <[email protected]>
  • Loading branch information
jpsollie committed Nov 19, 2023
1 parent 651102e commit dda140e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ktest_exit()
fi

[[ -n $ktest_tmp ]] && rm -rf "$ktest_tmp"
#umount overlayfs of bcachefs-tools if needed
[[ -n $ktest_tmp && $(grep bcachefs-tools-$ktest_arch /proc/mounts) ]] && umount $(grep bcachefs-tools-$ktest_arch /proc/mounts | cut -d' ' -f 2)
true
}

Expand Down
22 changes: 19 additions & 3 deletions tests/bcachefs/bcachefs-test-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,32 @@
. $(dirname $(readlink -e "${BASH_SOURCE[0]}"))/../test-libs.sh
bch_loc=$(dirname $(readlink -e "${BASH_SOURCE[0]}"))/bcachefs-tools

require-git http://evilpiepirate.org/git/bcachefs-tools.git
if [[ ! -f "${bch_loc}/.last_arch_for_compile" || "$(cat ${bch_loc}/.last_arch_for_compile)" != $ktest_arch ]]; then
declare -A ov_dirs=(["tmp"]="${bch_loc}/../.tmp-bcachefs-tools-overlay" \
["diff"]="${bch_loc}/../.bcachefs-tools-overlay-${ktest_arch}" \
["merge"]="${bch_loc}/../bcachefs-tools-${ktest_arch}")

for dir_overlay in ${ov_dirs[@]}; do
if [[ ! -d ${dir_overlay} ]]; then mkdir -p ${dir_overlay}; fi
done

if [[ $(which fuse-overlayfs) && ! $(grep bcachefs-tools-$ktest_arch /proc/mounts) ]]; then
fuse-overlayfs -o lowerdir=${bch_loc},upperdir=${ov_dirs["diff"]},workdir=${ov_dirs["tmp"]} ${ov_dirs["merge"]}
elif [[ ! $(grep bcachefs-tools-$ktest_arch /proc/mounts) ]]; then
rsync -av ${bch_loc}/ ${ov_dirs["merge"]}/
fi

bch_loc=$(dirname $(readlink -e "${BASH_SOURCE[0]}"))/bcachefs-tools-${ktest_arch}

if [[ ! -f "${bch_loc}/.last_arch_for_compile" || "$(cat ${bch_loc}/.last_arch_for_compile)" != ${ktest_arch} ]]; then
make -C ${bch_loc} clean >/dev/null 2>&1;
rm -rf "${bch_loc}/rust-src/target/*";
find ${bch_loc} -name "*.o" -exec rm {} \;
find ${bch_loc} -name "*.a" -exec rm {} \;
echo $ktest_arch > ${bch_loc}/.last_arch_for_compile
fi
require-make bcachefs-tools

require-git http://evilpiepirate.org/git/bcachefs-tools.git
require-make bcachefs-tools-${ktest_arch}
require-kernel-config BCACHEFS_FS

if [[ ! -v NO_BCACHEFS_DEBUG ]]; then
Expand Down

0 comments on commit dda140e

Please sign in to comment.