system.scm 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (test-system)
  19. #:use-module (gnu)
  20. #:use-module (guix store)
  21. #:use-module (srfi srfi-1)
  22. #:use-module (srfi srfi-64))
  23. ;; Test the (gnu system) module.
  24. (define %root-fs
  25. (file-system
  26. (device "my-root")
  27. (title 'label)
  28. (mount-point "/")
  29. (type "ext4")))
  30. (define %os
  31. (operating-system
  32. (host-name "komputilo")
  33. (timezone "Europe/Berlin")
  34. (locale "en_US.utf8")
  35. (bootloader (grub-configuration (target "/dev/sdX")))
  36. (file-systems (cons %root-fs %base-file-systems))
  37. (users %base-user-accounts)))
  38. (define %luks-device
  39. (mapped-device
  40. (source "/dev/foo") (target "my-luks-device")
  41. (type luks-device-mapping)))
  42. (define %os-with-mapped-device
  43. (operating-system
  44. (host-name "komputilo")
  45. (timezone "Europe/Berlin")
  46. (locale "en_US.utf8")
  47. (bootloader (grub-configuration (target "/dev/sdX")))
  48. (mapped-devices (list %luks-device))
  49. (file-systems (cons (file-system
  50. (inherit %root-fs)
  51. (dependencies (list %luks-device)))
  52. %base-file-systems))
  53. (users %base-user-accounts)))
  54. (test-begin "system")
  55. (test-assert "operating-system-store-file-system"
  56. ;; %BASE-FILE-SYSTEMS defines a bind-mount for /gnu/store, but this
  57. ;; shouldn't be a problem.
  58. (eq? %root-fs
  59. (operating-system-store-file-system %os)))
  60. (test-assert "operating-system-store-file-system, prefix"
  61. (let* ((gnu (file-system
  62. (device "foobar")
  63. (mount-point (dirname (%store-prefix)))
  64. (type "ext5")))
  65. (os (operating-system
  66. (inherit %os)
  67. (file-systems (cons* gnu %root-fs
  68. %base-file-systems)))))
  69. (eq? gnu (operating-system-store-file-system os))))
  70. (test-assert "operating-system-store-file-system, store"
  71. (let* ((gnu (file-system
  72. (device "foobar")
  73. (mount-point (%store-prefix))
  74. (type "ext5")))
  75. (os (operating-system
  76. (inherit %os)
  77. (file-systems (cons* gnu %root-fs
  78. %base-file-systems)))))
  79. (eq? gnu (operating-system-store-file-system os))))
  80. (test-equal "operating-system-user-mapped-devices"
  81. '()
  82. (operating-system-user-mapped-devices %os-with-mapped-device))
  83. (test-equal "operating-system-boot-mapped-devices"
  84. (list %luks-device)
  85. (operating-system-boot-mapped-devices %os-with-mapped-device))
  86. (test-equal "operating-system-boot-mapped-devices, implicit dependency"
  87. (list %luks-device)
  88. ;; Here we expect the implicit dependency between "/" and
  89. ;; "/dev/mapper/my-luks-device" to be found, in spite of the lack of a
  90. ;; 'dependencies' field in the root file system.
  91. (operating-system-boot-mapped-devices
  92. (operating-system
  93. (inherit %os-with-mapped-device)
  94. (file-systems (cons (file-system
  95. (device "/dev/mapper/my-luks-device")
  96. (title 'device)
  97. (mount-point "/")
  98. (type "ext4"))
  99. %base-file-systems)))))
  100. (test-end)