aboutsummaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-09-07 09:24:43 +0900
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-09-08 23:15:32 +0900
commit2625abc6aa5df66a6503e906b7592691452954f5 (patch)
treeff8e118d5d3c5615e261a82d3202f4b6cbc876aa /gnu/services
parentafd39a76e26a8ad6d77e65b7316b912fd8dbb623 (diff)
downloadguix-2625abc6aa5df66a6503e906b7592691452954f5.tar.gz
guix-2625abc6aa5df66a6503e906b7592691452954f5.zip
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.
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/networking.scm40
1 files changed, 21 insertions, 19 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index dd2f9e29e2..432f3a80ee 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -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?)
-
- (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))))
+ (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 (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))