From 9d000957eb46de020dbd78d8ddbc77a032e9d0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Mon, 24 Jun 2024 20:12:11 +0200 Subject: [PATCH] fixup! test(nix): add basic functionality testing infra --- checks/default.nix | 1 + checks/nested.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 checks/nested.sh diff --git a/checks/default.nix b/checks/default.nix index 5a85d1e6..b014687b 100644 --- a/checks/default.nix +++ b/checks/default.nix @@ -29,6 +29,7 @@ let # Add any packages you need inside test scripts here environment.systemPackages = with pkgs; [ + f3 genpass keyutils ]; diff --git a/checks/nested.sh b/checks/nested.sh new file mode 100755 index 00000000..20cb58a3 --- /dev/null +++ b/checks/nested.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euxo pipefail + +blkdev="/dev/vdb" +mnt1=$(mktemp -d) +mnt2=$(mktemp -d) +pw=$(genpass) +uuid=$(uuidgen) + +# link user and session keyrings so that the key can be found by the kernel +keyctl link @u @s + +echo "$pw" | bcachefs format \ + --verbose \ + --encrypted \ + --uuid "$uuid" \ + --fs_label test-fs \ + "$blkdev" + +udevadm settle + +echo "$pw" | bcachefs mount -v "UUID=$uuid" "$mnt1" + +fallocate --length 2G "$mnt1/fs.img" + +bcachefs format \ + --verbose \ + "$mnt1/fs.img" + +loopdev=$(losetup --find --show "$mnt1/fs.img") + +udevadm settle + +mount "$loopdev" "$mnt2" + +f3write "$mnt1" +f3write "$mnt2" + +f3read "$mnt1" +f3read "$mnt2"