mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
nixos/tests: add swap-partition test
This commit is contained in:
parent
4c77ffb38f
commit
5249031660
2 changed files with 49 additions and 0 deletions
|
@ -516,6 +516,7 @@ in {
|
||||||
step-ca = handleTestOn ["x86_64-linux"] ./step-ca.nix {};
|
step-ca = handleTestOn ["x86_64-linux"] ./step-ca.nix {};
|
||||||
strongswan-swanctl = handleTest ./strongswan-swanctl.nix {};
|
strongswan-swanctl = handleTest ./strongswan-swanctl.nix {};
|
||||||
sudo = handleTest ./sudo.nix {};
|
sudo = handleTest ./sudo.nix {};
|
||||||
|
swap-partition = handleTest ./swap-partition.nix {};
|
||||||
sway = handleTest ./sway.nix {};
|
sway = handleTest ./sway.nix {};
|
||||||
switchTest = handleTest ./switch-test.nix {};
|
switchTest = handleTest ./switch-test.nix {};
|
||||||
sympa = handleTest ./sympa.nix {};
|
sympa = handleTest ./sympa.nix {};
|
||||||
|
|
48
nixos/tests/swap-partition.nix
Normal file
48
nixos/tests/swap-partition.nix
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
import ./make-test-python.nix ({ lib, pkgs, ... }:
|
||||||
|
{
|
||||||
|
name = "swap-partition";
|
||||||
|
|
||||||
|
nodes.machine =
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
{
|
||||||
|
virtualisation.useDefaultFilesystems = false;
|
||||||
|
|
||||||
|
virtualisation.bootDevice = "/dev/vda1";
|
||||||
|
|
||||||
|
boot.initrd.postDeviceCommands = ''
|
||||||
|
if ! test -b /dev/vda1; then
|
||||||
|
${pkgs.parted}/bin/parted --script /dev/vda -- mklabel msdos
|
||||||
|
${pkgs.parted}/bin/parted --script /dev/vda -- mkpart primary 1MiB -250MiB
|
||||||
|
${pkgs.parted}/bin/parted --script /dev/vda -- mkpart primary -250MiB 100%
|
||||||
|
sync
|
||||||
|
fi
|
||||||
|
|
||||||
|
FSTYPE=$(blkid -o value -s TYPE /dev/vda1 || true)
|
||||||
|
if test -z "$FSTYPE"; then
|
||||||
|
${pkgs.e2fsprogs}/bin/mke2fs -t ext4 -L root /dev/vda1
|
||||||
|
${pkgs.util-linux}/bin/mkswap --label swap /dev/vda2
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
virtualisation.fileSystems = {
|
||||||
|
"/" = {
|
||||||
|
device = "/dev/disk/by-label/root";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices = [
|
||||||
|
{
|
||||||
|
device = "/dev/disk/by-label/swap";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
|
with subtest("Swap is active"):
|
||||||
|
# Doesn't matter if the numbers reported by `free` are slightly off due to unit conversions.
|
||||||
|
machine.succeed("free -h | grep -E 'Swap:\s+2[45][0-9]Mi'")
|
||||||
|
'';
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue