Merge pull request #305845 from abathur/resholve_0.10.5
[NixPkgs.git] / nixos / tests / apfs.nix
blob15ed5aa7f5736f74525a76c6bb96c4c98841bc4b
1 { lib, ... }: {
2   name = "apfs";
3   meta.maintainers = with lib.maintainers; [ Luflosi ];
5   nodes.machine = {
6     virtualisation.emptyDiskImages = [ 1024 ];
8     boot.supportedFilesystems = [ "apfs" ];
9   };
11   testScript = ''
12     machine.wait_for_unit("basic.target")
13     machine.succeed("mkdir /tmp/mnt")
15     with subtest("mkapfs refuses to work with a label that is too long"):
16       machine.fail( "mkapfs -L '000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F' /dev/vdb")
18     with subtest("mkapfs works with the maximum label length"):
19       machine.succeed("mkapfs -L '000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7' /dev/vdb")
21     with subtest("Enable case sensitivity and normalization sensitivity"):
22       machine.succeed(
23           "mkapfs -s -z /dev/vdb",
24           "mount -o cknodes,readwrite /dev/vdb /tmp/mnt",
25           "echo 'Hello World 1' > /tmp/mnt/test.txt",
26           "[ ! -f /tmp/mnt/TeSt.TxT ] || false", # Test case sensitivity
27           "echo 'Hello World 1' | diff - /tmp/mnt/test.txt",
28           "echo 'Hello World 2' > /tmp/mnt/\u0061\u0301.txt",
29           "echo 'Hello World 2' | diff - /tmp/mnt/\u0061\u0301.txt",
30           "[ ! -f /tmp/mnt/\u00e1.txt ] || false", # Test Unicode normalization sensitivity
31           "umount /tmp/mnt",
32           "apfsck /dev/vdb",
33       )
34     with subtest("Disable case sensitivity and normalization sensitivity"):
35       machine.succeed(
36           "mkapfs /dev/vdb",
37           "mount -o cknodes,readwrite /dev/vdb /tmp/mnt",
38           "echo 'bla bla bla' > /tmp/mnt/Test.txt",
39           "echo -n 'Hello World' > /tmp/mnt/test.txt",
40           "echo ' 1' >> /tmp/mnt/TEST.TXT",
41           "umount /tmp/mnt",
42           "apfsck /dev/vdb",
43           "mount -o cknodes,readwrite /dev/vdb /tmp/mnt",
44           "echo 'Hello World 1' | diff - /tmp/mnt/TeSt.TxT", # Test case insensitivity
45           "echo 'Hello World 2' > /tmp/mnt/\u0061\u0301.txt",
46           "echo 'Hello World 2' | diff - /tmp/mnt/\u0061\u0301.txt",
47           "echo 'Hello World 2' | diff - /tmp/mnt/\u00e1.txt", # Test Unicode normalization
48           "umount /tmp/mnt",
49           "apfsck /dev/vdb",
50       )
51     with subtest("Snapshots"):
52       machine.succeed(
53           "mkapfs /dev/vdb",
54           "mount -o cknodes,readwrite /dev/vdb /tmp/mnt",
55           "echo 'Hello World' > /tmp/mnt/test.txt",
56           "apfs-snap /tmp/mnt snap-1",
57           "rm /tmp/mnt/test.txt",
58           "umount /tmp/mnt",
59           "mount -o cknodes,readwrite,snap=snap-1 /dev/vdb /tmp/mnt",
60           "echo 'Hello World' | diff - /tmp/mnt/test.txt",
61           "umount /tmp/mnt",
62           "apfsck /dev/vdb",
63       )
64   '';