nixosTests.bcache: init

This commit is contained in:
Shogo Takata
2025-09-11 02:53:29 +09:00
parent f0244a0dd3
commit 86263107aa
3 changed files with 46 additions and 0 deletions

View File

@@ -244,6 +244,7 @@ in
ayatana-indicators = runTest ./ayatana-indicators.nix;
babeld = runTest ./babeld.nix;
bazarr = runTest ./bazarr.nix;
bcache = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./bcache.nix;
bcachefs = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./bcachefs.nix;
beanstalkd = runTest ./beanstalkd.nix;
bees = runTest ./bees.nix;

40
nixos/tests/bcache.nix Normal file
View File

@@ -0,0 +1,40 @@
{ pkgs, ... }:
{
name = "bcache";
meta.maintainers = with pkgs.lib.maintainers; [ pineapplehunter ];
nodes.machine =
{ pkgs, ... }:
{
virtualisation.emptyDiskImages = [ 4096 ];
networking.hostId = "deadbeef";
boot.supportedFilesystems = [ "ext4" ];
environment.systemPackages = [ pkgs.parted ];
};
testScript = ''
machine.succeed("modprobe bcache")
machine.succeed("bcache version")
machine.succeed("ls /dev")
machine.succeed(
"mkdir /tmp/mnt",
"udevadm settle",
"parted --script /dev/vdb mklabel gpt",
"parted --script /dev/vdb mkpart primary 0% 50% mkpart primary 50% 100%",
"udevadm settle",
"bcache make -C /dev/vdb1",
"bcache make -B /dev/vdb2",
"udevadm settle",
"bcache attach /dev/vdb1 /dev/vdb2",
"bcache set-cachemode /dev/vdb2 writeback",
"udevadm settle",
"bcache show",
"ls /sys/fs/bcache",
"mkfs.ext4 /dev/bcache0",
"mount /dev/bcache0 /tmp/mnt",
"umount /tmp/mnt",
"udevadm settle",
)
'';
}

View File

@@ -6,6 +6,7 @@
util-linux,
bash,
udevCheckHook,
nixosTests,
}:
stdenv.mkDerivation rec {
@@ -51,6 +52,10 @@ stdenv.mkDerivation rec {
mkdir -p "$out/sbin" "$out/lib/udev/rules.d" "$out/share/man/man8"
'';
passthru.tests = {
inherit (nixosTests) bcache;
};
meta = {
description = "User-space tools required for bcache (Linux block layer cache)";
longDescription = ''