mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-05-25 02:21:49 +02:00
services: openntpd: Add test for issue #3731.
See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37318. * gnu/services/networking.scm (openntpd-configuration->string): New procedure, extracted from top of the `openntpd-shepherd-service' to make it testable. (openntpd-shepherd-service): Adapt following the move of the code to the above procedure. * tests/networking.scm: Add a test for the `openntpd-configuration->string' procedure.
This commit is contained in:
+20
-18
@@ -504,28 +504,30 @@ make an initial adjustment of more than 1,000 seconds."
|
||||
(allow-large-adjustment? openntpd-allow-large-adjustment?
|
||||
(default #f))) ; upstream default
|
||||
|
||||
(define (openntpd-shepherd-service config)
|
||||
(define (openntpd-configuration->string config)
|
||||
(match-record config <openntpd-configuration>
|
||||
(openntpd listen-on query-from sensor server servers constraint-from
|
||||
constraints-from allow-large-adjustment?)
|
||||
(listen-on query-from sensor server servers constraint-from
|
||||
constraints-from)
|
||||
(string-join
|
||||
(filter-map
|
||||
(lambda (field value)
|
||||
(string-join
|
||||
(map (cut string-append field <> "\n")
|
||||
value)))
|
||||
'("listen on " "query from " "sensor " "server " "servers "
|
||||
"constraint from ")
|
||||
(list listen-on query-from sensor server servers constraint-from))
|
||||
;; The 'constraints from' field needs to be enclosed in double quotes.
|
||||
(string-join
|
||||
(map (cut string-append "constraints from \"" <> "\"\n")
|
||||
constraints-from)))))
|
||||
|
||||
(define config
|
||||
(string-join
|
||||
(filter-map
|
||||
(lambda (field value)
|
||||
(string-join
|
||||
(map (cut string-append field <> "\n")
|
||||
value)))
|
||||
'("listen on " "query from " "sensor " "server " "servers "
|
||||
"constraint from ")
|
||||
(list listen-on query-from sensor server servers constraint-from))
|
||||
;; The 'constraints from' field needs to be enclosed in double quotes.
|
||||
(string-join
|
||||
(map (cut string-append "constraints from \"" <> "\"\n")
|
||||
constraints-from))))
|
||||
(define (openntpd-shepherd-service config)
|
||||
(let ((openntpd (openntpd-configuration-openntpd config))
|
||||
(allow-large-adjustment? (openntpd-allow-large-adjustment? config)))
|
||||
|
||||
(define ntpd.conf
|
||||
(plain-file "ntpd.conf" config))
|
||||
(plain-file "ntpd.conf" (openntpd-configuration->string config)))
|
||||
|
||||
(list (shepherd-service
|
||||
(provision '(ntpd))
|
||||
|
||||
Reference in New Issue
Block a user