| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 20 | (define-module (test-file-systems)
|
| 21 | #:use-module (guix store)
|
| 22 | #:use-module (guix modules)
|
| 23 | #:use-module (gnu system file-systems)
|
| 24 | #:use-module (srfi srfi-1)
|
| 25 | #:use-module ((srfi srfi-35) #:select (&message))
|
| 26 | #:use-module (srfi srfi-64)
|
| 27 | #:use-module (ice-9 match))
|
| 28 |
|
| 29 | |
| 30 |
|
| 31 | (test-begin "file-systems")
|
| 32 |
|
| 33 | (test-assert "file-system-needed-for-boot?"
|
| 34 | (let-syntax ((dummy-fs (syntax-rules ()
|
| 35 | ((_ directory)
|
| 36 | (file-system
|
| 37 | (device "foo")
|
| 38 | (mount-point directory)
|
| 39 | (type "ext4"))))))
|
| 40 | (parameterize ((%store-prefix "/gnu/guix/store"))
|
| 41 | (and (file-system-needed-for-boot? (dummy-fs "/"))
|
| 42 | (file-system-needed-for-boot? (dummy-fs "/gnu"))
|
| 43 | (file-system-needed-for-boot? (dummy-fs "/gnu/guix"))
|
| 44 | (file-system-needed-for-boot? (dummy-fs "/gnu/guix/store"))
|
| 45 | (not (file-system-needed-for-boot?
|
| 46 | (dummy-fs "/gnu/guix/store/foo")))
|
| 47 | (not (file-system-needed-for-boot? (dummy-fs "/gn")))
|
| 48 | (not (file-system-needed-for-boot?
|
| 49 | (file-system
|
| 50 | (inherit (dummy-fs (%store-prefix)))
|
| 51 | (device "/foo")
|
| 52 | (flags '(bind-mount read-only)))))))))
|
| 53 |
|
| 54 | (test-assert "does not pull (guix config)"
|
| 55 | |
| 56 | |
| 57 | |
| 58 | (not (member '(guix config)
|
| 59 | (source-module-closure '((gnu system file-systems))))))
|
| 60 |
|
| 61 | (test-equal "does not pull (gnu packages …)"
|
| 62 | |
| 63 | #f
|
| 64 | (find (match-lambda
|
| 65 | (('gnu 'packages _ ..1) #t)
|
| 66 | (_ #f))
|
| 67 | (source-module-closure '((gnu system file-systems)))))
|
| 68 |
|
| 69 | (test-equal "file-system-options->alist"
|
| 70 | '("autodefrag" ("subvol" . "home") ("compress" . "lzo"))
|
| 71 | (file-system-options->alist "autodefrag,subvol=home,compress=lzo"))
|
| 72 |
|
| 73 | (test-equal "file-system-options->alist (#f)"
|
| 74 | '()
|
| 75 | (file-system-options->alist #f))
|
| 76 |
|
| 77 | (test-equal "alist->file-system-options"
|
| 78 | "autodefrag,subvol=root,compress=lzo"
|
| 79 | (alist->file-system-options '("autodefrag"
|
| 80 | ("subvol" . "root")
|
| 81 | ("compress" . "lzo"))))
|
| 82 |
|
| 83 | (test-equal "alist->file-system-options (null)"
|
| 84 | #f
|
| 85 | (alist->file-system-options '()))
|
| 86 |
|
| 87 |
|
| 88 | |
| 89 | |
| 90 | |
| 91 |
|
| 92 | (define %btrfs-root-subvolume
|
| 93 | (file-system
|
| 94 | (device (file-system-label "btrfs-pool"))
|
| 95 | (mount-point "/")
|
| 96 | (type "btrfs")
|
| 97 | (options "subvol=rootfs,compress=zstd")))
|
| 98 |
|
| 99 | (define %btrfs-store-subvolid
|
| 100 | (file-system
|
| 101 | (device (file-system-label "btrfs-pool"))
|
| 102 | (mount-point "/gnu/store")
|
| 103 | (type "btrfs")
|
| 104 | (options "subvolid=10,compress=zstd")
|
| 105 | (dependencies (list %btrfs-root-subvolume))))
|
| 106 |
|
| 107 | (define %btrfs-store-subvolume
|
| 108 | (file-system
|
| 109 | (device (file-system-label "btrfs-pool"))
|
| 110 | (mount-point "/gnu/store")
|
| 111 | (type "btrfs")
|
| 112 | (options "subvol=/some/nested/file/name")
|
| 113 | (dependencies (list %btrfs-root-subvolume))))
|
| 114 |
|
| 115 | (test-assert "btrfs-subvolume? (subvol)"
|
| 116 | (btrfs-subvolume? %btrfs-root-subvolume))
|
| 117 |
|
| 118 | (test-assert "btrfs-subvolume? (subvolid)"
|
| 119 | (btrfs-subvolume? %btrfs-store-subvolid))
|
| 120 |
|
| 121 | (test-equal "btrfs-store-subvolume-file-name"
|
| 122 | "/some/nested/file/name"
|
| 123 | (parameterize ((%store-prefix "/gnu/store"))
|
| 124 | (btrfs-store-subvolume-file-name (list %btrfs-root-subvolume
|
| 125 | %btrfs-store-subvolume))))
|
| 126 |
|
| 127 | (test-error "btrfs-store-subvolume-file-name (subvolid)"
|
| 128 | &message
|
| 129 | (parameterize ((%store-prefix "/gnu/store"))
|
| 130 | (btrfs-store-subvolume-file-name (list %btrfs-root-subvolume
|
| 131 | %btrfs-store-subvolid))))
|
| 132 |
|
| 133 | (test-end)
|