summaryrefslogtreecommitdiff
path: root/tests/file-systems.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/file-systems.scm')
-rw-r--r--tests/file-systems.scm64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/file-systems.scm b/tests/file-systems.scm
index 4c28d0ebc5..7f7c373884 100644
--- a/tests/file-systems.scm
+++ b/tests/file-systems.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -64,4 +65,67 @@
(_ #f))
(source-module-closure '((gnu system file-systems)))))
+(test-equal "file-system-options->alist"
+ '("autodefrag" ("subvol" . "home") ("compress" . "lzo"))
+ (file-system-options->alist "autodefrag,subvol=home,compress=lzo"))
+
+(test-equal "file-system-options->alist (#f)"
+ '()
+ (file-system-options->alist #f))
+
+(test-equal "alist->file-system-options"
+ "autodefrag,subvol=root,compress=lzo"
+ (alist->file-system-options '("autodefrag"
+ ("subvol" . "root")
+ ("compress" . "lzo"))))
+
+(test-equal "alist->file-system-options (null)"
+ #f
+ (alist->file-system-options '()))
+
+
+;;;
+;;; Btrfs related.
+;;;
+
+(define %btrfs-root-subvolume
+ (file-system
+ (device (file-system-label "btrfs-pool"))
+ (mount-point "/")
+ (type "btrfs")
+ (options "subvol=rootfs,compress=zstd")))
+
+(define %btrfs-store-subvolid
+ (file-system
+ (device (file-system-label "btrfs-pool"))
+ (mount-point "/gnu/store")
+ (type "btrfs")
+ (options "subvolid=10,compress=zstd")
+ (dependencies (list %btrfs-root-subvolume))))
+
+(define %btrfs-store-subvolume
+ (file-system
+ (device (file-system-label "btrfs-pool"))
+ (mount-point "/gnu/store")
+ (type "btrfs")
+ (options "subvol=/some/nested/file/name")
+ (dependencies (list %btrfs-root-subvolume))))
+
+(test-assert "btrfs-subvolume? (subvol)"
+ (btrfs-subvolume? %btrfs-root-subvolume))
+
+(test-assert "btrfs-subvolume? (subvolid)"
+ (btrfs-subvolume? %btrfs-store-subvolid))
+
+(test-equal "btrfs-store-subvolume-file-name"
+ "/some/nested/file/name"
+ (parameterize ((%store-prefix "/gnu/store"))
+ (btrfs-store-subvolume-file-name (list %btrfs-root-subvolume
+ %btrfs-store-subvolume))))
+
+(test-error "btrfs-store-subvolume-file-name (subvolid)"
+ (parameterize ((%store-prefix "/gnu/store"))
+ (btrfs-store-subvolume-file-name (list %btrfs-root-subvolume
+ %btrfs-store-subvolid))))
+
(test-end)