Skip to content

Instantly share code, notes, and snippets.

@Panky-codes
Last active April 23, 2024 13:21
Show Gist options
  • Save Panky-codes/09f8f470b5c48a317630da7714d0a495 to your computer and use it in GitHub Desktop.
Save Panky-codes/09f8f470b5c48a317630da7714d0a495 to your computer and use it in GitHub Desktop.
nix config for running custom xfstests with custom xfsprogs
# To get a nix shell with this environment, run:
# $ nix-shell -A xfs_65 xfstests.nix
# $ [nix-shell:~]# xfstests-check -s <section-name> <testpath>
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
packages = rec {
xfsprog = pkgs.xfsprogs.overrideDerivation (oldAttrs: {
version = "6.7.0";
src = fetchurl {
url = "mirror://kernel/linux/utils/fs/xfs/xfsprogs/xfsprogs-6.7.0.tar.xz";
hash = "sha256-510eAShT4RWXQRz8uA4myBGIHPDKA3FehStClGzGHh8=";
};
});
xfstest = pkgs.xfstests.overrideDerivation (oldAttrs: {
version = "2024.04.14";
src = fetchgit {
url = "https://github.com/Panky-codes/xfstests.git";
rev = "v2024.04.14";
sha256 = "sha256-MA9tZ7Osm5tHVoGB6zXyCgczKioS7MYucTJSPoOoUvE=";
};
});
xfs_67 = mkShell rec {
name = "6.7.0";
nativeBuildInputs = [ git lvm2 xfsdump ];
buildInputs = [
xfsprog
xfstest
];
shellHook = ''
host=$(hostname)
xfscheck=$(which xfstests-check)
basepath=$(dirname "$xfscheck")
xfstests_config_path="$basepath/../lib/xfstests/configs"
echo $xfstests_config_path
mkdir -p "$xfstests_config_path"
cat <<EOF >$xfstests_config_path/$host.config
[default]
FSTYP=xfs
RESULT_BASE=/root/results/
DUMP_CORRUPT_FS=1
CANON_DEVS=yes
RECREATE_TEST_DEV=true
TEST_DEV=/dev/nvme0n1
TEST_DIR=/media/test
SCRATCH_DEV=/dev/vdb
SCRATCH_MNT=/media/scratch
LOGWRITES_DEV=/dev/vdc
[8k]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=8k,'
[2k]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=2048,'
[64k]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=64k,'
[16k]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=16k,'
[8k_4ks]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=8k, -s size=4k'
[16k_4ks]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=16k, -s size=4k'
[64k_4ks]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=64k, -s size=4k'
[32k_4ks]
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=32k, -s size=4k'
EOF
mkdir -p /media/scratch
mkdir -p /media/test
mkfs.xfs -f /dev/nvme0n1
'';
};
xfs_64 = mkShell rec {
nativeBuildInputs = with pkgs.buildPackages; [ xfsprogs ];
};
};
in
packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment